Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
en:iot-open:practical:hardware:itt:avr:lcd [2025/08/26 11:15] – [LCD screen] ingmar05en:iot-open:practical:hardware:itt:avr:lcd [2025/09/02 12:30] (current) raivo.sell
Line 1: Line 1:
 +<pagebreak>
 +====== LCD screen ======
 +===== Theory =====
  
 +[{{ :examples:display:lcd:lcd_element.jpg?250|The graphical LCD element}}]
 +/*[{{  :examples:display:lcd_alphanumeric:lcd_alphanumeric_abc.png?200|Alfabeetilise LCD pikslite maatriksitest moodustatud tekst}}]*/
 +
 +[{{  :examples:display:lcd_graphic:lcd_graphic_smiley.png?200|The picture formed of pixels of a graphic LCD}}]
 +
 +A graphical LCD liquid crystal display is a display that allows displaying pictures and text. Its construction is similar to the alphanumeric LCD, with a difference that on the graphic display, all pixels are divided into a single large matrix. If we are dealing with a monochrome LCD, then a pixel is one square segment. In a color display, a 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 usually have a passive matrix, and large color displays, including computer screens, have an active matrix. All information concerning the color of the background and the pixels of the graphic LCDs is similar to that of alphanumeric LCDs. Similar to the alphanumeric displays, graphic displays are also equipped with a separate controller, which takes care of receiving information through the communication interface and generating the electrical field for the segments.
 +
 +
 +===== Practice =====
 +
 +HomeLab User Interface is an 84×48-pixel monochrome graphic LCD. It is the same display as used in Nokia 3310 mobile phones. The Philips PCD8544 controller is attached to the display, which can be communicated through a SPI-like serial interface. The background lighting of the display module is separately controlled. 
 +
 +First, the graphical LCD screen must be started with //lcd_gfx_init// function. There is a letter map inside the library with the full Latin alphabet, numbers, and the most common signs written. To display a letter or text, first its position must be determined by using the function //lcd_gfx_goto_char_xy//. For displaying a letter is //lcd_gfx_write_char// function, and for displaying text //lcd_gfx_write_string// function.
 +
 +The following is an example of a time counter. The program counts seconds (approximately), minutes, and hours. For converting time to text, the sprintf function is used.
 +
 +<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 <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("Time counter");
 +
 + // Endless loop
 + while (true)
 + {
 + // Converting the seconds to the form of a 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);
 + }
 +}
 +</code>
 +
 +
 +==== Task to be implemented ====
 +
 +  - Combine with LED tasks (traffic light) and show on the LCD screen, which LED is currently active.
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0