New LiquidCrystal library  1.3.5
Generic LCD control library
/Users/fmalpartida/Documents/development/mercurial repos/SW/NewliquidCrystal/LiquidCrystal_SI2C.h
1 // ---------------------------------------------------------------------------
2 // Created by Francisco Malpartida on 20/08/11.
3 // Copyright 2011 - Under creative commons license 3.0:
4 // Attribution-ShareAlike CC BY-SA
5 //
6 // This software is furnished "as is", without technical support, and with no
7 // warranty, express or implied, as to its usefulness for any purpose.
8 //
9 // Thread Safe: No
10 // Extendable: Yes
11 //
12 // @file LiquidCrystal_I2C.h
13 // This file implements a basic liquid crystal library that comes as standard
14 // in the Arduino SDK but using an I2C IO extension board and software I2C.
15 // It will use digital pins 6 and 7 for SCL and SDA, but it can be changed
16 // in SI2CIO.cpp to use other pins if needed.
17 
18 // @brief
19 // This is a basic implementation of the LiquidCrystal library of the
20 // Arduino SDK. The original library has been reworked in such a way that
21 // this class implements the all methods to command an LCD based
22 // on the Hitachi HD44780 and compatible chipsets using I2C extension
23 // backpacks such as the I2CLCDextraIO with the PCF8574* I2C IO Expander ASIC.
24 //
25 // The functionality provided by this class and its base class is identical
26 // to the original functionality of the Arduino LiquidCrystal library.
27 //
28 //
29 // @author F. Malpartida - fmalpartida@gmail.com
30 // Adapted to SoftIC2 by Adrian Piccioli - adrianpiccioli@gmail.com
31 // ---------------------------------------------------------------------------
32 #ifndef LiquidCrystal_SI2C_h
33 #define LiquidCrystal_SI2C_h
34 
35 #if defined (__AVR__)
36 
37 #include <inttypes.h>
38 #include <Print.h>
39 
40 #include "SI2CIO.h"
41 #include "LCD.h"
42 
43 
44 class LiquidCrystal_SI2C : public LCD
45 {
46 public:
47 
57  LiquidCrystal_SI2C (uint8_t lcd_Addr);
58  // Constructor with backlight control
59  LiquidCrystal_SI2C (uint8_t lcd_Addr, uint8_t backlighPin, t_backlightPol pol);
60 
73  LiquidCrystal_SI2C( uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs);
74  // Constructor with backlight control
75  LiquidCrystal_SI2C(uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs,
76  uint8_t backlighPin, t_backlightPol pol);
77 
94  LiquidCrystal_SI2C(uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs,
95  uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7 );
96  // Constructor with backlight control
97  LiquidCrystal_SI2C(uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs,
98  uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
99  uint8_t backlighPin, t_backlightPol pol);
116  virtual void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);
117 
130  virtual void send(uint8_t value, uint8_t mode);
131 
140  void setBacklightPin ( uint8_t value, t_backlightPol pol );
141 
151  void setBacklight ( uint8_t value );
152 
169  void config (uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs,
170  uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7 );
171 
172 private:
173 
179  int init();
180 
181 
190  void write4bits(uint8_t value, uint8_t mode);
191 
198  void pulseEnable(uint8_t);
199 
200 
201  uint8_t _Addr; // I2C Address of the IO expander
202  uint8_t _backlightPinMask; // Backlight IO pin mask
203  uint8_t _backlightStsMask; // Backlight status mask
204  SI2CIO _si2cio; // I2CIO PCF8574* expansion module driver I2CLCDextraIO
205  uint8_t _En; // LCD expander word for enable pin
206  uint8_t _Rw; // LCD expander word for R/W pin
207  uint8_t _Rs; // LCD expander word for Register Select pin
208  uint8_t _data_pins[4]; // LCD data lines
209 
210 };
211 
212 #else
213 #error "ONLY SUPPORTED ON AVR PROCESSORS"
214 #endif // defined (__AVR__)
215 
216 #endif
Definition: LCD.h:187
virtual void setBacklightPin(uint8_t value, t_backlightPol pol)
Definition: LCD.h:486
virtual void setBacklight(uint8_t value)
Definition: LCD.h:505
virtual void begin(uint8_t cols, uint8_t rows, uint8_t charsize=LCD_5x8DOTS)
Definition: LCD.cpp:79