YALI
Yet Another LCD Interface
Macros | Functions
unilcd.cpp File Reference

YALI (Yet Another LCD Interface) library. More...

#include "unilcd.h"
Include dependency graph for unilcd.cpp:

Macros

#define LINE1_OFFSET   0x80
 
#define LINE2_OFFSET   (LINE1_OFFSET + 0x40)
 
#define LINE3_OFFSET   0x94
 
#define LINE4_OFFSET   (LINE3_OFFSET + 0x40)
 
#define LCD_CONFIG_BACKLIGHT   0x80
 

Functions

VOID writeLCDInterface (UCHAR *data)
 
VOID initLCDInterface (VOID)
 Initialize LCD interface. More...
 
VOID sendLCDInstruction (UCHAR data, UCHAR mode)
 Send instructions or data to the HD44780 controller. More...
 
VOID initLCD (VOID)
 Initialize HD44780 controller. More...
 
VOID printStringLen (const CHAR *str, UCHAR maxLength)
 Print string on LCD. More...
 
VOID gotoLCDPosition (UCHAR x, UCHAR y)
 Move the cursor to the given coordinates. More...
 
VOID setDisplayState (UCHAR onState)
 Control LCD screen. More...
 
VOID setCursorState (UCHAR cursorState)
 Set cursor display mode. More...
 
VOID setCursorBlinkState (UCHAR blinkState)
 Set cursor blinking mode. More...
 
VOID setCustomChar (UCHAR addr, UCHAR *buffer)
 Load custom character to the LCD RAM. More...
 
VOID setBacklightState (UCHAR backLightState)
 Turn on or off the LCD backlight. More...
 

Detailed Description

YALI (Yet Another LCD Interface) library.

Author
Dilshan R Jayakody (jayak.nosp@m.ody2.nosp@m.000lk.nosp@m.@gma.nosp@m.il.co.nosp@m.m)
Version
1.0
Date
2023-03-23

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Function Documentation

◆ gotoLCDPosition()

VOID gotoLCDPosition ( UCHAR  x,
UCHAR  y 
)

Move the cursor to the given coordinates.

Set the current cursor position to the given row and column.

Parameters
xHorizontal (row) position starting from 0.
yVertical (column) position.
Returns
VOID

◆ initLCD()

VOID initLCD ( VOID  )

Initialize HD44780 controller.

Initialize the LCD controller and clear the screen. This function initializes the LCD controller into the following configuration.

  • Disable the blinking cursor.
  • Hide the cursor from the LCD.
  • Turn on the LCD backlight.
Returns
VOID

◆ initLCDInterface()

VOID initLCDInterface ( VOID  )

Initialize LCD interface.

This function initializes the MCU's I/O pins used by the LCD interface. The I/O pins used in this function are defined in the platform configuration header file (e.g: arduino-conf.h).

Returns
VOID

◆ printStringLen()

VOID printStringLen ( const CHAR str,
UCHAR  maxLength 
)

Print string on LCD.

Print the content of the specified string buffer on the LCD screen. This function print contents starting from the current cursor position.

Parameters
strString buffer.
maxLengthLength of the string buffer.
Returns
VOID

◆ sendLCDInstruction()

VOID sendLCDInstruction ( UCHAR  data,
UCHAR  mode 
)

Send instructions or data to the HD44780 controller.

This function sends instructions or data to the HD44780 controller. The transfer type (such as instructions or data) can select using the mode parameter. This function support all WRITE instructions provided by the HD44780 controller.

Parameters
data8-bit data or instruction code.
modeTransfer mode, such as INSTRUCTION_MODE_CMD or INSTRUCTION_MODE_CHAR.
Returns
VOID

◆ setBacklightState()

VOID setBacklightState ( UCHAR  backLightState)

Turn on or off the LCD backlight.

This function can turn on or off (LED) backlight.

Parameters
backLightStateSet 1 to turn on the LCD backlight. Set 0 to turn off the LCD backlight.
Returns
VOID

◆ setCursorBlinkState()

VOID setCursorBlinkState ( UCHAR  blinkState)

Set cursor blinking mode.

This function can switch the cursor between blinking and static modes.

Parameters
blinkStateSet 1 for blinking, or 0 for the static cursor.
Returns
VOID

◆ setCursorState()

VOID setCursorState ( UCHAR  cursorState)

Set cursor display mode.

This function can turn on or off the cursor.

Parameters
cursorStateSet 1 to turn on the cursor. Set 0 to turn off the cursor.
Returns
VOID

◆ setCustomChar()

VOID setCustomChar ( UCHAR  addr,
UCHAR buffer 
)

Load custom character to the LCD RAM.

Load 5×8 custom character to the specified address of the CGRAM.

Make sure to call the clearLCD function after loading all custom characters. Without this function call, the custom characters will not be displayed on the LCD.

To display the custom characters, call the printChar function with the appropriate address.

Parameters
addrRAM address, ranges from 0 to 7.
buffer8-byte long custom character buffer.
Returns
VOID

◆ setDisplayState()

VOID setDisplayState ( UCHAR  onState)

Control LCD screen.

This function can turn on or off the entire LCD screen. When turn off, the display data remains in the DDRAM of the LCD controller.

Parameters
onStateSet 1 to turn on the LCD display. Set 0 to turn off the LCD display.
Returns
VOID