This is an old revision of the document!


Table of Contents

Graphic LCD

Necessary knowledge: [HW] lcd, [LIB] Graphic LCD, [LIB] Delay, [PRT] Alphanumeric LCD

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.

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.

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.

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.

Järgnevalt on toodud näide aja loenduri kohta. Programm loendab sekundeid (ligikaudu), minuteid ja tunde. Aja tekstiks teisendamiseks on kasutusel sprintf-funktsioon.

//
// Kodulabori graafilise LCD kasutamise näide.
// LCD-le kuvatakse kellaaeg programmi algusest alates.
//
#include <stdio.h>
#include <homelab/module/lcd_gfx.h>
#include <homelab/delay.h>
 
//
// Põhiprogramm
//
int main(void)
{
	int seconds = 0;
	char text[16];
 
	// LCD ekraani seadistamine
	lcd_gfx_init();
 
	// Ekraani puhastamine
	lcd_gfx_clear();
 
	// Taustavalgustuse tööle lülitamine
	lcd_gfx_backlight(true);	
 
	// Programmi nime kuvamine
	lcd_gfx_goto_char_xy(1, 1);
	lcd_gfx_write_string("Aja loendur");
 
	// Lõputu tsükkel	
	while (true)
	{
		// Sekundite teisendamine kellaaja kujule
		// hh:mm:ss
		sprintf(text, "%02d:%02d:%02d",
			(seconds / 3600) % 24,
			(seconds / 60) % 60,
			 seconds % 60);
 
		// Kellaaja teksti kuvamine
		lcd_gfx_goto_char_xy(3, 3);
		lcd_gfx_write_string(text);
 
		// Sekundi suurendamine 1 võrra
		seconds++;
 
		// Riistvaraline paus 1000 millisekundit
		hw_delay_ms(1000);
	}
}
en/examples/display/lcd_graphic.1267798693.txt.gz · Last modified: 2020/07/20 09:00 (external edit)
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