Line 5: Line 5:
  
 
==LCD_Init==   
 
==LCD_Init==   
{| class="wikitable"  style="colspan:1; background-color:#4682B4;"
+
{|{{Widget:LibCol}}
 
{{#Widget:LibTable}}
 
{{#Widget:LibTable}}
 
|-
 
|-
|Defination ||<syntaxhighlight> void LCD_Init(uint8_t lcdMode, uint8_t lcdtype)</syntaxhighlight>
+
|Defination ||void LCD_Init(uint8_t v_lcdMode_u8, uint8_t v_lcdNoOfLines_u8, uint8_t v_MaxCharsPerLine_u8)
 
|-
 
|-
| Input Arguments || <syntaxhighlight>uint8_t: required Mode 4/8-bit. uint8_t: Type of LCD used (16x2/16x1 etc)</syntaxhighlight>
+
| 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
 
| Return Value|| none
Line 19: Line 19:
 
|}
 
|}
  
==LCD_CmdWrite==
+
 
{| class="wikitable"  style="colspan:1; background-color:#4682B4;"
+
 
 +
 
 +
==LCD_Clear==            
 +
{|{{Widget:LibCol}}
 
{{#Widget:LibTable}}
 
{{#Widget:LibTable}}
 
|-
 
|-
|Defination || '''void LCD_CmdWrite( uint8_t cmd)'''
+
|Defination || void LCD_Clear()
 
|-
 
|-
| Input Arguments || 8-bit command supported by LCD.
+
| Input Arguments || none.
 
|-
 
|-
| Return Value|| none
+
| 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.   
+
| Description ||This function clears the LCD and moves the cursor to beginning of first line
 
|-
 
|-
| Usage ||  
+
| Usage ||    
 
|}
 
|}
  
==LCD_DataWrite==
+
 
{| class="wikitable"  style="colspan:1; background-color:#4682B4;"
+
 
 +
 
 +
 
 +
==LCD_GoToLine==      
 +
{|{{Widget:LibCol}}
 
{{#Widget:LibTable}}
 
{{#Widget:LibTable}}
 
|-
 
|-
|Defination || '''static void lcd_DataWrite( uint8_t dat)'''
+
|Defination || void LCD_GoToLine(uint8_t v_lineNumber_u8)
 
|-
 
|-
| Input Arguments || uint8_t: 8-bit value to be sent to LCD.
+
| Input Arguments || uint8_t: Line number.
 
|-
 
|-
 
| Return Value|| none
 
| Return Value|| none
 
|-
 
|-
| Description ||This functions is used to send a byte of data to LCD.
+
| 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 ||  
+
| Usage ||    
 
|}
 
|}
  
==LCD_Clear==            
+
 
{| class="wikitable"  style="colspan:1; background-color:#4682B4;"
+
 
 +
 
 +
==LCD_GoToNextline==
 +
{|{{Widget:LibCol}}
 
{{#Widget:LibTable}}
 
{{#Widget:LibTable}}
 
|-
 
|-
|Defination || '''void LCD_Clear()'''
+
|Defination || void LCD_GoToNextLine()
 
|-
 
|-
| Input Arguments || none.
+
| Input Arguments || none
 
|-
 
|-
| Return Value|| none.
+
| Return Value|| none
 
|-
 
|-
| Description ||This function clears the LCD and moves the cursor to beginning of first line
+
| 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 ||    
+
| Usage ||  
 
|}
 
|}
  
==LCD_GoToLine==      
+
 
{| class="wikitable"  style="colspan:1; background-color:#4682B4;"
+
 
 +
 
 +
 
 +
==LCD_SetCursor==
 +
{|{{Widget:LibCol}}
 
{{#Widget:LibTable}}
 
{{#Widget:LibTable}}
 
|-
 
|-
|Defination || '''void LCD_GoToLine(uint8_t LineNumber)'''
+
|Defination || void LCD_SetCursor(char v_lineNumber_u8,char v_charNumber_u8)
 
|-
 
|-
| Input Arguments || uint8_t: Line number.
+
| 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
 
| 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.
+
| 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 ||    
+
| Usage ||  
 
|}
 
|}
  
==LCD_GoToNextline==
+
 
{| class="wikitable"  style="colspan:1; background-color:#4682B4;"
+
 
 +
 
 +
 
 +
==LCD_CmdWrite==
 +
{|{{Widget:LibCol}}
 
{{#Widget:LibTable}}
 
{{#Widget:LibTable}}
 
|-
 
|-
|Defination || '''void LCD_GoToNextLine()'''
+
|Defination || void LCD_CmdWrite( uint8_t v_lcdCmd_u8)
 
|-
 
|-
| Input Arguments || none
+
| Input Arguments || 8-bit command supported by LCD.
 
|-
 
|-
 
| Return Value|| 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.
+
| 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 ||   
 
| Usage ||   
 
|}
 
|}
 +
 +
 +
 +
 +
==LCD_DisplayChar==
 +
{|{{Widget:LibCol}}
 +
{{#Widget:LibTable}}
 +
|-
 +
|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==
 
==LCD_DisplayString==
{| class="wikitable"  style="colspan:1; background-color:#4682B4;"
+
{|{{Widget:LibCol}}
 
{{#Widget:LibTable}}
 
{{#Widget:LibTable}}
 
|-
 
|-
|Defination || '''void LCD_DisplayString(char *string_ptr)'''
+
|Defination || void LCD_DisplayString(char *p_stringPointer_u8)
 
|-
 
|-
| Input Arguments || String(Address of the string) to be displayed.
+
| Input Arguments || char*:String(Address of the string) to be displayed.
 
|-
 
|-
 
| Return Value|| none
 
| Return Value|| none
 
|-
 
|-
 
| Description ||This function is used to display the ASCII string on the lcd.
 
| Description ||This function is used to display the ASCII string on the lcd.
* The string_ptr points to the first char of the string  and traverses till the end(NULL CHAR)and displays a char each time.
 
 
|-
 
|-
 
| Usage ||     
 
| Usage ||     
 
|}
 
|}
 +
 +
 +
 +
  
 
==LCD_ScrollMessage==
 
==LCD_ScrollMessage==
{| class="wikitable"  style="colspan:1; background-color:#4682B4;"
+
{|{{Widget:LibCol}}
 
{{#Widget:LibTable}}
 
{{#Widget:LibTable}}
 
|-
 
|-
|Defination || '''void LCD_ScrollMessage(uint8_t linenumber, char *msg_ptr)'''
+
|Defination || void LCD_ScrollMessage(uint8_t v_lineNumber_u8, char *p_msgPointer_u8)
 
|-
 
|-
 
| Input Arguments ||
 
| Input Arguments ||
*'''uint8_t'''  : Line number on which the message has to be scrolled
+
*uint8_t: Line number on which the message has to be scrolled
* '''char *''': pointer to the string to be scrolled
+
*char *: pointer to the string to be scrolled
 
|-
 
|-
 
| Return Value|| none
 
| Return Value|| none
Line 126: Line 181:
 
| Usage ||     
 
| Usage ||     
 
|}
 
|}
 +
 +
 +
  
 
==LCD_DisplayDecimalNumber==
 
==LCD_DisplayDecimalNumber==
{| class="wikitable"  style="colspan:1; background-color:#4682B4;"
+
{|{{Widget:LibCol}}
 
{{#Widget:LibTable}}
 
{{#Widget:LibTable}}
 
|-
 
|-
|Defination || '''void  LCD_DisplayNumber(uint32_t num, uint8_t NumOfDigits )'''
+
|Defination || void  LCD_DisplayNumber(uint32_t v_DecNumber_u32, uint8_t v_numOfDigitsToDisplay_u8 )
 
|-
 
|-
 
| Input Arguments ||  
 
| Input Arguments ||  
* '''uint32_t''': Number to be displayed on the LCD.
+
*uint32_t: Number to be displayed on the LCD.
*'''uint8_t''' : Number of digits to be displayed
+
*uint8_t : Number of digits to be displayed
 
|-
 
|-
 
| Return Value|| none
 
| Return Value|| none
Line 144: Line 202:
 
*(12345,4) then 4-digits ie. 2345 will be displayed
 
*(12345,4) then 4-digits ie. 2345 will be displayed
 
*(12345,6) then 6-digits ie. 012345 will be displayed
 
*(12345,6) then 6-digits ie. 012345 will be displayed
*(12345,C_DefaultDigits) then 12345 will be displayed.
+
*(12345,C_DisplayDefaultDigits_U8) then 12345 will be displayed.
 
|-
 
|-
 
| Usage ||     
 
| Usage ||     
 
|}
 
|}
  
'''==LCD_DisplayHexNumber==
+
 
{| class="wikitable"  style="colspan:1; background-color:#4682B4;"
+
 
 +
 
 +
==LCD_DisplayHexNumber==
 +
{|{{Widget:LibCol}}
 
{{#Widget:LibTable}}
 
{{#Widget:LibTable}}
 
|-
 
|-
|Defination || '''void  LCD_DisplayHexNumber(uint32_t num, uint8_t NumOfDigits )'''
+
|Defination ||void  LCD_DisplayHexNumber(uint32_t v_hexNumber_u32, uint8_t v_numOfDigitsToDisplay_u8)
 
|-
 
|-
 
| Input Arguments ||  
 
| Input Arguments ||  
*'''uint32_t''': Hexadecimal Number to be displayed on the LCD.
+
*uint32_t: Hexadecimal Number to be displayed on the LCD.
*'''uint8_t''' : Number of digits to be displayed
+
*uint8_t : Number of digits to be displayed
 
|-
 
|-
 
| Return Value|| none
 
| Return Value|| none
Line 165: Line 226:
 
*(0x12AB,3) then 3-digits ie. 2AB will be displayed
 
*(0x12AB,3) then 3-digits ie. 2AB will be displayed
 
*(0x12AB,6) then 6-digits ie. 0012AB will be displayed
 
*(0x12AB,6) then 6-digits ie. 0012AB will be displayed
*(0x12AB,C_DefaultDigits) then 12AB will be displayed.
+
*(0x12AB,C_DisplayDefaultDigits_U8) then 12AB will be displayed.
 
|-
 
|-
 
| Usage ||     
 
| Usage ||     
 
|}
 
|}
 +
 +
 +
  
 
==LCD_DisplayBinaryNumber==
 
==LCD_DisplayBinaryNumber==
{| class="wikitable"  style="colspan:1; background-color:#4682B4;"
+
{|{{Widget:LibCol}}
 
{{#Widget:LibTable}}
 
{{#Widget:LibTable}}
 
|-
 
|-
|Defination || '''void  LCD_DisplayBinaryNumber(uint32_t num, uint8_t NumOfBits )'''
+
|Defination || void  LCD_DisplayBinaryNumber(uint32_t v_binNumber_u32, uint8_t v_numOfBitsToDisplay_u8)
 
|-
 
|-
 
| Input Arguments ||  
 
| Input Arguments ||  
*'''uint32_t''': Hexadecimal Number to be displayed on the LCD.
+
*uint32_t: Hexadecimal Number to be displayed on the LCD.
*'''uint8_t''': Number of bits to be displayed
+
*uint8_t: Number of bits to be displayed
 
|-
 
|-
 
| Return Value|| none
 
| Return Value|| none
Line 186: Line 250:
 
The output for the input combinations is as below
 
The output for the input combinations is as below
 
*(10,4) then 4-LSB will be displayed ie. 1010
 
*(10,4) then 4-LSB will be displayed ie. 1010
* (10,8) then 8-LSB will be displayed ie. 00001010
+
*(10,8) then 8-LSB will be displayed ie. 00001010
 
*(10,2) then 2-LSB will be displayed ie. 10
 
*(10,2) then 2-LSB will be displayed ie. 10
 
|-
 
|-
 
| Usage ||     
 
| Usage ||     
 
|}
 
|}
 +
 +
 +
  
 
==LCD_DisplayFloatNumber==  
 
==LCD_DisplayFloatNumber==  
{| class="wikitable"  style="colspan:1; background-color:#4682B4;"
+
{|{{Widget:LibCol}}
 
{{#Widget:LibTable}}
 
{{#Widget:LibTable}}
 
|-
 
|-
|Defination || '''void  LCD_DisplayFloatNumber(float num)'''
+
|Defination || void  LCD_DisplayFloatNumber(float v_floatNum_f32)
 
|-
 
|-
| Input Arguments || '''float Number''' to be displayed on the LCD.
+
| Input Arguments || float: Number to be displayed on the LCD.
 
|-
 
|-
 
| Return Value|| none
 
| Return Value|| none
Line 208: Line 275:
 
| Usage ||     
 
| Usage ||     
 
|}
 
|}
 +
 +
 +
  
 
==LCD_Printf==
 
==LCD_Printf==
{| class="wikitable"  style="colspan:1; background-color:#4682B4;"
+
{|{{Widget:LibCol}}
 
{{#Widget:LibTable}}
 
{{#Widget:LibTable}}
 
|-
 
|-
Line 223: Line 293:
 
*%c: character
 
*%c: character
  
*%d: decimal
+
*%d: decimal(16bit)
  
*%b: binary
+
*%l: decimal(32-bit)
 +
 
 +
*%b: binary(16-bit)
  
 
*%s: string
 
*%s: string
Line 236: Line 308:
 
| Usage ||     
 
| Usage ||     
 
|}
 
|}
 +
 +
  
  

Revision as of 12:51, 28 December 2014

LCD

LCD_Init

{{#Widget:LibTable}}
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

{{#Widget:LibTable}}
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

{{#Widget:LibTable}}
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

{{#Widget:LibTable}}
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

{{#Widget:LibTable}}
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

{{#Widget:LibTable}}
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

{{#Widget:LibTable}}
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

{{#Widget:LibTable}}
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

{{#Widget:LibTable}}
Defination void LCD_ScrollMessage(uint8_t v_lineNumber_u8, char *p_msgPointer_u8)
Input Arguments
  • uint8_t: Line number on which the message has to be scrolled
  • char *: pointer to the string to be scrolled
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

{{#Widget:LibTable}}
Defination void LCD_DisplayNumber(uint32_t v_DecNumber_u32, uint8_t v_numOfDigitsToDisplay_u8 )
Input Arguments
  • uint32_t: Number to be displayed on the LCD.
  • uint8_t : Number of digits to be displayed
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

  • (12345,4) then 4-digits ie. 2345 will be displayed
  • (12345,6) then 6-digits ie. 012345 will be displayed
  • (12345,C_DisplayDefaultDigits_U8) then 12345 will be displayed.
Usage



LCD_DisplayHexNumber

{{#Widget:LibTable}}
Defination void LCD_DisplayHexNumber(uint32_t v_hexNumber_u32, uint8_t v_numOfDigitsToDisplay_u8)
Input Arguments
  • uint32_t: Hexadecimal Number to be displayed on the LCD.
  • uint8_t : Number of digits to be displayed
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

  • (0x12AB,3) then 3-digits ie. 2AB will be displayed
  • (0x12AB,6) then 6-digits ie. 0012AB will be displayed
  • (0x12AB,C_DisplayDefaultDigits_U8) then 12AB will be displayed.
Usage



LCD_DisplayBinaryNumber

{{#Widget:LibTable}}
Defination void LCD_DisplayBinaryNumber(uint32_t v_binNumber_u32, uint8_t v_numOfBitsToDisplay_u8)
Input Arguments
  • uint32_t: Hexadecimal Number to be displayed on the LCD.
  • uint8_t: Number of bits to be displayed
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

  • (10,4) then 4-LSB will be displayed ie. 1010
  • (10,8) then 8-LSB will be displayed ie. 00001010
  • (10,2) then 2-LSB will be displayed ie. 10
Usage



LCD_DisplayFloatNumber

{{#Widget:LibTable}}
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

{{#Widget:LibTable}}
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.

  • %c: character
  • %d: decimal(16bit)
  • %l: decimal(32-bit)
  • %b: binary(16-bit)
  • %s: string
  • %f: float
  • %x: hexadecimal
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;
  }