/* ---------------------------------------------------------------------------* AVR_MLIB - HD 44780 LCD Display Driver Test Application* www.mlab.cz miho 2008* ---------------------------------------------------------------------------* Simple test application for lcd_hd44780.h LCD library. This code ilustates* how to use and configure the library functions.* ---------------------------------------------------------------------------* 00.00 2008/03/28 First Version* 00.01 2008/04/19 Improved* ---------------------------------------------------------------------------*/// Required Libraries// ------------------// Delay#define F_CPU 1000000UL // CPU Frequency#include <util/delay.h> // Delay Routines// Standard Output Library#include <stdio.h> // For printf// LCD Display Interface// ---------------------// LCD Port Settings#define LCD_DATA B // 4 or 8 bits field (lsb port)#define LCD_DATA_BIT 4#define LCD_RS D // Register Select#define LCD_RS_BIT 4#define LCD_E D // Enable#define LCD_E_BIT 3// LCD Display Parameters#define LCD_INTERFACE_BITS 4 // 4 or 8 bit interface#define LCD_LINES 2 // 1 or 2 or 4 lines#define LCD_CHARS 20 // usualy 16 or 20, important for 4 line display only// LCD Library#include "lcd_hd44780.h"// Test Application// ----------------// Define Output Stream to LCDstatic FILE lcd_stream = FDEV_SETUP_STREAM(lcd_putc_stream, NULL, _FDEV_SETUP_WRITE);// Main Programint main (){int i;stdout = &lcd_stream; // Connect stdout to LCD Streamlcd_init(); // Init LCD (interface and display module)// Print Linesfor (i=1; i<=LCD_LINES;i++){lcd_gotoxy(1,i);printf("Line %d", i);_delay_ms(1000);}// Show User Defined Symbolsprintf("\v" "\x10" LCD_CHAR_SPACE LCD_CHAR_SPACE "\v"); // You shold know that dispalyprintf("\fBat Status \x10 \x11"); // does clear user defined chars_delay_ms(1000); // on Power Up onlyprintf("\v" "\x11" LCD_CHAR_UP "\v");printf("\v" "\x10" LCD_CHAR_BAT100 "\v");_delay_ms(1000);printf("\v" "\x10" LCD_CHAR_BAT50 "\v");_delay_ms(1000);printf("\v" "\x10" LCD_CHAR_BAT0 "\v");_delay_ms(1000);// Show Cursorlcd_cursor_on();_delay_ms(1000);lcd_cursor_right();_delay_ms(1000);lcd_cursor_left();_delay_ms(1000);lcd_cursor_left();_delay_ms(1000);// Print to the Next Lineprintf("\n Hello World");_delay_ms(1000);// Count Downfor(i=20;i>0;i--){printf("\r%2d", i);_delay_ms(1000);}// Endlcd_cursor_off();printf("\b\b X");}