YALI
Yet Another LCD Interface
|
YALI (Yet Another LCD Interface) library. More...
Go to the source code of this file.
Macros | |
#define | LCD_CMD_CLEAR 0x01 |
#define | LCD_CMD_HOME 0x02 |
#define | LCD_CMD_ENTRY_MODE 0x04 |
#define | LCD_CMD_ENTRY_INC_ADDRESS 0x02 |
#define | LCD_CMD_ENTRY_SHIFT_LEFT 0x01 |
#define | LCD_CMD_DISPLAY 0x08 |
#define | LCD_CMD_DISPLAY_ON 0x04 |
#define | LCD_CMD_DISPLAY_CUSROR 0x02 |
#define | LCD_CMD_DISPLAY_CURSOR_BLINK 0x01 |
#define | LCD_CMD_SHIFT 0x10 |
#define | LCD_CMD_SHIFT_RIGHT 0x04 |
#define | LCD_CMD_SHIFT_DISPLAY 0x08 |
#define | LCD_CMD_FUNCTION 0x20 |
#define | LCD_CMD_FUNC_8BIT_LENGTH 0x10 |
#define | LCD_CMD_FUNC_LINES 0x04 |
#define | LCD_CMD_FUNC_FONT 0x08 |
#define | LCD_CMD_CG_RAM 0x40 |
#define | LCD_CMD_DDRAM 0x80 |
#define | INSTRUCTION_MODE_CMD 0x00 |
#define | INSTRUCTION_MODE_CHAR 0x01 |
#define | sendLCDData(d) sendLCDInstruction(d, INSTRUCTION_MODE_CHAR) |
This macro send data to the HD44780 controller. | |
#define | sendLCDCommand(c) sendLCDInstruction(c, INSTRUCTION_MODE_CMD) |
This macro send instructions (commands) to the HD44780 controller. | |
#define | clearLCD() sendLCDCommand(LCD_CMD_CLEAR) |
Macro to clear LCD display and reset DDRAM address. | |
#define | returnToHome() sendLCDCommand(LCD_CMD_HOME) |
Macro to move cursor to the home location. | |
#define | printChar(c) sendLCDData(c) |
Macro to print a single character on the LCD. | |
#define | printString(s) printStringLen(s, MAX_STR_LEN) |
Macro to print a null terminate string on the LCD. | |
Functions | |
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... | |
YALI (Yet Another LCD Interface) library.
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.
#define INSTRUCTION_MODE_CHAR 0x01 |
Data (character) mode.
#define INSTRUCTION_MODE_CMD 0x00 |
Command (instruction) mode.
#define LCD_CMD_CG_RAM 0x40 |
CGRAM (character pattern buffer) command.
#define LCD_CMD_CLEAR 0x01 |
Clears entire display and reset DDRAM address.
#define LCD_CMD_DDRAM 0x80 |
DDRAM (display data buffer) command.
#define LCD_CMD_DISPLAY 0x08 |
Display and cursor control.
#define LCD_CMD_DISPLAY_CURSOR_BLINK 0x01 |
Enable blinking cursor.
#define LCD_CMD_DISPLAY_CUSROR 0x02 |
Display cursor as 5×8 block.
#define LCD_CMD_DISPLAY_ON 0x04 |
Turn on the entire LCD display.
#define LCD_CMD_ENTRY_INC_ADDRESS 0x02 |
Auto increment the DDRAM address by 1 when a character is written.
#define LCD_CMD_ENTRY_MODE 0x04 |
Set cursor move direction and specifies display shift.
#define LCD_CMD_ENTRY_SHIFT_LEFT 0x01 |
Shift the entire display to the left.
#define LCD_CMD_FUNC_8BIT_LENGTH 0x10 |
Interface data length is 8-bits. (This mode is not supported by YALI module.)
#define LCD_CMD_FUNC_FONT 0x08 |
Set the character font.
#define LCD_CMD_FUNC_LINES 0x04 |
Number of display lines.
#define LCD_CMD_FUNCTION 0x20 |
Function mode to set data length, number of display lines and character font.
#define LCD_CMD_HOME 0x02 |
Return cursor to the home location and shift display to the original position.
#define LCD_CMD_SHIFT 0x10 |
Moves cursor or shifts display.
#define LCD_CMD_SHIFT_DISPLAY 0x08 |
Shift display.
#define LCD_CMD_SHIFT_RIGHT 0x04 |
Shift display to the right.
Move the cursor to the given coordinates.
Set the current cursor position to the given row and column.
x | Horizontal (row) position starting from 0. |
y | Vertical (column) position. |
Initialize HD44780 controller.
Initialize the LCD controller and clear the screen. This function initializes the LCD controller into the following configuration.
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).
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.
str | String buffer. |
maxLength | Length of the string buffer. |
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.
data | 8-bit data or instruction code. |
mode | Transfer mode, such as INSTRUCTION_MODE_CMD or INSTRUCTION_MODE_CHAR . |
Turn on or off the LCD backlight.
This function can turn on or off (LED) backlight.
backLightState | Set 1 to turn on the LCD backlight. Set 0 to turn off the LCD backlight. |
Set cursor blinking mode.
This function can switch the cursor between blinking and static modes.
blinkState | Set 1 for blinking, or 0 for the static cursor. |
Set cursor display mode.
This function can turn on or off the cursor.
cursorState | Set 1 to turn on the cursor. Set 0 to turn off the cursor. |
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.
addr | RAM address, ranges from 0 to 7. |
buffer | 8-byte long custom character buffer. |