LCD Library 1.1.1
LCD Library - LCD control class hierarchy library. Drop in replacement for the LiquidCrystal Library.
/Users/fmalpartida/development/ardWorkspace/LiquidCrystal_I2C/LiquiCrystal_I2C/LiquidCrystal_SR.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_SR.h
00013 //  Connects an LCD using 2 or 3 pins from the Arduino, via an 8-bit 
00014 // ShiftRegister (SR from now on).
00015 // 
00016 // @brief 
00017 // This is a port of the ShiftRegLCD library from raron and ported to the
00018 // LCD library.
00019 //
00020 // The functionality provided by this class and its base class is identical
00021 // to the original functionality of the Arduino LiquidCrystal library and can
00022 // be used as such.
00023 //
00024 // Modified to work serially with the shiftOut() function, an 8-bit shiftregister 
00025 // (SR) and an LCD in 4-bit mode.
00026 //
00027 // Shiftregister connection description (NEW as of 2009.07.27)
00028 //
00029 // Bit  #0 - N/C - not connected, used to hold a zero
00030 // Bits #1 - N/C
00031 // Bit  #2 - connects to RS (Register Select) on the LCD
00032 // Bits #3 - #6 from SR connects to LCD data inputs D4 - D7.
00033 // Bit  #7 - is used to enabling the enable-puls (via a diode-resistor AND "gate")
00034 //
00035 // 2 or 3 Pins required from the Arduino for Data, Clock, and Enable (optional). 
00036 // If not using Enable, the Data pin is used for the enable signal by defining 
00037 // the same pin for Enable as for Data. Data and Clock outputs/pins goes to the 
00038 // shiftregister.
00039 // LCD RW-pin hardwired to LOW (only writing to LCD). Busy Flag (BF, data bit D7) 
00040 // is not read.
00041 //
00042 // Any shift register should do. I used 74LS164, for the reason that's what I 
00043 // had at hand.
00044 //
00045 //  Original project homepage: http://code.google.com/p/arduinoshiftreglcd/
00046 //
00047 // History
00048 // 2011.10.29  fmalpartida - adaption of the library to the LCD class hierarchy.
00049 // 2009.05.23  raron - but; based mostly (as in almost verbatim) on the 
00050 //             "official" LiquidCrystal library.
00051 // 2009.07.23  Incorporated some proper initialization routines
00052 //             inspired (lets say copy-paste-tweaked) from LiquidCrystal library 
00053 //             improvements from LadyAda
00054 // 2009.07.25  raron - Fixed comments. I really messed up the comments before 
00055 //             posting this, so I had to fix it.
00056 //             Also renamed a function, but no improvements or functional changes.
00057 // 2009.07.27  Thanks to an excellent suggestion from mircho at the Arduiono 
00058 //             playgrond forum, the number of wires now required is only two!
00059 // 2009.07.28  Mircho / raron - a new modification to the schematics, and a more 
00060 //             streamlined interface
00061 // 2009.07.30  raron - minor corrections to the comments. Fixed keyword highlights. 
00062 //             Fixed timing to datasheet safe.
00063 // 2011.07.02  Fixed a minor flaw in setCursor function. No functional change, 
00064 //             just a bit more memory efficient.
00065 //             Thanks to CapnBry (from google code and github) who noticed it. 
00066 //             URL to his version of shiftregLCD:
00067 //https://github.com/CapnBry/HeaterMeter/commit/c6beba1b46b092ab0b33bcbd0a30a201fd1f28c1
00068 //
00069 //
00070 // This library is only compatible with Arduino's SDK version 1.0
00071 //
00072 //
00073 // @author F. Malpartida - fmalpartida@gmail.com
00074 // ---------------------------------------------------------------------------
00075 #ifndef _LIQUIDCRYSTAL_SR_
00076 #define _LIQUIDCRYSTAL_SR_
00077 
00078 #include <inttypes.h>
00079 #include <LCD.h>
00080 
00081 
00082 // two-wire indicator constant
00083 // ---------------------------------------------------------------------------
00084 #define TWO_WIRE  204
00085 #define SR_RS_BIT 0x04
00086 #define SR_EN_BIT 0x80
00087 
00088 class LiquidCrystal_SR : public LCD
00089 {
00090 public:
00102    LiquidCrystal_SR ( uint8_t srdata, uint8_t srclock, uint8_t enable );
00103    
00104    
00105    // Set nr. of lines, assume 8 pixel high font
00106    LiquidCrystal_SR ( uint8_t srdata, uint8_t srclock, uint8_t enable, 
00107                      uint8_t lines );
00108    
00109    // Set nr. of lines and font
00110    LiquidCrystal_SR( uint8_t srdata, uint8_t srclock, uint8_t enable, 
00111                     uint8_t lines, uint8_t font );
00112    
00113    
00126    virtual void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);   
00127    
00140    virtual void send(uint8_t value, uint8_t mode);
00141    
00142    
00143 private:
00144    
00150    void init ( uint8_t srdata, uint8_t srclock, uint8_t enable, uint8_t lines, 
00151               uint8_t font );
00157    void init4bits ( uint8_t );
00158    
00159    uint8_t _srdata_pin;  // Serial Data pin
00160    uint8_t _srclock_pin; // Clock Pin
00161    uint8_t _enable_pin;  // Enable Pin
00162    uint8_t _two_wire;    // two wire mode
00163 };
00164 
00165 #endif
00166 
 All Classes Files Functions Variables Defines