This is an old revision of the document!
Necessary knowledge: [HW] lcd, [LIB] Graphic LCD, [LIB] Delay, [PRT] Alphanumeric LCD
Graphical LCD liquid crystal display is a display which allows displaying pictures and text. Its known as alphanumericLCD. Basic liquid crystal displays are using see-through electrodes placed between liquid crystal, which changes the polarisation of the passing light in an electric field. Electrodes are covered by polarisation filters, which assure that only one way polarised light can pass the display.In case the liquid crystal changes the polarisation due to electric field, the light on the display or part of it cannot pass and it appears dark. Its construction is similar to the alphanumerical LCD, the main difference is that on the graphic display all pixels are divided as one large matrix. If we are dealing with a monochrome LCD, then a pixel is one square segment. Color displays’ one pixel is formed of three subpixels. Each of the three subpixels lets only one colored light pass (red, green or blue). Since the subpixels are positioned very close to each other, they seem like one pixel.
Monochrome graphic displays have usually passive matrix, large color displays including computer screens have active matrix. All information concerning the color of the background and the pixels of the graphic LCD-s is the same as the alphanumerical LCD-s – there is a lot of variants. And similar to the alphanumerical displays, the graphic displays have also a separate controller, which takes care of receiving information through the communication interface and generating the electrical field for the segments. If for alphanumerical LCD it is enough to send indexes of the signs in order to display text, then graphic displays are not capable of generating letters by themselves – all the pictures and text needs to be generated by the user pixel by pixel.
In the Home-Lab set is a 84×48 pixels monochrome graphic LCD. It is the same display which is used in Nokia 3310 mobile phones. To the screen is attached a Philips PCD8544 controller which can be communicated through SPI like serial interface. The background lighting of the display module is also separately controlled. Communicating with the screen is not very difficult, but due to the large amount of the functions it is not explained here. There are functions to use it in the library of the Home-Lab.
The functions of the graphic LCD are similar to the alphanumeric LCD functions. First, the screen must be started with lcd_gfx_init function. After startup it is advised to clean the screen (the memory of the controller) with the lcd_gfx_clear function. There is a letter map which contains all the numbers, letters and most common signs written inside of the library. The height of the letter is 7 and the width of the letter is 5 pixels. The gap between each letter is horizontally 6 and vertically 8 pixels, i.e. there can be 6 rows and 14 columns of letters overall. To display a letter or text, first its position must be determined by using the function lcd_gfx_goto_char_xy . For displaying the letter is lcd_gfx_write_char function and for displaying text lcd_gfx_write_string function.
The following is an example of time counter. The program counts seconds (approximately), minutes and hours. For converting time to text is sprintf function.
// // Example of using the graphic LCD of the Home Lab. // The clock time since the beginning of the program is displayed LCD. // #include <stdio.h> #include <homelab/module/lcd_gfx.h> #include <homelab/delay.h> // // Main program. // int main(void) { int seconds = 0; char text[16]; // Set-up of the LCD. lcd_gfx_init(); // Cleaning the screen. lcd_gfx_clear(); // Switching on the background light. lcd_gfx_backlight(true); // Displaying the name of the program. lcd_gfx_goto_char_xy(1, 1); lcd_gfx_write_string("Aja loendur"); // Endless loop. while (true) { // Converting the seconds to the form of clock. // hh:mm:ss sprintf(text, "%02d:%02d:%02d", (seconds / 3600) % 24, (seconds / 60) % 60, seconds % 60); // Displaying the clock text. lcd_gfx_goto_char_xy(3, 3); lcd_gfx_write_string(text); // Adding one second. seconds++; // Hardware delay for 1000 ms. hw_delay_ms(1000); } }