New LiquidCrystal library  1.5.0
Generic LCD control library
/Users/fmalpartida/Documents/development/mercurial repos/SW/NewLiquidCrystal_lib/LiquidCrystal_I2C.h
1 // ---------------------------------------------------------------------------
2 // Created by Francisco Malpartida on 20/08/11.
3 // Copyright (C) - 2018
4 //
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License v3.0
16 // along with this program.
17 // If not, see <https://www.gnu.org/licenses/gpl-3.0.en.html>.
18 //
19 // ---------------------------------------------------------------------------
20 //
21 // Thread Safe: No
22 // Extendable: Yes
23 //
24 // @file LiquidCrystal_I2C.h
25 // This file implements a basic liquid crystal library that comes as standard
26 // in the Arduino SDK but using an I2C IO extension board.
27 //
28 // @brief
29 // This is a basic implementation of the LiquidCrystal library of the
30 // Arduino SDK. The original library has been reworked in such a way that
31 // this class implements the all methods to command an LCD based
32 // on the Hitachi HD44780 and compatible chipsets using I2C extension
33 // backpacks such as the I2CLCDextraIO with the PCF8574* I2C IO Expander ASIC.
34 //
35 // The functionality provided by this class and its base class is identical
36 // to the original functionality of the Arduino LiquidCrystal library.
37 //
38 //
39 // @author F. Malpartida - fmalpartida@gmail.com
40 // ---------------------------------------------------------------------------
41 #ifndef LiquidCrystal_I2C_h
42 #define LiquidCrystal_I2C_h
43 #include <inttypes.h>
44 #include <Print.h>
45 
46 #include "I2CIO.h"
47 #include "LCD.h"
48 
49 
50 class LiquidCrystal_I2C : public LCD
51 {
52 public:
53 
63  LiquidCrystal_I2C (uint8_t lcd_Addr);
64  // Constructor with backlight control
65  LiquidCrystal_I2C (uint8_t lcd_Addr, uint8_t backlighPin, t_backlightPol pol);
66 
79  LiquidCrystal_I2C( uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs);
80  // Constructor with backlight control
81  LiquidCrystal_I2C(uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs,
82  uint8_t backlighPin, t_backlightPol pol);
83 
100  LiquidCrystal_I2C(uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs,
101  uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7 );
102  // Constructor with backlight control
103  LiquidCrystal_I2C(uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs,
104  uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
105  uint8_t backlighPin, t_backlightPol pol);
122  virtual void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);
123 
136  virtual void send(uint8_t value, uint8_t mode);
137 
146  void setBacklightPin ( uint8_t value, t_backlightPol pol );
147 
157  void setBacklight ( uint8_t value );
158 
175  void config (uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs,
176  uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7 );
177 
178 private:
179 
185  int init();
186 
195  void write4bits(uint8_t value, uint8_t mode);
196 
203  void pulseEnable(uint8_t);
204 
205 
206  uint8_t _Addr; // I2C Address of the IO expander
207  uint8_t _backlightPinMask; // Backlight IO pin mask
208  uint8_t _backlightStsMask; // Backlight status mask
209  I2CIO _i2cio; // I2CIO PCF8574* expansion module driver I2CLCDextraIO
210  uint8_t _En; // LCD expander word for enable pin
211  uint8_t _Rw; // LCD expander word for R/W pin
212  uint8_t _Rs; // LCD expander word for Register Select pin
213  uint8_t _data_pins[4]; // LCD data lines
214 
215 };
216 
217 #endif
Definition: I2CIO.h:56
Definition: LCD.h:199
LiquidCrystal_I2C(uint8_t lcd_Addr)
Definition: LiquidCrystal_I2C.cpp:108
virtual void begin(uint8_t cols, uint8_t rows, uint8_t charsize=LCD_5x8DOTS)
Definition: LiquidCrystal_I2C.cpp:156
virtual void send(uint8_t value, uint8_t mode)
Definition: LiquidCrystal_I2C.cpp:252
Definition: LiquidCrystal_I2C.h:50
void config(uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7)
Definition: LiquidCrystal_I2C.cpp:225
void setBacklight(uint8_t value)
Definition: LiquidCrystal_I2C.cpp:179
void setBacklightPin(uint8_t value, t_backlightPol pol)
Definition: LiquidCrystal_I2C.cpp:170