This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:examples:display:lcd_graphic [2012/06/29 14:59] – raivo.sell | en:examples:display:lcd_graphic [2020/07/20 12:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Graphic LCD ====== | ||
| + | //Necessary knowledge: [HW] [[en: | ||
| + | |||
| + | ===== Theory ===== | ||
| + | |||
| + | Graphical LCD //liquid crystal display// is a display which allows displaying pictures and text. Its construction is similar to the alphanumerical LCD, with a difference 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. | ||
| + | |||
| + | ===== Practice ===== | ||
| + | |||
| + | In the Home-Lab set is a 84x48 pixels monochrome graphic LCD. It is the same display as used in Nokia 3310 mobile phones. Philips PCD8544 controller is attached to the display which can be communicated through SPI-like serial interface. The background lighting of the display module is separately controlled. Communicating with the display is not very difficult, but due to the large amount of the functions it is not explained here. Home-Labs library has functions for using it. | ||
| + | |||
| + | The functions of the graphic LCD are similar to the alphanumeric LCD functions. First, the screen must be started with // lcd_gfx_init// | ||
| + | |||
| + | The following is an example of time counter. The program counts seconds (approximately), | ||
| + | |||
| + | <code c> | ||
| + | // | ||
| + | // Example of using the graphic LCD of the HomeLab. | ||
| + | // Time of day is displayed on LCD since the beginning of the program. | ||
| + | // | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | // | ||
| + | // 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, | ||
| + | lcd_gfx_write_string(" | ||
| + | |||
| + | // Endless loop. | ||
| + | while (true) | ||
| + | { | ||
| + | // Converting the seconds to the form of clock. | ||
| + | // hh:mm:ss | ||
| + | sprintf(text, | ||
| + | (seconds / 3600) % 24, | ||
| + | (seconds / 60) % 60, | ||
| + | seconds % 60); | ||
| + | |||
| + | // Displaying the clock text. | ||
| + | lcd_gfx_goto_char_xy(3, | ||
| + | lcd_gfx_write_string(text); | ||
| + | |||
| + | // Adding one second. | ||
| + | seconds++; | ||
| + | |||
| + | // Hardware delay for 1000 ms. | ||
| + | hw_delay_ms(1000); | ||
| + | } | ||
| + | } | ||
| + | </ | ||