![]() |
Display_Lib_RPI 2.3.0
A C++ Library to connect electronic displays to Linux single board computers.
|
class to drive the HD44780 LCD with PCF8574 I2C interface More...
#include <HD44780_LCD_RDL.hpp>
Public Types | |
enum | LCDBackLight_e : uint8_t { LCDBackLightOnMask = 0x0F , LCDBackLightOffMask = 0x07 } |
enum | LCDEntryMode_e : uint8_t { LCDEntryModeOne = 0x04 , LCDEntryModeTwo = 0x05 , LCDEntryModeThree = 0x06 , LCDEntryModeFour = 0x07 } |
enum | LCDCursorType_e : uint8_t { LCDCursorTypeOff = 0x0C , LCDCursorTypeBlink = 0x0D , LCDCursorTypeOn = 0x0E , LCDCursorTypeOnBlink = 0x0F } |
enum | LCDDirectionType_e : uint8_t { LCDMoveRight = 1 , LCDMoveLeft = 2 } |
enum | LCDLineNumber_e : uint8_t { LCDLineNumberOne = 1 , LCDLineNumberTwo = 2 , LCDLineNumberThree = 3 , LCDLineNumberFour = 4 } |
![]() | |
enum | BaseNum : uint8_t { RDL_DEC = 10 , RDL_HEX = 16 , RDL_OCT = 8 , RDL_BIN = 2 } |
Public Member Functions | |
HD44780PCF8574LCD (uint8_t NumRow, uint8_t NumCol, int I2Cdevice, int I2Caddress, int I2Cflags) | |
Constructor for class HD44780PCF8574LCD. | |
void | LCDInit (LCDCursorType_e) |
Initialise LCD. | |
void | LCDDisplayON (bool) |
Turn Screen on and off. | |
void | LCDResetScreen (LCDCursorType_e) |
Reset screen. | |
void | LCDBackLightSet (bool) |
Turn LED backlight on and off. | |
bool | LCDBackLightGet (void) |
get the backlight flag status | |
rdlib::Return_Codes_e | LCD_I2C_ON (void) |
Switch on the I2C. | |
rdlib::Return_Codes_e | LCD_I2C_OFF (void) |
End I2C operations. | |
int | LCDCheckConnection (void) |
checks if LCD on I2C bus | |
int | LCDI2CErrorGet (void) |
get I2C error Flag | |
uint16_t | LCDI2CErrorTimeoutGet (void) |
Gets the I2C timeout, used in the event of an I2C write error. | |
void | LCDI2CErrorTimeoutSet (uint16_t) |
Sets the I2C timeout, in the event of an I2C write error. | |
uint8_t | LCDI2CErrorRetryNumGet (void) |
Gets the I2C error retry attempts, used in the event of an I2C write error. | |
void | LCDI2CErrorRetryNumSet (uint8_t) |
Sets the I2C error retry attempts used in the event of an I2C write error. | |
rdlib::Return_Codes_e | LCDSendString (char *str) |
Send a string to LCD. | |
void | LCDSendChar (char data) |
Sends a character to screen , simply wraps SendData command. | |
virtual size_t | write (uint8_t) |
Called by print class, used to print out numerical data types etc. | |
rdlib::Return_Codes_e | LCDCreateCustomChar (uint8_t location, uint8_t *charmap) |
Saves a custom character to a location in character generator RAM 64 bytes. | |
void | LCDPrintCustomChar (uint8_t location) |
Print out a customer character from character generator CGRAM 64 bytes 8 characters. | |
void | LCDMoveCursor (LCDDirectionType_e, uint8_t moveSize) |
Moves cursor. | |
void | LCDScroll (LCDDirectionType_e, uint8_t ScrollSize) |
Scrolls screen. | |
void | LCDGOTO (LCDLineNumber_e lineNo, uint8_t col) |
moves cursor to an x , y position on display. | |
void | LCDClearLine (LCDLineNumber_e lineNo) |
Clear a line by writing spaces to every position. | |
rdlib::Return_Codes_e | LCDClearScreen (void) |
Clear screen by writing spaces to every position. | |
void | LCDClearScreenCmd (void) |
Clear display using software command , set cursor position to zero. | |
void | LCDHome (void) |
Set cursor position to home position . | |
void | LCDChangeEntryMode (LCDEntryMode_e mode) |
Change entry mode. | |
![]() | |
int | getWriteError () |
gets the error flag status, zero no error | |
void | clearWriteError () |
clears the error flag by setting it to zero | |
virtual size_t | write (const uint8_t *buffer, size_t size) |
define in the sub class | |
size_t | write (const char *str) |
Writes a string to the output. | |
size_t | write (const char *buffer, size_t size) |
Writes a buffer of a specified size to the output. | |
virtual int | availableForWrite () |
define in the sub class | |
size_t | print (const char[]) |
print an array | |
size_t | print (char) |
print an character | |
size_t | print (int, int=RDL_DEC) |
print an integer of base number system | |
size_t | print (unsigned int, int=RDL_DEC) |
print an unsigned integer of base number system | |
size_t | print (long, int=RDL_DEC) |
print an long integer of base number system | |
size_t | print (unsigned long, int=RDL_DEC) |
print an unsigned long integer of base number system | |
size_t | print (double, int=2) |
print an double | |
size_t | print (const std::string &) |
print an C++ string object | |
size_t | println (const char[]) |
Prints a character array followed by a newline. | |
size_t | println (char) |
print an character followed by new line | |
size_t | println (int, int=RDL_DEC) |
print an integer of base number system followed by new line | |
size_t | println (unsigned int, int=RDL_DEC) |
print an unsigned integer of base number system followed by new line | |
size_t | println (long, int=RDL_DEC) |
print an long integer of base number system followed by new line | |
size_t | println (unsigned long, int=RDL_DEC) |
print an unsigned long integer of base number system followed by new line | |
size_t | println (double, int=2) |
print an double | |
size_t | println (void) |
Goto to new line. | |
size_t | println (const std::string &s) |
print an C++ string object followed by new line | |
template<typename T > | |
size_t | print (const std::vector< T > &v, int format=defaultFormat< T >()) |
Print a vector of any type. | |
template<typename T > | |
size_t | println (const std::vector< T > &vec, int format=defaultFormat< T >()) |
Print a vector of elements followed by a newline. | |
template<typename T , size_t N> | |
size_t | print (const std::array< T, N > &arr, int format=defaultFormat< T >()) |
Print a std::array of any type. | |
template<typename T , size_t N> | |
size_t | println (const std::array< T, N > &arr, int format=defaultFormat< T >()) |
Print a std::array of elements followed by a newline. | |
Private Types | |
enum | LCDAddress_e : uint8_t { LCDLineAddressOne = 0x80 , LCDLineAddressTwo = 0xC0 , LCDLineAddress3Col20 = 0x94 , LCDLineAddress4Col20 = 0xD4 , LCDLineAddress3Col16 = 0x90 , LCDLineAddress4Col16 = 0xD0 } |
enum | LCDCmdBytesGeneral_e : uint8_t { LCDCmdModeFourBit = 0x28 , LCDCmdHomePosition = 0x02 , LCDCmdDisplayOn = 0x0C , LCDCmdDisplayOff = 0x08 , LCDCmdClearScreen = 0x01 } |
Private Member Functions | |
void | LCDSendCmd (unsigned char cmd) |
Send command byte to lcd. | |
void | LCDSendData (unsigned char data) |
Send data byte to LCD via I2C. | |
Private Attributes | |
enum LCDBackLight_e | _LCDBackLight = LCDBackLightOnMask |
int | _LCDI2CAddress = 0x27 |
int | _LCDI2CDevice = 1 |
int | _LCDI2CFlags = 0 |
int | _LCDI2CHandle = 0 |
uint16_t | _I2C_ErrorDelay = 100 |
uint8_t | _I2C_ErrorRetryNum = 3 |
int | _I2C_ErrorFlag = 0 |
uint8_t | _NumRowsLCD = 2 |
uint8_t | _NumColsLCD = 16 |
Additional Inherited Members | |
![]() | |
void | setWriteError (int err=0) |
class to drive the HD44780 LCD with PCF8574 I2C interface
|
private |
DDRAM address's used to set cursor position Note Private
Command Bytes General Note Private
Entry mode control set command, Command Byte Code
HD44780PCF8574LCD::HD44780PCF8574LCD | ( | uint8_t | NumRow, |
uint8_t | NumCol, | ||
int | I2CDevice, | ||
int | I2Caddress, | ||
int | I2CFlags | ||
) |
Constructor for class HD44780PCF8574LCD.
NumRow | number of rows in LCD |
NumCol | number of columns in LCD |
I2CDevice | An I2C device number. |
I2Caddress | The address of a device on the I2C bus. PCF8574 default is 0x27. |
I2CFlags | Flags which modify an I2C open command. None are currently defined. |
rdlib::Return_Codes_e HD44780PCF8574LCD::LCD_I2C_OFF | ( | void | ) |
End I2C operations.
rdlib::Return_Codes_e HD44780PCF8574LCD::LCD_I2C_ON | ( | void | ) |
Switch on the I2C.
get the backlight flag status
Turn LED backlight on and off.
OnOff | passed bool True = LED on , false = display LED off |
void HD44780PCF8574LCD::LCDChangeEntryMode | ( | LCDEntryMode_e | newEntryMode | ) |
Change entry mode.
newEntryMode | 1-4 , 4 choices. |
checks if LCD on I2C bus
void HD44780PCF8574LCD::LCDClearLine | ( | LCDLineNumber_e | lineNo | ) |
Clear a line by writing spaces to every position.
lineNo | LCDLineNumber_e enum lineNo 1-4 |
rdlib::Return_Codes_e HD44780PCF8574LCD::LCDClearScreen | ( | void | ) |
Clear screen by writing spaces to every position.
Clear display using software command , set cursor position to zero.
rdlib::Return_Codes_e HD44780PCF8574LCD::LCDCreateCustomChar | ( | uint8_t | location, |
uint8_t * | charmap | ||
) |
Saves a custom character to a location in character generator RAM 64 bytes.
location | CG_RAM location 0-7, we only have 8 locations 64 bytes |
charmap | An array of 8 bytes representing a custom character data |
Turn Screen on and off.
OnOff | True = display on , false = display off |
void HD44780PCF8574LCD::LCDGOTO | ( | LCDLineNumber_e | line, |
uint8_t | col | ||
) |
moves cursor to an x , y position on display.
line | x row 1-4 |
col | y column 0-15 or 0-19 |
get I2C error Flag
See Error Codes at bottom of https://abyz.me.uk/lg/lgpio.html
Gets the I2C error retry attempts, used in the event of an I2C write error.
Number of times to retry in event of an error
Sets the I2C error retry attempts used in the event of an I2C write error.
Number of times to retry in event of an error
AttemptCount | I2C retry attempts |
Gets the I2C timeout, used in the event of an I2C write error.
Delay between retry attempts in event of an error , mS
Sets the I2C timeout, in the event of an I2C write error.
Delay between retry attempts in event of an error , mS
newTimeout | I2C timeout delay in mS |
void HD44780PCF8574LCD::LCDInit | ( | LCDCursorType_e | CursorType | ) |
Initialise LCD.
CursorType | The cursor type 4 choices. |
void HD44780PCF8574LCD::LCDMoveCursor | ( | LCDDirectionType_e | direction, |
uint8_t | moveSize | ||
) |
Moves cursor.
direction | enum LCDDirectionType_e left or right |
moveSize | number of spaces to move |
Print out a customer character from character generator CGRAM 64 bytes 8 characters.
location | CGRAM 0-7 |
void HD44780PCF8574LCD::LCDResetScreen | ( | LCDCursorType_e | CursorType | ) |
Reset screen.
CursorType | LCDCursorType_e enum cursor type, 4 choices |
void HD44780PCF8574LCD::LCDScroll | ( | LCDDirectionType_e | direction, |
uint8_t | ScrollSize | ||
) |
Scrolls screen.
direction | left or right |
ScrollSize | number of spaces to scroll |
Sends a character to screen , simply wraps SendData command.
data | Character to display |
Send command byte to lcd.
cmd | command byte |
Send data byte to LCD via I2C.
data | The data byte to send |
rdlib::Return_Codes_e HD44780PCF8574LCD::LCDSendString | ( | char * | str | ) |
Send a string to LCD.
str | Pointer to the char array |
Called by print class, used to print out numerical data types etc.
character | write a character |
Implements Print.
|
private |
I2C delay(in between retry attempts) in event of error in mS
|
private |
In event of I2C error holds code
|
private |
In event of I2C error number of retry attempts
|
private |
Enum to store backlight status
|
private |
I2C address for I2C module PCF8574 backpack on LCD
|
private |
An I2C device number.
|
private |
Flags which modify an I2C open command. None are currently defined.
|
private |
A number referencing an object opened by one of lgI2cOpen
|
private |
number of columns on LCD
|
private |
number of rows on LCD