New LiquidCrystal library 1.3.2 Generic LCD control library

- Main Page
- Related Pages
- Classes
- Files

- File List

/Users/fmalpartida/Documents/development/mercurial repos/SW/NewliquidCrystal/LiquidCrystal_SR.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_SR.h
13 // Connects an LCD using 2 or 3 pins from the Arduino, via an 8-bit
14 // ShiftRegister (SR from now on).
15 //
16 // @brief
17 // This is a port of the ShiftRegLCD library from raron and ported to the
18 // LCD library.
19 //
20 // The functionality provided by this class and its base class is identical
21 // to the original functionality of the Arduino LiquidCrystal library and can
22 // be used as such.
23 //
24 // Modified to work serially with the shiftOut() function, an 8-bit
25 // unlatched, no-tristate, unidirectional SIPO (Serial-In-Parallel-Out)
26 // shift register (IE a very simple SR), and an LCD in 4-bit mode.
27 // Any such shift register should do (pref. 74LS family IC's for 2-wire).
28 // I used 74LS164, for the reason that's what I had at hand.
29 //
30 // Connection description:
31 //
32 // SR output:
33 // Bit #0 - N/C - not connected, used to hold a zero
34 // Bit #1 - N/C
35 // Bit #2 - connects to RS (Register Select) on the LCD
36 // Bits #3-6 - connects to LCD data inputs D4 - D7.
37 // Bit #7 - enables the LCD enable-puls (via the diode-resistor AND "gate")
38 //
39 // 2 or 3 Pins required from the Arduino for Data, Clock and (optional) Enable
40 // If not using Enable, the Data pin will be used for the enable signal.
41 // 2 wire mode can be indicated by:
42 // - ommitting the enable pin in constructor
43 // - defining the same pin for Enable as for Data in constructor
44 // - by using the token TWO_WIRE for the enable pin.
45 //
46 // Data and Clock outputs/pins goes to the shiftregister.
47 // LCD RW-pin hardwired to LOW (only writing to LCD).
48 // Busy Flag (BF, data bit D7) is not read.
49 //
50 // Original project homepage: http://code.google.com/p/arduinoshiftreglcd/
51 //
52 //
53 // History
54 // 2012.03.29 bperrybap - can now eliminate enable pin in constructor for two wire mode.
55 // 2011.10.29 fmalpartida - adaption of the library to the LCD class hierarchy.
56 // 2011.07.02 Fixed a minor flaw in setCursor function. No functional change,
57 // just a bit more memory efficient.
58 // Thanks to CapnBry (from google code and github) who noticed it.
59 // URL to his version of shiftregLCD:
60 // https://github.com/CapnBry/HeaterMeter/commit/c6beba1b46b092ab0b33bcbd0a30a201fd1f28c1
61 // 2009.07.30 raron - minor corrections to the comments.
62 // Fixed timing to datasheet safe. Fixed keyword highlights.
63 // 2009.07.28 Mircho / raron - a new modification to the schematics, and a
64 // more streamlined interface
65 // 2009.07.27 Thanks to an excellent suggestion from mircho at the Arduiono
66 // playgrond forum, the number of wires now required is only two!
67 // 2009.07.25 raron - Fixed comments. I really messed up the comments before
68 // posting this, so I had to fix it.
69 // Renamed a function, but no improvements or functional changes.
70 // 2009.07.23 Incorporated some proper initialization routines
71 // inspired (lets say copy-paste-tweaked) from LiquidCrystal
72 // library improvements from LadyAda.
73 // 2009.05.23 raron - first version, but based mostly (as in almost verbatim)
74 // on the "official" LiquidCrystal library.
75 //
76 //
77 //
78 // @author F. Malpartida - fmalpartida@gmail.com
79 // ---------------------------------------------------------------------------
80 #ifndef _LIQUIDCRYSTAL_SR_
81 #define _LIQUIDCRYSTAL_SR_
82
83 #include <inttypes.h>
84 #include "LCD.h"
85 #include "FastIO.h"
86
87
88 // two-wire indicator constant
89 // ---------------------------------------------------------------------------
90 #define TWO_WIRE 204
91 #define SR_RS_BIT 0x04
92 #define SR_EN_BIT 0x80
93
94 class LiquidCrystal_SR : public LCD
95 {
96 public:
108 LiquidCrystal_SR ( uint8_t srdata, uint8_t srclock, uint8_t enable=TWO_WIRE );
109
122 virtual void send(uint8_t value, uint8_t mode);
123
124
134 void setBacklightPin ( uint8_t pin, t_backlighPol pol );
135
145 void setBacklight ( uint8_t mode );
146
147 private:
148
154 void init ( uint8_t srdata, uint8_t srclock, uint8_t enable, uint8_t lines,
155 uint8_t font );
156
161 void shiftIt (uint8_t val);
162
163 uint8_t _enable_pin; // Enable Pin
164 uint8_t _two_wire; // two wire mode
165
166 fio_register _srDataRegister; // Serial Data pin
167 fio_bit _srDataBit;
168 fio_register _srClockRegister; // Clock Pin
169 fio_bit _srClockBit;
170 fio_register _srEnableRegister; // Enable Pin
171 fio_bit _srEnableBit;
172
173 };
174
175 #endif
176
LCD
Definition: LCD.h:187
LiquidCrystal_SR::LiquidCrystal_SR
LiquidCrystal_SR(uint8_t srdata, uint8_t srclock, uint8_t enable=TWO_WIRE)
Definition: LiquidCrystal_SR.cpp:98
LiquidCrystal_SR::setBacklight
void setBacklight(uint8_t mode)
Definition: LiquidCrystal_SR.cpp:207
LiquidCrystal_SR::send
virtual void send(uint8_t value, uint8_t mode)
Definition: LiquidCrystal_SR.cpp:172
LiquidCrystal_SR
Definition: LiquidCrystal_SR.h:94
LiquidCrystal_SR::setBacklightPin
void setBacklightPin(uint8_t pin, t_backlighPol pol)
Definition: LiquidCrystal_SR.cpp:202