Contents
- 1 LCD
- 1.1 LCD_Init
- 1.2 LCD_Clear
- 1.3 LCD_GoToLine
- 1.4 LCD_GoToNextline
- 1.5 LCD_SetCursor
- 1.6 LCD_CmdWrite
- 1.7 LCD_DisplayChar
- 1.8 LCD_DisplayString
- 1.9 LCD_ScrollMessage
- 1.10 LCD_DisplayDecimalNumber
- 1.11 LCD_DisplayHexNumber
- 1.12 LCD_DisplayBinaryNumber
- 1.13 LCD_DisplayFloatNumber
- 1.14 LCD_Printf
- 1.15 Usage Guide
LCD
LCD_Init
Defination | void LCD_Init ( uint8_t v_lcdMode_u8, uint8_t v_lcdNoOfLines_u8, uint8_t v_MaxCharsPerLine_u8) |
Input Arguments | *uint8_t: required Mode 4/8-bit *uint8_t: Number of lines of LCD *uint8_t: Number of Chars per line |
Return Value | none |
Description | This function is used to initialize the lcd. It initializes the LCD for selected mode(4/8-bit) and Type(16x2/16x1 etc) |
Usage |
LCD_Clear
Defination | void LCD_Clear() |
Input Arguments | none. |
Return Value | none. |
Description | This function clears the LCD and moves the cursor to beginning of first line |
Usage |
LCD_GoToLine
Defination | void LCD_GoToLine(uint8_t v_lineNumber_u8) |
Input Arguments | uint8_t: Line number. |
Return Value | none |
Description | This function moves the Cursor to beginning of the specified line. If the requested line number is out of range, it will not move the cursor.
Note: The line numbers run from 1 to Maxlines, To avoid the confusion the below enums has to be used for selecting lines For four line LCD the enums are as below: *E_LcdLineOne, *E_LcdLineTwo, *E_LcdLineThree, *E_LcdLineFour, |
Usage |
LCD_GoToNextline
Defination | void LCD_GoToNextLine() |
Input Arguments | none |
Return Value | none |
Description | This function moves the Cursor to beginning of the next line. If the cursor is on last line and NextLine command is issued then it will move the cursor to first line. |
Usage |
LCD_SetCursor
Defination | void LCD_SetCursor(char v_lineNumber_u8,char v_charNumber_u8) |
Input Arguments | *row: line number(line1=1, line2=2)
For 2line LCD the I/P argument should be either 1 or 2. *col: char number. For 16-char LCD the I/P argument should be between 0-15. |
Return Value | none |
Description | This function moves the Cursor to specified position
*Note:If the Input(Line/Char number) are out of range then no action will be taken |
Usage |
LCD_CmdWrite
Defination | void LCD_CmdWrite( uint8_t v_lcdCmd_u8) |
Input Arguments | 8-bit command supported by LCD. |
Return Value | none |
Description | This function sends a command to LCD. Some of the commonly used commands are defined in lcd.h. For more commands refer the data sheet and send the supported command. The behaviour is undefined if unsupported commands are sent. |
Usage |
LCD_DisplayChar
Defination | void LCD_DisplayChar( char v_lcdData_u8) |
Input Arguments | uint8_t: ASCII value of the char to be displayed. |
Return Value | none |
Description | This function sends a character to be displayed on LCD.
Any valid ascii value can be passed to display the respective character |
Usage |
LCD_DisplayString
Defination | void LCD_DisplayString(char *p_stringPointer_u8) |
Input Arguments | char*:String(Address of the string) to be displayed. |
Return Value | none |
Description | This function is used to display the ASCII string on the lcd. |
Usage |
LCD_ScrollMessage
Defination | void LCD_ScrollMessage(uint8_t v_lineNumber_u8, char *p_msgPointer_u8) |
Input Arguments |
|
Return Value | none |
Description | This function scrolls the given message on the specified line. If the specified line number is out of range then the message will be scrolled on first line |
Usage |
LCD_DisplayDecimalNumber
Defination | void LCD_DisplayNumber(uint32_t v_DecNumber_u32, uint8_t v_numOfDigitsToDisplay_u8 ) |
Input Arguments |
|
Return Value | none |
Description | This function is used to display a max of 10digit decimal number.
2nd parameter specifies the number of digits from the right side to be displayed The output for the input combinations is as below
|
Usage |
LCD_DisplayHexNumber
Defination | void LCD_DisplayHexNumber(uint32_t v_hexNumber_u32, uint8_t v_numOfDigitsToDisplay_u8) |
Input Arguments |
|
Return Value | none |
Description | This function is used to display a max of 10digit hex number.2nd parameter specifies the number of digits from the right side to be displayed .
The output for the input combinations is as below
|
Usage |
LCD_DisplayBinaryNumber
Defination | void LCD_DisplayBinaryNumber(uint32_t v_binNumber_u32, uint8_t v_numOfBitsToDisplay_u8) |
Input Arguments |
|
Return Value | none |
Description | This function is used to display the binary equivalent of the given number.2nd parameter specifies the number of LSB to be displayed .
The output for the input combinations is as below
|
Usage |
LCD_DisplayFloatNumber
Defination | void LCD_DisplayFloatNumber(float v_floatNum_f32) |
Input Arguments | float: Number to be displayed on the LCD. |
Return Value | none |
Description | This function is used to display a floating point number It supports 6digits of precision.
Note: Float will be disabled by default as it takes huge controller resources It can be enabled by changing value of Enable_LCD_DisplayFloatNumber to 1 in lcd.h |
Usage |
LCD_Printf
Defination | void LCD_Printf(const char *argList, ...) |
Input Arguments | variable length arguments similar to printf |
Return Value | none |
Description | This function is similar to printf function in C. It takes the arguments with specified format and prints accordingly .
The supported format specifiers are as below.
|
Usage |
Usage Guide
/* Program to demonstrate the LCD library usage*/ #include"lcd.h" #include"delay.h" int main() { char a_displayMsg_u8[]={"Good Morning"}; char v_lcdData_u8='A'; uint16_t v_number_u16= 1234u; LCD_Init(8,2,16); LCD_ScrollMessage(0," Program to illustrate the lcd library usage "); LCD_Clear(); LCD_DisplayString("Hello, world"); /* Display the specified Message */ LCD_GoToNextLine(); LCD_DisplayString(a_displayMsg_u8); /* Display the message stored in a string */ DELAY_sec(2); LCD_Clear(); LCD_DisplayString("Display Char\n"); LCD_DisplayChar('X'); /* Display the specified Ascii character */ LCD_DisplayChar(v_lcdData_u8); /* Display the char stored in a variable */ DELAY_sec(2); LCD_Clear(); LCD_DisplayString("D:"); LCD_DisplayDecimalNumber(1234,5); /* Display the specified digits of a number */ LCD_DisplayString(" H:"); LCD_DisplayHexNumber(0xABCD,5); /* Note here the num=1234, and digitsToDisplay=5 */ LCD_GoToNextLine(); /* The number displayed on LCD will be as below*/ LCD_DisplayBinaryNumber(0xABCD,16); /* dec=01234, hex=0ABCD, bin=1010101111001101*/ DELAY_sec(2); LCD_Clear(); LCD_Printf("D=%d H=%x \n%b",v_number_u16,v_number_u16,v_number_u16); DELAY_sec(2); LCD_Clear(); LCD_Printf("Enjoy Embedded \nProgramming"); while(1); return 0; }