The Graphics LCD used here is JHD12864E. This LCD is divided into two parts which are controlled by two different controllers. Each of these parts is divided into rows and columns. For basic instructions and programming procedure, refer to interfacing Graphics LCD with 8051.
To display different font types, corresponding header files have been created. These header files contain the bitmap information of all alphabetic, numeric characters and symbols of a particular font. These header files are included into the main program. (The header file declarations are given in Code2)
The strings to be displayed are stored in a character array. These strings are passed as arguments to a user defined function. The bitmap information of each character is called through pointer from respective header file. This way the whole string can be displayed.
This function is used to display string (with character font 8x8) directly on LCD.
· First, a column and a page numbers are passed as arguments through puts1() function in variables y and x respectively.
· y and x are used to set column and page addresses in the function.
· The pointer *str receives the string (to be displayed on LCD) from the main function.
· Then each character from string is taken with the help of for loop:
for(i=0; str[i]!=0; i++)
a = (*( str+i ));
· The bitmap code of each character of the string is taken from the array character8x8. The array character8x8 is defined in header file named as <font.h>. This array contains the bitmap codes of all characters and these codes are arranged in the same order as in the ASCII table.
· The condition[a*=8; ] is used to increase the address of the character in array character8x8 by 8 because the size of bitmap of each character is 8 bytes which needs to be skipped. This array is saved as code unsigned char. The unsigned char makes it an unsigned character array and the keyword code saves it to flash memory of microcontroller. Thus long arrays (which do not change in course of code) can be saved with small RAM of 8051 (here AT89C52 has been used which has 128 bytes of RAM and 8K bytes flash memory).
This function is used to display string ((with character font 5x7) directly on LCD. This function works similar to puts1() function with slight differences which are explained below.
· In the condition [ a=(*(str+i)-32); ], ‘32’ is subtracted because the ASCII value of the first character of array font5x7 is 32.
· The condition [ a*=5;] is used because the bitmap size of each character is 5 bytes (and not 8 as earlier) which needs to be skipped.
To scroll the strings, the start line has to be selected. The following steps are to be followed to write startline function:
a) Put these values in Data register
b) CS1=1, CS2=1 (display data on both halves of LCD)
c) RS=0, R/W=0 (to select the instruction mode)
f) EN=0 (to latch data into the input register)
To scroll the strings vertically just pass the successive line values to the setstartline() function. This can be easily done using a while loop (see Code). To blink the display, just call the display off and display on functions successively with some delay. The connections of LCD with controller are shown in circuit diagram. Also see displaying images on Graphics LCD.