This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:examples:display:lcd_alphanumeric [2010/03/05 15:49] – priitj | en:examples:display:lcd_alphanumeric [2020/07/20 12:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Alphanumeric LCD ====== | ||
| + | //Necessary knowledge: [LIB] [[en: | ||
| + | |||
| + | ===== Theory ===== | ||
| + | |||
| + | Alphanumeric LCD is liquid crystal display, with the purpose of displaying letters and numbers. | ||
| + | |||
| + | Main characteristic of alphanumerical LCD is the placing of its segments. The screen is divided into many indicators. Each indicator has either enough segments for displaying letters and numbers or it is formed from matrix of little square segments (pixels). For example, a matrix of 5x7 pixels is enough to display all numbers, and letters of Latin alphabet. There are usually 1 – 4 rows of indicators and 8 – 32 columns. Each indicator has a small difference similar to the differences of the letters in text. | ||
| + | |||
| + | |||
| + | [{{ : | ||
| + | |||
| + | Besides the screen Alphanumerical LCD has also controller which controls the segments of the screen according to the commands from the communication interface. | ||
| + | |||
| + | Alphanumerical LCDs are usually with passive matrix, where renewal of the electrical field of the segments is tone in turns. That is why the screens with passive matrix are slower and have less contrast compared with the active matrix screens where the charge of each segment is controlled by separate transistor. Some LCDs are with reflective back and others with backlight sometimes even with several different backlights. But segment colour for alphanumerical LCDs is usually still one – which is black, however there are also screens with white and colorful writings. | ||
| + | |||
| + | |||
| + | ===== Practice ===== | ||
| + | |||
| + | HomeLabs Digital i/o module connects a 2x16 symbol alphanumerical LCD WC 1602A. For controlling the screen, there is a 4-bit data-bus and 3 control pins, but its communication protocol is too capacious, to be explained here. For simplicity, the library of the HomeLab has corresponding functions for using the display. | ||
| + | |||
| + | Before using the display it is vital to adjust its settings. For this purpose is the // lcd_alpha_init// | ||
| + | |||
| + | The following program code demonstrates the usage of alphanumerical LCD as a clock. The Time begins at 00:00:00 and grows approximately in every second. Since the counting of the time is done with the delay function, it is not very precise. The inaccuracy is explained in the exercise of the periodic interruption. The program counts the seconds and converts them into minutes and seconds. For using clock time is a standard function in the C-language: // | ||
| + | |||
| + | |||
| + | <code c> | ||
| + | // | ||
| + | // The example of using the alphanumerical LCD of the HomeLab. | ||
| + | // The clock time starting at the beginning of the program is displayed on the LCD. | ||
| + | // | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | // | ||
| + | // Main program. | ||
| + | // | ||
| + | int main(void) | ||
| + | { | ||
| + | int seconds = 0; | ||
| + | char text[16]; | ||
| + | |||
| + | // Set-up of the LCD. | ||
| + | lcd_alpha_init(LCD_ALPHA_DISP_ON); | ||
| + | |||
| + | // Cleaning of the LCD. | ||
| + | lcd_alpha_clear(); | ||
| + | |||
| + | // Name of the program. | ||
| + | lcd_alpha_write_string(" | ||
| + | |||
| + | // Endless loop | ||
| + | while (true) | ||
| + | { | ||
| + | // Converting the seconds to the clock form: | ||
| + | // hh:mm:ss | ||
| + | sprintf(text, | ||
| + | (seconds / 3600) % 24, | ||
| + | (seconds / 60) % 60, | ||
| + | seconds % 60); | ||
| + | |||
| + | // Displaying the clock text in the LCD. | ||
| + | lcd_alpha_goto_xy(0, | ||
| + | lcd_alpha_write_string(text); | ||
| + | |||
| + | // Growing seconds by 1. | ||
| + | seconds++; | ||
| + | |||
| + | // Hardware delay 1000 ms. | ||
| + | hw_delay_ms(1000); | ||
| + | } | ||
| + | } | ||
| + | </ | ||