HD44780_LCD_PCF8574  1.3.0
Arduino library for HD44780 LCD
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
HD44780LCD Class Reference

Class for HD44780 LCD
More...

#include <HD44780_LCD_PCF8574.h>

Inheritance diagram for HD44780LCD:
Inheritance graph
[legend]
Collaboration diagram for HD44780LCD:
Collaboration graph
[legend]

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 }
 

Public Member Functions

 HD44780LCD (uint8_t NumRow, uint8_t NumCol, uint8_t I2Caddress, TwoWire *twi)
 Constructor for class TM1638plus. More...
 
void PCF8574_LCDInit (LCDCursorType_e)
 Initialise LCD. More...
 
void PCF8574_LCDDisplayON (bool)
 Turn Screen on and off. More...
 
void PCF8574_LCDResetScreen (LCDCursorType_e)
 Reset screen. More...
 
void PCF8574_LCDBackLightSet (bool)
 Turn LED backlight on and off. More...
 
bool PCF8574_LCDBackLightGet (void)
 get the backlight flag status More...
 
void PCF8574_LCDSendString (char *str)
 Send a string to LCD. More...
 
void PCF8574_LCDSendChar (char data)
 Sends a character to screen , simply wraps SendData command. More...
 
void PCF8574_LCDCreateCustomChar (uint8_t location, uint8_t *charmap)
 Saves a custom character to a location in character generator RAM 64 bytes. More...
 
void PCF8574_LCDPrintCustomChar (uint8_t location)
 Print out a customer character from character generator CGRAM 64 bytes 8 characters. More...
 
void PCF8574_LCDMoveCursor (LCDDirectionType_e, uint8_t moveSize)
 Moves cursor. More...
 
void PCF8574_LCDScroll (LCDDirectionType_e, uint8_t ScrollSize)
 Scrolls screen. More...
 
void PCF8574_LCDGOTO (LCDLineNumber_e lineNo, uint8_t col)
 moves cursor to an x , y position on display. More...
 
void PCF8574_LCDClearLine (LCDLineNumber_e lineNo)
 Clear a line by writing spaces to every position. More...
 
void PCF8574_LCDClearScreen (void)
 Clear screen by writing spaces to every position. More...
 
void PCF8574_LCDClearScreenCmd (void)
 Clear display using software command , set cursor position to zero. More...
 
void PCF8574_LCDHome (void)
 Set cursor position to home position .
 
void PCF8574_LCDChangeEntryMode (LCDEntryMode_e mode)
 Change entry mode
More...
 
virtual void write (uint8_t)
 Called by print class, used to print out numerical data types etc. More...
 

Private Types

enum  LCDAddress_e : uint8_t {
  LCDLineAddressOne = 0x80 , LCDLineAddressTwo = 0xC0 , LCDLineAddress3Col20 = 0x94 , LCDLineAddress4Col20 = 0xD4 ,
  LCDLineAddress3Col16 = 0x90 , LCDLineAddress4Col16 = 0xD0
}
 
enum  LCDCmdBytesGeneral_e : uint8_t {
  LCDModeFourBit = 0x28 , LCDHomePosition = 0x02 , LCDDisplayOn = 0x0C , LCDDisplayOff = 0x08 ,
  LCDClearScreen = 0x01
}
 

Private Member Functions

void PCF8574_LCDSendCmd (unsigned char cmd)
 Send command byte to lcd. More...
 
void PCF8574_LCDSendData (unsigned char data)
 Send data byte to LCD via I2C. More...
 
bool PCF8574_LCD_I2C_ON (void)
 Switch on the I2C. More...
 

Private Attributes

enum LCDBackLight_e _LCDBackLight = LCDBackLightOnMask
 
uint8_t _LCDSlaveAddresI2C = 0x27
 
uint8_t _NumRowsLCD = 2
 
uint8_t _NumColsLCD = 16
 
TwoWire * wire
 

Detailed Description

Class for HD44780 LCD

Member Enumeration Documentation

◆ LCDAddress_e

enum HD44780LCD::LCDAddress_e : uint8_t
private

DDRAM address's used to set cursor position Note Private

Enumerator
LCDLineAddressOne 

Line 1

LCDLineAddressTwo 

Line 2

LCDLineAddress3Col20 

Line 3 20x04 line 3

LCDLineAddress4Col20 

Line 4 20x04 line 4

LCDLineAddress3Col16 

Line 3 16x04 untested, no part

LCDLineAddress4Col16 

Line 4 16x04 untested, no part

◆ LCDBackLight_e

Backlight Control , Command Byte Code

Enumerator
LCDBackLightOnMask 

XXXX-1111 , Turn on Back light

LCDBackLightOffMask 

XXXX-0111, Turn off Back light

◆ LCDCmdBytesGeneral_e

enum HD44780LCD::LCDCmdBytesGeneral_e : uint8_t
private

Command Bytes General Note Private

Enumerator
LCDModeFourBit 

Function set (4-bit interface, 2 lines, 5*7 Pixels)

LCDHomePosition 

Home (move cursor to top/left character position)

LCDDisplayOn 

Restore the display (with cursor hidden)

LCDDisplayOff 

Blank the display (without clearing)

LCDClearScreen 

clear screen

◆ LCDCursorType_e

Cursor mode, Command Byte Code

Enumerator
LCDCursorTypeOff 

Make cursor invisible

LCDCursorTypeBlink 

Turn on blinking-block cursor

LCDCursorTypeOn 

Turn on visible underline cursor

LCDCursorTypeOnBlink 

Turn on blinking-block cursor + visible underline cursor

◆ LCDDirectionType_e

Direction mode for scroll and move

Enumerator
LCDMoveRight 

move or scroll right

LCDMoveLeft 

move or scroll left

◆ LCDEntryMode_e

Entry mode control set command, Command Byte Code

Enumerator
LCDEntryModeOne 

Display Shift :OFF Decrement Address Counter

LCDEntryModeTwo 

Display Shift :ON Decrement Address Counter

LCDEntryModeThree 

Display Shift :OFF Increment Address Counter, default

LCDEntryModeFour 

Display Shift :ON Increment Address Counter

◆ LCDLineNumber_e

Line Row Number

Enumerator
LCDLineNumberOne 

row 1

LCDLineNumberTwo 

row 2

LCDLineNumberThree 

row 3

LCDLineNumberFour 

row 4

Constructor & Destructor Documentation

◆ HD44780LCD()

HD44780LCD::HD44780LCD ( uint8_t  NumRow,
uint8_t  NumCol,
uint8_t  I2Caddress,
TwoWire *  twi 
)

Constructor for class TM1638plus.

Parameters
NumRowNumber of Rows/Lines in the LCD
NumColNumber of Columns in the LCD
I2CaddressThe PCF8574 I2C address, default is 0x27.
twiPointer to the Wire I2C interface.

Member Function Documentation

◆ PCF8574_LCD_I2C_ON()

bool HD44780LCD::PCF8574_LCD_I2C_ON ( void  )
private

Switch on the I2C.

Returns
false if PCF8574 fails to appear on I2C bus , true if ok
Note
if LCD_SERIAL_DEBUG enabled will print I2C error code to screen wire.endTransmission() return: 0 : Success 1 : Data length error 2 : NACK on transmit of the address. 3 : NACK on transmit of the data. 4 : Some other error

◆ PCF8574_LCDBackLightGet()

bool HD44780LCD::PCF8574_LCDBackLightGet ( void  )

get the backlight flag status

Returns
the status of backlight on or off , true or false.

◆ PCF8574_LCDBackLightSet()

void HD44780LCD::PCF8574_LCDBackLightSet ( bool  OnOff)

Turn LED backlight on and off.

Parameters
OnOffpassed bool True = LED on , false = display LED off
Note
another data or command must be issued before it takes effect.

◆ PCF8574_LCDChangeEntryMode()

void HD44780LCD::PCF8574_LCDChangeEntryMode ( LCDEntryMode_e  newEntryMode)

Change entry mode

Parameters
newEntryMode1-4 , 4 choices.

◆ PCF8574_LCDClearLine()

void HD44780LCD::PCF8574_LCDClearLine ( LCDLineNumber_e  lineNo)

Clear a line by writing spaces to every position.

Parameters
lineNoLCDLineNumber_e enum lineNo 1-4

◆ PCF8574_LCDClearScreen()

void HD44780LCD::PCF8574_LCDClearScreen ( void  )

Clear screen by writing spaces to every position.

Note
: See also LCDClearScreenCmd for software command clear alternative.

◆ PCF8574_LCDClearScreenCmd()

void HD44780LCD::PCF8574_LCDClearScreenCmd ( void  )

Clear display using software command , set cursor position to zero.

Note
See also LCDClearScreen for manual clear

◆ PCF8574_LCDCreateCustomChar()

void HD44780LCD::PCF8574_LCDCreateCustomChar ( uint8_t  location,
uint8_t *  charmap 
)

Saves a custom character to a location in character generator RAM 64 bytes.

Parameters
locationCG_RAM location 0-7, we only have 8 locations 64 bytes
charmapAn array of 8 bytes representing a custom character data

◆ PCF8574_LCDDisplayON()

void HD44780LCD::PCF8574_LCDDisplayON ( bool  OnOff)

Turn Screen on and off.

Parameters
OnOffTrue = display on , false = display off

◆ PCF8574_LCDGOTO()

void HD44780LCD::PCF8574_LCDGOTO ( LCDLineNumber_e  line,
uint8_t  col 
)

moves cursor to an x , y position on display.

Parameters
linex row 1-4
coly column 0-15 or 0-19

◆ PCF8574_LCDInit()

void HD44780LCD::PCF8574_LCDInit ( LCDCursorType_e  cursorType)

Initialise LCD.

Parameters
cursorType4 choices.

◆ PCF8574_LCDMoveCursor()

void HD44780LCD::PCF8574_LCDMoveCursor ( LCDDirectionType_e  direction,
uint8_t  moveSize 
)

Moves cursor.

Parameters
directionenum LCDDirectionType_e left or right
moveSizenumber of spaces to move

◆ PCF8574_LCDPrintCustomChar()

void HD44780LCD::PCF8574_LCDPrintCustomChar ( uint8_t  location)

Print out a customer character from character generator CGRAM 64 bytes 8 characters.

Parameters
locationCGRAM 0-7

◆ PCF8574_LCDResetScreen()

void HD44780LCD::PCF8574_LCDResetScreen ( LCDCursorType_e  CursorType)

Reset screen.

Parameters
CursorTypeLCDCursorType_e enum cursor type, 4 choices

◆ PCF8574_LCDScroll()

void HD44780LCD::PCF8574_LCDScroll ( LCDDirectionType_e  direction,
uint8_t  ScrollSize 
)

Scrolls screen.

Parameters
directionleft or right
ScrollSizenumber of spaces to scroll

◆ PCF8574_LCDSendChar()

void HD44780LCD::PCF8574_LCDSendChar ( char  data)

Sends a character to screen , simply wraps SendData command.

Parameters
dataCharacter to display

◆ PCF8574_LCDSendCmd()

void HD44780LCD::PCF8574_LCDSendCmd ( unsigned char  cmd)
private

Send command byte to lcd.

Parameters
cmdcommand byte
Note
if LCD_SERIAL_DEBUG is defined will output data on I2C failures

◆ PCF8574_LCDSendData()

void HD44780LCD::PCF8574_LCDSendData ( unsigned char  data)
private

Send data byte to LCD via I2C.

Parameters
dataThe data byte to send
Note
if LCD_SERIAL_DEBUG is defined , will output data on I2C failures.

◆ PCF8574_LCDSendString()

void HD44780LCD::PCF8574_LCDSendString ( char *  str)

Send a string to LCD.

Parameters
strPointer to the char array

◆ write()

size_t HD44780LCD::write ( uint8_t  character)
virtual

Called by print class, used to print out numerical data types etc.

Parameters
characterwrite a character
Note
used internally. Called by the print method using virtual

Member Data Documentation

◆ _LCDBackLight

enum LCDBackLight_e HD44780LCD::_LCDBackLight = LCDBackLightOnMask
private

Enum to store backlight status

◆ _LCDSlaveAddresI2C

uint8_t HD44780LCD::_LCDSlaveAddresI2C = 0x27
private

I2C address for I2C module PCF8574 backpack on LCD

◆ _NumColsLCD

uint8_t HD44780LCD::_NumColsLCD = 16
private

Number of Cols on LCD

◆ _NumRowsLCD

uint8_t HD44780LCD::_NumRowsLCD = 2
private

Number of rows on LCD

◆ wire

TwoWire* HD44780LCD::wire
private

I2C wire interface


The documentation for this class was generated from the following files: