Table of Contents

 

LCD screen

Necessary knowledge: [HW] User Interface Module, [LIB] Alphanumeric LCD, [LIB] Graphic LCD,
[LIB] Delay

Theory

The graphical LCD element
The picture formed of pixels of a graphic LCD

LCD screens, which are used with microcontrollers, can be divided mainly into a two parts: a text or alphanumeric LCD and a graphic LCD. Alphanumeric LCD is liquid crystal display, with the purpose of displaying letters and numbers. In basic LCD is used liquid crystal which is placed between transparent electrodes, and which changes the polarization of the passing light in electrical field. The electrodes are covered by polarization filters, which assure that only one way polarized light can pass the screen. If the liquid crystal changes its polarity due to an electrical field, the light can not pass the screen or part (segment) of it and it looks dark.

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 5×7 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. A controller has a preprogrammed card of letters, where each letter, number or symbol has its own index. Displaying the text on the screen is basically done by sending the indexes to the controller. In reality there must be more control orders sent to the controller before anything can be displayed. It is important to get familiarize with each LCD data-sheet, because there are many different types of LCDs and they all are controlled differently.

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. 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.

Practice

In the HomeLab III set is a 128×160 pixels and 1,8 inch full color TFT LCD screen. Sitronixi ST7735 controller is attached to the display which can be communicated through SPI serial interface. The background lighting of the display module is separately controlled, but without the background light, it is not possible to use the screen. 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.

Main difference compared to from HomeLab III to HomeLab II is a 84×48 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.

First, the graphical LCD screen must be started with lcd_gfx_init function. There is a letter map in side of the library with full Latin alphabet, numbers and with most common signs written. 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.

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.

// 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 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);
	}
}
en/examples/display/lcd.txt · Last modified: 2020/07/20 09:00 by 127.0.0.1
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