New LiquidCrystal library  1.5.0
Generic LCD control library
/Users/fmalpartida/Documents/development/mercurial repos/SW/NewLiquidCrystal_lib/LiquidCrystal_SI2C.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 and software I2C.
27 // It will use digital pins 6 and 7 for SCL and SDA, but it can be changed
28 // in SI2CIO.cpp to use other pins if needed.
29 
30 // @brief
31 // This is a basic implementation of the LiquidCrystal library of the
32 // Arduino SDK. The original library has been reworked in such a way that
33 // this class implements the all methods to command an LCD based
34 // on the Hitachi HD44780 and compatible chipsets using I2C extension
35 // backpacks such as the I2CLCDextraIO with the PCF8574* I2C IO Expander ASIC.
36 //
37 // The functionality provided by this class and its base class is identical
38 // to the original functionality of the Arduino LiquidCrystal library.
39 //
40 //
41 // @author F. Malpartida - fmalpartida@gmail.com
42 // Adapted to SoftIC2 by Adrian Piccioli - adrianpiccioli@gmail.com
43 // ---------------------------------------------------------------------------
44 #ifndef LiquidCrystal_SI2C_h
45 #define LiquidCrystal_SI2C_h
46 
47 #if defined (__AVR__)
48 
49 #include <inttypes.h>
50 #include <Print.h>
51 
52 #include "SI2CIO.h"
53 #include "LCD.h"
54 
55 
56 class LiquidCrystal_SI2C : public LCD
57 {
58 public:
59 
69  LiquidCrystal_SI2C (uint8_t lcd_Addr);
70  // Constructor with backlight control
71  LiquidCrystal_SI2C (uint8_t lcd_Addr, uint8_t backlighPin, t_backlightPol pol);
72 
85  LiquidCrystal_SI2C( uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs);
86  // Constructor with backlight control
87  LiquidCrystal_SI2C(uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs,
88  uint8_t backlighPin, t_backlightPol pol);
89 
106  LiquidCrystal_SI2C(uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs,
107  uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7 );
108  // Constructor with backlight control
109  LiquidCrystal_SI2C(uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs,
110  uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
111  uint8_t backlighPin, t_backlightPol pol);
128  virtual void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);
129 
142  virtual void send(uint8_t value, uint8_t mode);
143 
152  void setBacklightPin ( uint8_t value, t_backlightPol pol );
153 
163  void setBacklight ( uint8_t value );
164 
181  void config (uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs,
182  uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7 );
183 
184 private:
185 
191  int init();
192 
193 
202  void write4bits(uint8_t value, uint8_t mode);
203 
210  void pulseEnable(uint8_t);
211 
212 
213  uint8_t _Addr; // I2C Address of the IO expander
214  uint8_t _backlightPinMask; // Backlight IO pin mask
215  uint8_t _backlightStsMask; // Backlight status mask
216  SI2CIO _si2cio; // I2CIO PCF8574* expansion module driver I2CLCDextraIO
217  uint8_t _En; // LCD expander word for enable pin
218  uint8_t _Rw; // LCD expander word for R/W pin
219  uint8_t _Rs; // LCD expander word for Register Select pin
220  uint8_t _data_pins[4]; // LCD data lines
221 
222 };
223 
224 #else
225 #error "ONLY SUPPORTED ON AVR PROCESSORS"
226 #endif // defined (__AVR__)
227 
228 #endif
Definition: LCD.h:199
virtual void setBacklightPin(uint8_t value, t_backlightPol pol)
Definition: LCD.h:498
virtual void setBacklight(uint8_t value)
Definition: LCD.h:517
virtual void begin(uint8_t cols, uint8_t rows, uint8_t charsize=LCD_5x8DOTS)
Definition: LCD.cpp:91