LCD Library 1.2.1
LCD Library - LCD control class hierarchy library. Drop in replacement for the LiquidCrystal Library.
|
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 // @author F. Malpartida - [email protected] 00028 // --------------------------------------------------------------------------- 00029 #ifndef LiquidCrystal_I2C_h 00030 #define LiquidCrystal_I2C_h 00031 #include <inttypes.h> 00032 #include <Print.h> 00033 00034 #include "I2CIO.h" 00035 #include "LCD.h" 00036 00037 00038 class LiquidCrystal_I2C : public LCD 00039 { 00040 public: 00041 00051 LiquidCrystal_I2C (uint8_t lcd_Addr); 00052 // Constructor with backlight control 00053 LiquidCrystal_I2C (uint8_t lcd_Addr, uint8_t backlighPin, t_backlighPol pol); 00054 00067 LiquidCrystal_I2C( uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs); 00068 // Constructor with backlight control 00069 LiquidCrystal_I2C(uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs, 00070 uint8_t backlighPin, t_backlighPol pol); 00071 00088 LiquidCrystal_I2C(uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs, 00089 uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7 ); 00090 // Constructor with backlight control 00091 LiquidCrystal_I2C(uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs, 00092 uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 00093 uint8_t backlighPin, t_backlighPol pol); 00110 virtual void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); 00111 00124 virtual void send(uint8_t value, uint8_t mode); 00125 00134 void setBacklightPin ( uint8_t value, t_backlighPol pol ); 00135 00145 void setBacklight ( uint8_t value ); 00146 00147 private: 00148 00154 int init(); 00155 00171 void config (uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs, 00172 uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7 ); 00173 00182 void write4bits(uint8_t value, uint8_t mode); 00183 00190 void pulseEnable(uint8_t); 00191 00192 00193 uint8_t _Addr; // I2C Address of the IO expander 00194 uint8_t _backlightPinMask; // Backlight IO pin mask 00195 uint8_t _backlightStsMask; // Backlight status mask 00196 I2CIO _i2cio; // I2CIO PCF8574* expansion module driver I2CLCDextraIO 00197 uint8_t _En; // LCD expander word for enable pin 00198 uint8_t _Rw; // LCD expander word for R/W pin 00199 uint8_t _Rs; // LCD expander word for Register Select pin 00200 uint8_t _data_pins[4]; // LCD data lines 00201 00202 }; 00203 00204 #endif