LCD Library 1.1.7
LCD Library - LCD control class hierarchy library. Drop in replacement for the LiquidCrystal Library.
/Users/fmalpartida/development/ardWorkspace/LiquidCrystal_I2C/LiquiCrystal_I2C/LiquidCrystal_I2C.h
Go to the documentation of this file.
00001 // ---------------------------------------------------------------------------
00002 // Created by Francisco Malpartida on 20/08/11.
00003 // Copyright 2011 - Under creative commons license 3.0:
00004 //        Attribution-ShareAlike CC BY-SA
00005 //
00006 // This software is furnished "as is", without technical support, and with no 
00007 // warranty, express or implied, as to its usefulness for any purpose.
00008 //
00009 // Thread Safe: No
00010 // Extendable: Yes
00011 //
00012 // @file LiquidCrystal_I2C.h
00013 // This file implements a basic liquid crystal library that comes as standard
00014 // in the Arduino SDK but using an I2C IO extension board.
00015 // 
00016 // @brief 
00017 // This is a basic implementation of the LiquidCrystal library of the
00018 // Arduino SDK. The original library has been reworked in such a way that 
00019 // this class implements the all methods to command an LCD based
00020 // on the Hitachi HD44780 and compatible chipsets using I2C extension
00021 // backpacks such as the I2CLCDextraIO with the PCF8574* I2C IO Expander ASIC.
00022 //
00023 // The functionality provided by this class and its base class is identical
00024 // to the original functionality of the Arduino LiquidCrystal library.
00025 //
00026 //
00027 // This library is only compatible with Arduino's SDK version 1.0
00028 //
00029 //
00030 // @author F. Malpartida - fmalpartida@gmail.com
00031 // ---------------------------------------------------------------------------
00032 #ifndef LiquidCrystal_I2C_h
00033 #define LiquidCrystal_I2C_h
00034 #include <inttypes.h>
00035 #include <Print.h>
00036 #include <I2CIO.h>
00037 #include <LCD.h>
00038 
00039 // flags for backlight control
00040 #define LCD_BACKLIGHT   0x00
00041 #define LCD_NOBACKLIGHT 0x80
00042 
00053 #define EN B01000000  // Enable bit
00054 
00060 #define RW B00100000  // Read/Write bit
00061 
00067 #define RS B00010000  // Register select bit
00068 
00069 
00070 class LiquidCrystal_I2C : public LCD 
00071 {
00072 public:
00073    
00083    LiquidCrystal_I2C (uint8_t lcd_Addr);
00084    
00097    LiquidCrystal_I2C( uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs);
00098    
00099    
00116    LiquidCrystal_I2C( uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs, 
00117                      uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3 );
00118    
00131    virtual void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);   
00132    
00145    virtual void send(uint8_t value, uint8_t mode);
00146    
00155    void noBacklight();
00156    
00165    void backlight();
00166    
00167    
00168 private:
00169    
00175    int  init();
00176    
00185    void write4bits(uint8_t value, uint8_t mode);
00186    
00193    void pulseEnable(uint8_t);
00194    
00201    void expanderWrite(uint8_t);
00202    
00203    uint8_t _Addr;           // I2C Address of the IO expander
00204    uint8_t _backlightval;   // Backlight shadow value
00205    I2CIO   _i2cio;          // I2CIO PCF8574* expansion module driver I2CLCDextraIO
00206    uint8_t _En;             // LCD expander word for enable pin
00207    uint8_t _Rw;             // LCD expander word for R/W pin
00208    uint8_t _Rs;             // LCD expander word for Register Select pin
00209    uint8_t _data_pins[4];   // LCD data lines
00210    
00211 };
00212 
00213 #endif
 All Classes Files Functions Variables Defines