HD44780_LCD_PCF8574  1.3.0
Arduino library for HD44780 LCD
HD44780_LCD_PCF8574.h
Go to the documentation of this file.
1 
9 #if ARDUINO >= 100
10  #include "Arduino.h"
11  #include "Print.h"
12 #else
13  #include "WProgram.h"
14 #endif
15 
16 #include "Wire.h"
17 
18 #ifndef LCD_HD44780_H
19 #define LCD_HD44780_H
20 
21 //#define LCD_SERIAL_DEBUG // Comment in for serial debug I2C errors, set baud rate externally.
22 
26 class HD44780LCD : public Print{
27 public:
28 
29  // public enums
30 
32  enum LCDBackLight_e : uint8_t{
34  LCDBackLightOffMask = 0x07
35  };
36 
38  enum LCDEntryMode_e : uint8_t{
39  LCDEntryModeOne = 0x04,
40  LCDEntryModeTwo = 0x05,
42  LCDEntryModeFour = 0x07
43  };
44 
46  enum LCDCursorType_e : uint8_t {
49  LCDCursorTypeOn = 0x0E,
50  LCDCursorTypeOnBlink = 0x0F
51  };
52 
54  enum LCDDirectionType_e : uint8_t {
56  LCDMoveLeft = 2
57  };
58 
60  enum LCDLineNumber_e : uint8_t{
65  };
66 
67 
68  // Constructor's
69  HD44780LCD(uint8_t NumRow, uint8_t NumCol, uint8_t I2Caddress,TwoWire *twi );
70  ~HD44780LCD(){};
71 
72  // public methods
74  void PCF8574_LCDDisplayON(bool );
76 
77  void PCF8574_LCDBackLightSet(bool);
78  bool PCF8574_LCDBackLightGet(void);
79 
80  void PCF8574_LCDSendString (char *str);
81  void PCF8574_LCDSendChar (char data);
82  void PCF8574_LCDCreateCustomChar(uint8_t location, uint8_t* charmap);
83  void PCF8574_LCDPrintCustomChar(uint8_t location);
84 
85  void PCF8574_LCDMoveCursor(LCDDirectionType_e, uint8_t moveSize);
86  void PCF8574_LCDScroll(LCDDirectionType_e, uint8_t ScrollSize);
87  void PCF8574_LCDGOTO(LCDLineNumber_e lineNo, uint8_t col);
89  void PCF8574_LCDClearScreen(void);
90  void PCF8574_LCDClearScreenCmd(void);
91  void PCF8574_LCDHome(void);
93 
94 #if ARDUINO >= 100
95  virtual size_t write(uint8_t);
96 #else
97  virtual void write(uint8_t);
98 #endif
99 
100 private:
101 
102  // Private internal enums
103 
105  enum LCDAddress_e : uint8_t {
111  LCDLineAddress4Col16 = 0xD0
112  };
113 
115  enum LCDCmdBytesGeneral_e : uint8_t {
116  LCDModeFourBit = 0x28,
118  LCDDisplayOn = 0x0C,
119  LCDDisplayOff = 0x08,
120  LCDClearScreen = 0x01
121  };
122 
123 
126  // Private Data
127  uint8_t _LCDSlaveAddresI2C = 0x27 ;
128  uint8_t _NumRowsLCD = 2;
129  uint8_t _NumColsLCD = 16;
130  TwoWire *wire;
132  // private methods
133  void PCF8574_LCDSendCmd (unsigned char cmd);
134  void PCF8574_LCDSendData (unsigned char data);
135  bool PCF8574_LCD_I2C_ON(void);
136 
137 }; // end of HD44780LCD class
138 
139 #endif // guard header ending
Class for HD44780 LCD
Definition: HD44780_LCD_PCF8574.h:26
HD44780LCD(uint8_t NumRow, uint8_t NumCol, uint8_t I2Caddress, TwoWire *twi)
Constructor for class TM1638plus.
Definition: HD44780_LCD_PCF8574.cpp:17
void PCF8574_LCDClearScreen(void)
Clear screen by writing spaces to every position.
Definition: HD44780_LCD_PCF8574.cpp:136
void PCF8574_LCDCreateCustomChar(uint8_t location, uint8_t *charmap)
Saves a custom character to a location in character generator RAM 64 bytes.
Definition: HD44780_LCD_PCF8574.cpp:297
bool PCF8574_LCDBackLightGet(void)
get the backlight flag status
Definition: HD44780_LCD_PCF8574.cpp:323
void PCF8574_LCDPrintCustomChar(uint8_t location)
Print out a customer character from character generator CGRAM 64 bytes 8 characters.
Definition: HD44780_LCD_PCF8574.cpp:371
LCDEntryMode_e
Definition: HD44780_LCD_PCF8574.h:38
@ LCDEntryModeOne
Definition: HD44780_LCD_PCF8574.h:39
@ LCDEntryModeFour
Definition: HD44780_LCD_PCF8574.h:42
@ LCDEntryModeTwo
Definition: HD44780_LCD_PCF8574.h:40
@ LCDEntryModeThree
Definition: HD44780_LCD_PCF8574.h:41
void PCF8574_LCDHome(void)
Set cursor position to home position .
Definition: HD44780_LCD_PCF8574.cpp:401
void PCF8574_LCDSendData(unsigned char data)
Send data byte to LCD via I2C.
Definition: HD44780_LCD_PCF8574.cpp:32
LCDAddress_e
Definition: HD44780_LCD_PCF8574.h:105
@ LCDLineAddress3Col20
Definition: HD44780_LCD_PCF8574.h:108
@ LCDLineAddressOne
Definition: HD44780_LCD_PCF8574.h:106
@ LCDLineAddressTwo
Definition: HD44780_LCD_PCF8574.h:107
@ LCDLineAddress4Col20
Definition: HD44780_LCD_PCF8574.h:109
@ LCDLineAddress3Col16
Definition: HD44780_LCD_PCF8574.h:110
@ LCDLineAddress4Col16
Definition: HD44780_LCD_PCF8574.h:111
void PCF8574_LCDDisplayON(bool)
Turn Screen on and off.
Definition: HD44780_LCD_PCF8574.cpp:166
virtual void write(uint8_t)
Called by print class, used to print out numerical data types etc.
Definition: HD44780_LCD_PCF8574.cpp:382
LCDCursorType_e
Definition: HD44780_LCD_PCF8574.h:46
@ LCDCursorTypeOff
Definition: HD44780_LCD_PCF8574.h:47
@ LCDCursorTypeOn
Definition: HD44780_LCD_PCF8574.h:49
@ LCDCursorTypeOnBlink
Definition: HD44780_LCD_PCF8574.h:50
@ LCDCursorTypeBlink
Definition: HD44780_LCD_PCF8574.h:48
void PCF8574_LCDInit(LCDCursorType_e)
Initialise LCD.
Definition: HD44780_LCD_PCF8574.cpp:176
enum LCDBackLight_e _LCDBackLight
Definition: HD44780_LCD_PCF8574.h:124
void PCF8574_LCDChangeEntryMode(LCDEntryMode_e mode)
Change entry mode
Definition: HD44780_LCD_PCF8574.cpp:410
uint8_t _NumRowsLCD
Definition: HD44780_LCD_PCF8574.h:128
void PCF8574_LCDResetScreen(LCDCursorType_e)
Reset screen.
Definition: HD44780_LCD_PCF8574.cpp:153
uint8_t _NumColsLCD
Definition: HD44780_LCD_PCF8574.h:129
void PCF8574_LCDSendChar(char data)
Sends a character to screen , simply wraps SendData command.
Definition: HD44780_LCD_PCF8574.cpp:211
void PCF8574_LCDSendString(char *str)
Send a string to LCD.
Definition: HD44780_LCD_PCF8574.cpp:203
LCDLineNumber_e
Definition: HD44780_LCD_PCF8574.h:60
@ LCDLineNumberOne
Definition: HD44780_LCD_PCF8574.h:61
@ LCDLineNumberFour
Definition: HD44780_LCD_PCF8574.h:64
@ LCDLineNumberTwo
Definition: HD44780_LCD_PCF8574.h:62
@ LCDLineNumberThree
Definition: HD44780_LCD_PCF8574.h:63
void PCF8574_LCDScroll(LCDDirectionType_e, uint8_t ScrollSize)
Scrolls screen.
Definition: HD44780_LCD_PCF8574.cpp:245
void PCF8574_LCDMoveCursor(LCDDirectionType_e, uint8_t moveSize)
Moves cursor.
Definition: HD44780_LCD_PCF8574.cpp:220
void PCF8574_LCDBackLightSet(bool)
Turn LED backlight on and off.
Definition: HD44780_LCD_PCF8574.cpp:314
LCDDirectionType_e
Definition: HD44780_LCD_PCF8574.h:54
@ LCDMoveLeft
Definition: HD44780_LCD_PCF8574.h:56
@ LCDMoveRight
Definition: HD44780_LCD_PCF8574.h:55
bool PCF8574_LCD_I2C_ON(void)
Switch on the I2C.
Definition: HD44780_LCD_PCF8574.cpp:343
LCDBackLight_e
Definition: HD44780_LCD_PCF8574.h:32
@ LCDBackLightOffMask
Definition: HD44780_LCD_PCF8574.h:34
@ LCDBackLightOnMask
Definition: HD44780_LCD_PCF8574.h:33
void PCF8574_LCDClearScreenCmd(void)
Clear display using software command , set cursor position to zero.
Definition: HD44780_LCD_PCF8574.cpp:392
void PCF8574_LCDClearLine(LCDLineNumber_e lineNo)
Clear a line by writing spaces to every position.
Definition: HD44780_LCD_PCF8574.cpp:106
void PCF8574_LCDSendCmd(unsigned char cmd)
Send command byte to lcd.
Definition: HD44780_LCD_PCF8574.cpp:69
TwoWire * wire
Definition: HD44780_LCD_PCF8574.h:130
LCDCmdBytesGeneral_e
Definition: HD44780_LCD_PCF8574.h:115
@ LCDDisplayOn
Definition: HD44780_LCD_PCF8574.h:118
@ LCDModeFourBit
Definition: HD44780_LCD_PCF8574.h:116
@ LCDClearScreen
Definition: HD44780_LCD_PCF8574.h:120
@ LCDDisplayOff
Definition: HD44780_LCD_PCF8574.h:119
@ LCDHomePosition
Definition: HD44780_LCD_PCF8574.h:117
void PCF8574_LCDGOTO(LCDLineNumber_e lineNo, uint8_t col)
moves cursor to an x , y position on display.
Definition: HD44780_LCD_PCF8574.cpp:271
uint8_t _LCDSlaveAddresI2C
Definition: HD44780_LCD_PCF8574.h:127