Both sides previous revisionPrevious revisionNext revision | Previous revision |
en:examples:display:lcd_graphic [2010/03/05 14:18] – priitj | en:examples:display:lcd_graphic [2020/07/20 09:00] (current) – external edit 127.0.0.1 |
---|
====== Graphic LCD ====== | ====== Graphic LCD ====== |
| |
//Necessary knowledge: [HW] [[en:hardware:homelab:lcd]], [LIB] [[en:software:homelab:library:module:lcd_graphic]], [LIB] [[en:software:homelab:library:delay]], [PRT] [[en:examples:display:lcd_alphanumeric]]// | //Necessary knowledge: [HW] [[en:hardware:homelab:digi]], [LIB] [[en:software:homelab:library:module:lcd_graphic]], [LIB] [[en:software:homelab:library:delay]], [PRT] [[en:examples:display:lcd_alphanumeric]]// |
| |
===== Theory ===== | ===== Theory ===== |
| |
Graphical LCD //liquid crystal display// is a display which allows displaying pictures besides text. 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. | 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. |
| |
[{{ :examples:display:lcd_graphic:lcd_graphic_abc.png?200|The text formed of pixels of a graphic LCD.}}] | [{{ :examples:display:lcd_graphic:lcd_graphic_abc.png?200|The text formed of pixels of a graphic LCD.}}] |
| |
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. | 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 LCDs are similar to alphanumerical LCDs. Similar to the alphanumerical displays, graphic displays are also equipped with separate controller, which takes care of receiving information through the communication interface and generates the electrical field for the segments. If for alphanumerical LCD 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 pixel by pixel by the user. |
| |
===== Practice ===== | ===== Practice ===== |
| |
Kodulabori komplekti kuulub mõõtudega 84 x 48 pikslit monokromaatiline graafiline LCD ekraan. See ekraan on sama, mida kasutatakse Nokia 3310 mobiiltelefonides. Ekraani küljes on Philipsi PCD8544 kontroller, millega saab suhelda läbi SPI-taolise järjestikliidese. Eraldi juhitav on veel ekraanimooduli taustvalgustus. Ekraaniga suhtlemine pole kuigi keeruline, kuid funktsioonide suure arvu tõttu pole siinkohal seda lahti seletatud. Kodulabori teegis on olemas funktsioonid selle kasutamiseks. | 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. |
| |
Graafilise LCD teegi funktsioonid on sarnased alfabeetilise LCD omadele. Esmalt tuleb ekraan käivitada //lcd_gfx_init//-funktsiooniga. Pärast käivitust on soovitatav ekraan, õigemini kontrolleri mälu, puhastada //lcd_gfx_clear//-funktsiooniga. Teeki on sisse kirjutatud tähekaart kogu ladina tähestiku, numbrite ja üldkasutatavate märkidega. Tähe kõrgus on 7 ja laius 5 pikslit. Iga tähe vahe on horisontaalselt 6 ja vertikaalselt 8 pikslit, ehk kokku mahub ekraanile 6 rida ja 14 tulpa tähti. Tähe või teksti kuvamiseks tuleb eelnevalt //lcd_gfx_goto_char_xy// funktsiooniga määrata selle asukoht. Tähe kuvamiseks on //lcd_gfx_write_char//- ja teksti kuvamiseks //lcd_gfx_write_string//-funktsioon. | 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 start-up it is advised to clean the screen, more precisely controllers memory with the //lcd_gfx_clear// function. There is a letter map in side of the library with full Latin alphabet, numbers and with most common signs written. 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. in total it fits 6 rows and 14 columns of letters. To display a letter or text, first its position must be determined by using function // lcd_gfx_goto_char_xy// . For displaying s letter is // lcd_gfx_write_char// function and for displaying text // lcd_gfx_write_string// function. |
| |
Järgnevalt on toodud näide aja loenduri kohta. Programm loendab sekundeid (ligikaudu), minuteid ja tunde. Aja tekstiks teisendamiseks on kasutusel //sprintf//-funktsioon. | The following is an example of time counter. The program counts seconds (approximately), minutes and hours. For converting time to text //sprintf// function is used. |
| |
<code c> | <code c> |
// | // |
// Kodulabori graafilise LCD kasutamise näide. | // Example of using the graphic LCD of the HomeLab. |
// LCD-le kuvatakse kellaaeg programmi algusest alates. | // Time of day is displayed on LCD since the beginning of the program. |
// | // |
#include <stdio.h> | #include <stdio.h> |
| |
// | // |
// Põhiprogramm | // Main program. |
// | // |
int main(void) | int main(void) |
char text[16]; | char text[16]; |
| |
// LCD ekraani seadistamine | // Set-up of the LCD. |
lcd_gfx_init(); | lcd_gfx_init(); |
| |
// Ekraani puhastamine | // Cleaning the screen. |
lcd_gfx_clear(); | lcd_gfx_clear(); |
| |
// Taustavalgustuse tööle lülitamine | // Switching on the background light. |
lcd_gfx_backlight(true); | lcd_gfx_backlight(true); |
| |
// Programmi nime kuvamine | // Displaying the name of the program. |
lcd_gfx_goto_char_xy(1, 1); | lcd_gfx_goto_char_xy(1, 1); |
lcd_gfx_write_string("Aja loendur"); | lcd_gfx_write_string("Aja loendur"); |
| |
// Lõputu tsükkel | // Endless loop. |
while (true) | while (true) |
{ | { |
// Sekundite teisendamine kellaaja kujule | // Converting the seconds to the form of clock. |
// hh:mm:ss | // hh:mm:ss |
sprintf(text, "%02d:%02d:%02d", | sprintf(text, "%02d:%02d:%02d", |
seconds % 60); | seconds % 60); |
| |
// Kellaaja teksti kuvamine | // Displaying the clock text. |
lcd_gfx_goto_char_xy(3, 3); | lcd_gfx_goto_char_xy(3, 3); |
lcd_gfx_write_string(text); | lcd_gfx_write_string(text); |
| |
// Sekundi suurendamine 1 võrra | // Adding one second. |
seconds++; | seconds++; |
| |
// Riistvaraline paus 1000 millisekundit | // Hardware delay for 1000 ms. |
hw_delay_ms(1000); | hw_delay_ms(1000); |
} | } |
} | } |
</code> | </code> |