| LCD Library 1.2.1 LCD Library - LCD control class hierarchy library. Drop in replacement for the LiquidCrystal Library.

- Main Page
- Classes
- Files

- File List
- File Members

/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
    00025 // unlatched, no-tristate, unidirectional SIPO (Serial-In-Parallel-Out)
    00026 // shift register (IE a very simple SR), and an LCD in 4-bit mode.
    00027 // Any such shift register should do (pref. 74LS family IC's for 2-wire).
    00028 // I used 74LS164, for the reason that's what I had at hand.
    00029 //
    00030 // Connection description:
    00031 //
    00032 // SR output:
    00033 // Bit  #0   - N/C - not connected, used to hold a zero
    00034 // Bit  #1   - N/C
    00035 // Bit  #2   - connects to RS (Register Select) on the LCD
    00036 // Bits #3-6 - connects to LCD data inputs D4 - D7.
    00037 // Bit  #7   - enables the LCD enable-puls (via the diode-resistor AND "gate")
    00038 //
    00039 // 2 or 3 Pins required from the Arduino for Data, Clock and (optional) Enable
    00040 // If not using Enable, the Data pin will be used for the enable signal.
    00041 // 2 wire mode can be indicated by:
    00042 // - ommitting the enable pin in constructor
    00043 // - defining the same pin for Enable as for Data in constructor
    00044 // - by using the token TWO_WIRE for the enable pin.
    00045 //
    00046 // Data and Clock outputs/pins goes to the shiftregister.
    00047 // LCD RW-pin hardwired to LOW (only writing to LCD).
    00048 // Busy Flag (BF, data bit D7) is not read.
    00049 //
    00050 //  Original project homepage: http://code.google.com/p/arduinoshiftreglcd/
    00051 //
    00052 //
    00053 // History
    00054 // 2012.03.29  bperrybap - can now eliminate enable pin in constructor for two wire mode.
    00055 // 2011.10.29  fmalpartida - adaption of the library to the LCD class hierarchy.
    00056 // 2011.07.02  Fixed a minor flaw in setCursor function. No functional change,
    00057 //             just a bit more memory efficient.
    00058 //             Thanks to CapnBry (from google code and github) who noticed it.
    00059 //             URL to his version of shiftregLCD:
    00060 //             https://github.com/CapnBry/HeaterMeter/commit/c6beba1b46b092ab0b33bcbd0a30a201fd1f28c1
    00061 // 2009.07.30  raron - minor corrections to the comments.
    00062 //             Fixed timing to datasheet safe. Fixed keyword highlights.
    00063 // 2009.07.28  Mircho / raron - a new modification to the schematics, and a
    00064 //             more streamlined interface
    00065 // 2009.07.27  Thanks to an excellent suggestion from mircho at the Arduiono
    00066 //             playgrond forum, the number of wires now required is only two!
    00067 // 2009.07.25  raron - Fixed comments. I really messed up the comments before
    00068 //             posting this, so I had to fix it.
    00069 //             Renamed a function, but no improvements or functional changes.
    00070 // 2009.07.23  Incorporated some proper initialization routines
    00071 //             inspired (lets say copy-paste-tweaked) from LiquidCrystal
    00072 //             library improvements from LadyAda.
    00073 // 2009.05.23  raron - first version, but based mostly (as in almost verbatim)
    00074 //             on the "official" LiquidCrystal library.
    00075 //
    00076 //
    00077 //
    00078 // @author F. Malpartida - fmalpartida@gmail.com
    00079 // ---------------------------------------------------------------------------
    00080 #ifndef _LIQUIDCRYSTAL_SR_
    00081 #define _LIQUIDCRYSTAL_SR_
    00082
    00083 #include <inttypes.h>
    00084 #include "LCD.h"
    00085 #include "FastIO.h"
    00086
    00087
    00088 // two-wire indicator constant
    00089 // ---------------------------------------------------------------------------
    00090 #define TWO_WIRE  204
    00091 #define SR_RS_BIT 0x04
    00092 #define SR_EN_BIT 0x80
    00093
    00094 class LiquidCrystal_SR : public LCD
    00095 {
    00096 public:
    00108    LiquidCrystal_SR ( uint8_t srdata, uint8_t srclock, uint8_t enable=TWO_WIRE );
    00109
    00122    virtual void send(uint8_t value, uint8_t mode);
    00123
    00124
    00134    void setBacklightPin ( uint8_t pin, t_backlighPol pol );
    00135
    00145    void setBacklight ( uint8_t mode );
    00146
    00147 private:
    00148
    00154    void init ( uint8_t srdata, uint8_t srclock, uint8_t enable, uint8_t lines,
    00155               uint8_t font );
    00156
    00161    void shiftIt (uint8_t val);
    00162
    00163    uint8_t _enable_pin;  // Enable Pin
    00164    uint8_t _two_wire;    // two wire mode
    00165
    00166    fio_register _srDataRegister; // Serial Data pin
    00167    fio_bit _srDataBit;
    00168    fio_register _srClockRegister; // Clock Pin
    00169    fio_bit _srClockBit;
    00170    fio_register _srEnableRegister; // Enable Pin
    00171    fio_bit _srEnableBit;
    00172
    00173 };
    00174
    00175 #endif
    00176

All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines