YALI
Yet Another LCD Interface
unilcd.h
Go to the documentation of this file.
1 
30 #ifndef __UNI_LCD_LIB_HEADER__
31 #define __UNI_LCD_LIB_HEADER__
32 
33 #if defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_AVR_UNO) || defined(ARDUINO_SAM_DUE)
34 // Arduino
35 #include "arduino-conf.h"
36 #elif __PICC__
37 // MPLAB XC C for PIC.
38 #include "xc8-pic-conf.h"
39 #elif STM32_LIBOPENCM3
40 // STM32 with LibOpenCM3.
41 #include "stm32-libopencm3-conf.h"
42 #include "stm32_delay.h"
43 #elif ESP8266_FREERTOS
44 // ESP8266 FreeRTOS SDK.
45 #include <unistd.h>
46 #include "driver/gpio.h"
47 #include "esp8266-conf.h"
48 #else
49 #error "Unsupported board or microcontroller."
50 #endif
51 
55 #define LCD_CMD_CLEAR 0x01
59 #define LCD_CMD_HOME 0x02
60 
64 #define LCD_CMD_ENTRY_MODE 0x04
68 #define LCD_CMD_ENTRY_INC_ADDRESS 0x02
72 #define LCD_CMD_ENTRY_SHIFT_LEFT 0x01
73 
77 #define LCD_CMD_DISPLAY 0x08
81 #define LCD_CMD_DISPLAY_ON 0x04
85 #define LCD_CMD_DISPLAY_CUSROR 0x02
89 #define LCD_CMD_DISPLAY_CURSOR_BLINK 0x01
90 
94 #define LCD_CMD_SHIFT 0x10
98 #define LCD_CMD_SHIFT_RIGHT 0x04
102 #define LCD_CMD_SHIFT_DISPLAY 0x08
103 
108 #define LCD_CMD_FUNCTION 0x20
113 #define LCD_CMD_FUNC_8BIT_LENGTH 0x10
117 #define LCD_CMD_FUNC_LINES 0x04
121 #define LCD_CMD_FUNC_FONT 0x08
122 
126 #define LCD_CMD_CG_RAM 0x40
130 #define LCD_CMD_DDRAM 0x80
131 
132 // Instruction modes.
133 
137 #define INSTRUCTION_MODE_CMD 0x00
141 #define INSTRUCTION_MODE_CHAR 0x01
142 
146 #define sendLCDData(d) sendLCDInstruction(d, INSTRUCTION_MODE_CHAR)
150 #define sendLCDCommand(c) sendLCDInstruction(c, INSTRUCTION_MODE_CMD)
151 
153 VOID sendLCDInstruction(UCHAR data, UCHAR mode);
154 
155 VOID initLCD(VOID);
156 VOID printStringLen(const CHAR *str, UCHAR maxLength);
158 VOID setDisplayState(UCHAR onState);
159 VOID setCursorState(UCHAR cursorState);
160 VOID setCursorBlinkState(UCHAR blinkState);
161 VOID setCustomChar(UCHAR addr, UCHAR *buffer);
162 
163 VOID setBacklightState(UCHAR backLightState);
164 
168 #define clearLCD() sendLCDCommand(LCD_CMD_CLEAR)
172 #define returnToHome() sendLCDCommand(LCD_CMD_HOME)
173 
177 #define printChar(c) sendLCDData(c)
181 #define printString(s) printStringLen(s, MAX_STR_LEN)
182 
183 #endif /* __UNI_LCD_LIB_HEADER__ */
Arduino configuration file for YALI module.
#define CHAR
Definition: arduino-conf.h:61
#define VOID
Definition: arduino-conf.h:65
#define UCHAR
Definition: arduino-conf.h:57
ESP8266 RTOS SDK configuration file for YALI module.
STM32 - LibOpenCM3 configuration file for YALI module.
VOID initLCDInterface(VOID)
Initialize LCD interface.
Definition: unilcd.cpp:164
VOID setCustomChar(UCHAR addr, UCHAR *buffer)
Load custom character to the LCD RAM.
Definition: unilcd.cpp:474
VOID gotoLCDPosition(UCHAR x, UCHAR y)
Move the cursor to the given coordinates.
Definition: unilcd.cpp:356
VOID setDisplayState(UCHAR onState)
Control LCD screen.
Definition: unilcd.cpp:384
VOID setBacklightState(UCHAR backLightState)
Turn on or off the LCD backlight.
Definition: unilcd.cpp:497
VOID printStringLen(const CHAR *str, UCHAR maxLength)
Print string on LCD.
Definition: unilcd.cpp:331
VOID sendLCDInstruction(UCHAR data, UCHAR mode)
Send instructions or data to the HD44780 controller.
Definition: unilcd.cpp:238
VOID setCursorBlinkState(UCHAR blinkState)
Set cursor blinking mode.
Definition: unilcd.cpp:439
VOID setCursorState(UCHAR cursorState)
Set cursor display mode.
Definition: unilcd.cpp:412
VOID initLCD(VOID)
Initialize HD44780 controller.
Definition: unilcd.cpp:286
MPLAB XC C (PIC) configuration file for YALI module.