Generic formats for LCD_Printf function


Interface routines for driving a alphanumeric Liquid Crystal Display module using 8051 micro-controller. LCD is driven by only 4 data lines ( 4-bit mode )
Also shows generic formats for LCD_Printf function.

Toolkit:SDCC 8051 Development System

Location:/bipom/devtools/SDCC/examples/lcd/printf

Code Example


#include <stdio.h>
#include <stdarg.h>
#include <8052.h>
#include <mcs51\bipomlib\types.h>
#include <mcs51\bipomlib\bipomlib.h>
#include <mcs51\bipomlib\lcd.h>

void main()
{
   	// Initialize the serial port 

   	serinit(CBR_19200);
    
	puts( "\rSDCC LCD PRINTF Example" );
	
	// Initialize the LCD 

	LCD_Init();

	// -----------------------------------------

	LCD_Clear();
	LCD_SetTopLine();
	LCD_Write("TEXT FORMAT");
	
	LCD_SetBottomLine();
	LCD_Printf("%s and %s", "PART1", "PART2");

	delay(5000);
	
	// -----------------------------------------

	LCD_Clear();
	LCD_SetTopLine();
	LCD_Write("CHARACTER FORMAT");
	
	LCD_SetBottomLine();
	LCD_Printf("Char1: '%c', Char2: '%c'", 'A', 'Z');

	delay(5000);

	// -----------------------------------------

	LCD_Clear();
	LCD_SetTopLine();
	LCD_Write("INTEGER FORMAT");
	
	LCD_SetBottomLine();
	LCD_Printf("Num1: %d, Num2: %d", 100, -200);

	delay(5000);
	
	// -----------------------------------------

	LCD_Clear();
	LCD_SetTopLine();
	LCD_Write("FLOAT FORMAT #1");
	
	LCD_SetBottomLine();
	LCD_Printf("Number1: %f", 10.5);

	delay(5000);

	// -----------------------------------------

	LCD_Clear();
	LCD_SetTopLine();
	LCD_Write("FLOAT FORMAT #2");
	
	LCD_SetBottomLine();
	LCD_Printf("Number1: %.3f", 1.23456789);

	delay(5000);
	
	puts( "\rDone" );
	while(1);
}