ezLCD+103 Driver  0.1
Driver code for the ezLCD+103
 All Files Functions Typedefs Enumerations Groups Pages
Getting Started With the ezLCD+103

The Earth LCD ezLCD+103 is a 3.5" 320x240, 24 bit Color TFT LCD touch screen with a built-in GPU. Unlike other screens, the brains are built in so the user need not worry about complex algorithms. This makes the display easy and intuitive to use. Anyone who can send data serially in a wide variety of interfaces can use the ezLCD+103.

The technical writeup for this project can be found here in PDF form or in Microsoft Word form

full_tb.jpg
ezLCD+103 Powered on and ready to use



Before writing any code, we must wire the display to the microcontroller. The schematic shown below illustrate the required connections.

schematic.png
Connecting the ezLCD+103 to the ATMega128

The Sparkfun BOB-12009 is a bi-polar logic level converter. It allows us to drive the ezLCD+103 from the ATMega128 since the ezLCD+103 utilizes 3.3V logic rather than the 5V logic of the ATmega128 The Hirose DF11-32DS is a 3 2-pin 2mm connector which the ezLCD+103 uses to interact with the outside world.

Once the display is properly connected, the user may begin to code.

Using this library is simple.

The library assumes that the user is communicating over SPI and is running their microcontroller at 16MHZ

The following code snippet illustrates how to write a simple program for this display using the ATMega128. Of course, this snippet only illustrates a small preview of the functions in this library. Please explore the rest of this page for an in-depth overview of this library.

This code snippet generates the simple menu shown at the top of this page. It performs simple tasks such as writing characters to a text box and switching between menus.

/*----------------------------------------------------------------------------*/
/* INCLUDES */
/*----------------------------------------------------------------------------*/
#include <iom128.h>
#include <intrinsics.h>
#include <avr_macros.h>
#include <stdio.h>
/*----------------------------------------------------------------------------*/
/* BUTTON IDs */
/*----------------------------------------------------------------------------*/
#define ZERO 0
#define ONE 1
#define TWO 2
#define THREE 3
#define FOUR 4
#define FIVE 5
#define SIX 6
#define SEVEN 7
#define EIGHT 8
#define NINE 9
#define STAR 10
#define POUND 11
#define START 12
#define STOP 13
#define CALIBRATE 14
/*----------------------------------------------------------------------------*/
/* PROTOTYPES */
/*----------------------------------------------------------------------------*/
void draw_buttons();
void draw_number_pad(uint8_t num_pad_x, uint8_t num_pad_y);
/*----------------------------------------------------------------------------*/
/* FUNCTIONS */
/*----------------------------------------------------------------------------*/
int main (void)
{
DDRB = (1<<EZLCD_POWER_PIN) | //power pin output
(0<<EZLCD_MISO_PIN) | //MISO pin input
(1<<EZLCD_MOSI_PIN) | //MOSI pin output
(1<<EZLCD_SCK_PIN) | //SCK pin output
(1<<EZLCD_SS_BAR_PIN); //SS_BAR pin output
__delay_cycles(10000);
/* Wait until display is fully powered and ready */
while(!ezLCD_ping());
/* Clear the screen contents */
/* Place background image */
ezLCD_put_picture_rom(BACKGROUND_1_INDEX);
/* Set touch protocol */
/* Draw buttons on the screen */
draw_buttons();
/* Initialize the putchar() function */
ezLCD_init_putchar(5, 5, 165-5, 70-5, 2, 2, 32,32,EZLCD_WHITE,EZLCD_VIOLET);
/* Set the font */
ezLCD_set_true_type_font(DEJAVUSANS-BOLD,32,32);
while(1)
{
/* Wait for button press */
/* Case on the button */
if(button == CALIBRATE)
{
ezLCD_calibrate_screen(); /* Calibrate the screen */
/* Reset font, there appears to be a bug with the display itself where
*calibrating changes the font size
*/
ezLCD_set_true_type_font(DEJAVUSANS-BOLD,32,32);
}
/* Zero through 9 */
if(button <= NINE)
printf("%d",button); /* Print the button ID to the text box */
/* Change the font mid-program and print a magical character */
if(button == STAR)
{
ezLCD_set_true_type_font(WALTOGRAPH,32,32);
ezLCD_set_true_type_font(DEJAVUSANS-BOLD,32,32);
}
/* If Pound button, print Greek letter Delta (TTF Fonts Only!)*/
if(button == POUND)
{
}
/* Clear screen of number pad and text box */
if(button == STOP)
{
ezLCD_put_picture_rom(BACKGROUND_1_INDEX);
EZLCD_BUTTON_UP,
CALIBRATE_BUTTON_EZLCD_BUTTON_UP_INDEX,
CALIBRATE_BUTTON_EZLCD_BUTTON_DOWN_INDEX,
CALIBRATE_BUTTON_DISABLED_INDEX,
215,
115,
CALIBRATE_BUTTON_WIDTH,
CALIBRATE_BUTTON_HEIGHT);
EZLCD_BUTTON_UP,
START_BUTTON_EZLCD_BUTTON_UP_INDEX,
START_BUTTON_EZLCD_BUTTON_DOWN_INDEX,
START_BUTTON_DISABLED_INDEX,
215,
5,
START_BUTTON_WIDTH,
START_BUTTON_HEIGHT);
EZLCD_BUTTON_UP,
STOP_BUTTON_EZLCD_BUTTON_UP_INDEX,
STOP_BUTTON_EZLCD_BUTTON_DOWN_INDEX,
STOP_BUTTON_DISABLED_INDEX,
215,
60,
STOP_BUTTON_WIDTH,
STOP_BUTTON_HEIGHT);
}
/* Restore numberpad and text box */
if(button == START)
{
ezLCD_put_picture_rom(BACKGROUND_1_INDEX);
draw_buttons();
ezLCD_init_putchar(5, 5, 165-5, 70-5, 2, 2, 32,32,EZLCD_WHITE,EZLCD_VIOLET);
ezLCD_set_true_type_font(DEJAVUSANS-BOLD,32,32);
}
}
}
void draw_buttons()
{
draw_number_pad(5,80);
EZLCD_BUTTON_UP,
START_BUTTON_EZLCD_BUTTON_UP_INDEX,
START_BUTTON_EZLCD_BUTTON_DOWN_INDEX,
START_BUTTON_DISABLED_INDEX,
215,
5,
START_BUTTON_WIDTH,
START_BUTTON_HEIGHT);
EZLCD_BUTTON_UP,
STOP_BUTTON_EZLCD_BUTTON_UP_INDEX,
STOP_BUTTON_EZLCD_BUTTON_DOWN_INDEX,
STOP_BUTTON_DISABLED_INDEX,
215,
60,
STOP_BUTTON_WIDTH,
STOP_BUTTON_HEIGHT);
EZLCD_BUTTON_UP,
CALIBRATE_BUTTON_EZLCD_BUTTON_UP_INDEX,
CALIBRATE_BUTTON_EZLCD_BUTTON_DOWN_INDEX,
CALIBRATE_BUTTON_DISABLED_INDEX,
215,
115,
CALIBRATE_BUTTON_WIDTH,
CALIBRATE_BUTTON_HEIGHT);
}
/* Used to keep numbers grouped together neatly */
void draw_number_pad(uint8_t num_pad_x, uint8_t num_pad_y)
{
EZLCD_BUTTON_UP,
ZERO_BUTTON_EZLCD_BUTTON_UP_INDEX,
ZERO_BUTTON_EZLCD_BUTTON_DOWN_INDEX,
ZERO_BUTTON_DISABLED_INDEX,
num_pad_x + 50 + 5,
num_pad_y + 105 + 15,
ZERO_BUTTON_WIDTH,
ZERO_BUTTON_HEIGHT);
EZLCD_BUTTON_UP,
ONE_BUTTON_EZLCD_BUTTON_UP_INDEX,
ONE_BUTTON_EZLCD_BUTTON_DOWN_INDEX,
ONE_BUTTON_DISABLED_INDEX,
num_pad_x,
num_pad_y,
ONE_BUTTON_WIDTH,
ONE_BUTTON_HEIGHT);
EZLCD_BUTTON_UP,
TWO_BUTTON_EZLCD_BUTTON_UP_INDEX,
TWO_BUTTON_EZLCD_BUTTON_DOWN_INDEX,
TWO_BUTTON_DISABLED_INDEX,
num_pad_x + 50 + 5,
num_pad_y,
TWO_BUTTON_WIDTH,
TWO_BUTTON_HEIGHT);
EZLCD_BUTTON_UP,
THREE_BUTTON_EZLCD_BUTTON_UP_INDEX,
THREE_BUTTON_EZLCD_BUTTON_DOWN_INDEX,
THREE_BUTTON_DISABLED_INDEX,
num_pad_x + 100 + 10,
num_pad_y,
THREE_BUTTON_WIDTH,
THREE_BUTTON_HEIGHT);
EZLCD_BUTTON_UP,
FOUR_BUTTON_EZLCD_BUTTON_UP_INDEX,
FOUR_BUTTON_EZLCD_BUTTON_DOWN_INDEX,
FOUR_BUTTON_DISABLED_INDEX,
num_pad_x,
num_pad_y + 35 + 5,
FOUR_BUTTON_WIDTH,
FOUR_BUTTON_HEIGHT);
EZLCD_BUTTON_UP,
FIVE_BUTTON_EZLCD_BUTTON_UP_INDEX,
FIVE_BUTTON_EZLCD_BUTTON_DOWN_INDEX,
FIVE_BUTTON_DISABLED_INDEX,
num_pad_x + 50 + 5,
num_pad_y + 35 + 5,
FIVE_BUTTON_WIDTH,
FIVE_BUTTON_HEIGHT);
EZLCD_BUTTON_UP,
SIX_BUTTON_EZLCD_BUTTON_UP_INDEX,
SIX_BUTTON_EZLCD_BUTTON_DOWN_INDEX,
SIX_BUTTON_DISABLED_INDEX,
num_pad_x + 100 + 10,
num_pad_y + 35 + 5,
SIX_BUTTON_WIDTH,
SIX_BUTTON_HEIGHT);
EZLCD_BUTTON_UP,
SEVEN_BUTTON_EZLCD_BUTTON_UP_INDEX,
SEVEN_BUTTON_EZLCD_BUTTON_DOWN_INDEX,
SEVEN_BUTTON_DISABLED_INDEX,
num_pad_x,
num_pad_y + 70 + 10,
SEVEN_BUTTON_WIDTH,
SEVEN_BUTTON_HEIGHT);
EZLCD_BUTTON_UP,
EIGHT_BUTTON_EZLCD_BUTTON_UP_INDEX,
EIGHT_BUTTON_EZLCD_BUTTON_DOWN_INDEX,
EIGHT_BUTTON_DISABLED_INDEX,
num_pad_x + 50 + 5,
num_pad_y + 70 + 10,
EIGHT_BUTTON_WIDTH,
EIGHT_BUTTON_HEIGHT);
EZLCD_BUTTON_UP,
NINE_BUTTON_EZLCD_BUTTON_UP_INDEX,
NINE_BUTTON_EZLCD_BUTTON_DOWN_INDEX,
NINE_BUTTON_DISABLED_INDEX,
num_pad_x + 100 + 10,
num_pad_y + 70 + 10,
NINE_BUTTON_WIDTH,
NINE_BUTTON_HEIGHT);
EZLCD_BUTTON_UP,
STAR_BUTTON_EZLCD_BUTTON_UP_INDEX,
STAR_BUTTON_EZLCD_BUTTON_DOWN_INDEX,
STAR_BUTTON_DISABLED_INDEX,
num_pad_x,
num_pad_y + 105 + 15,
STAR_BUTTON_WIDTH,
STAR_BUTTON_HEIGHT);
EZLCD_BUTTON_UP,
POUND_BUTTON_EZLCD_BUTTON_UP_INDEX,
POUND_BUTTON_EZLCD_BUTTON_DOWN_INDEX,
POUND_BUTTON_DISABLED_INDEX,
num_pad_x + 100 + 10,
num_pad_y + 105 + 15,
POUND_BUTTON_WIDTH,
POUND_BUTTON_HEIGHT);
}