Chapter 8. LCD

The LCD module provides functions to control an LCD display. The module currently supports 20x2 Hitachi HD44780 and 128x64 TIANMA Graphics LCD.

The LCD module has built-in line-wrapping and screen scrolling capability. When printing text, if the text exceeds the right most column, the text is wrapped over to the next line. This is called line-wrapping. When printing text, if the text exceeds the bottom row, of the screen, the screen is scrolled by one line. This is called screen scrolling. The following special characters are also handled by the LCD driver.

Character Handling
\n move cursor to beginning of next line
\r move cursor to beginning of current line
\t insert 4 spaces

The LCD module functions are declared in lcd.h. The no. of rows and columns in the LCD are available as constants LCD_ROWS and LCD_COLS.

The following example displays "Hello World" on the LCD, and displays a number using printf().

Listing 8.1. LCD Hello World

#include <stdio.h>

#include <event.h>
#include <board.h>
#include <lcd.h>

int main()
{
        board_init();
        lcd_init();

        lcd_puts("Hello World!\n");

        board_stdout(LCD_STDOUT);
        printf("%d", 145);

        event_poll();

        return 0;
}