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_SR3W.h
1 // ---------------------------------------------------------------------------
2 // Created by Francisco Malpartida on 7.3.2012.
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_SR3W.h
13 // This file implements a basic liquid crystal library that comes as standard
14 // in the Arduino SDK but using a generic SHIFT REGISTER extension board.
15 //
16 // @brief
17 // This is a basic implementation of the LiquidCrystal library of the
18 // Arduino SDK. The original library has been reworked in such a way that
19 // this class implements the all methods to command an LCD based
20 // on the Hitachi HD44780 and compatible chipsets using a 3 wire latching
21 // shift register. While it has been tested with a 74HC595N shift register
22 // it should also work with other latching shift registers such as the MC14094
23 // and the HEF4094
24 //
25 // This particular driver has been created as generic as possible to enable
26 // users to configure and connect their LCDs using just 3 digital IOs from the
27 // AVR or Arduino, and connect the LCD to the outputs of the shiftregister
28 // in any configuration. The library is configured by passing the IO pins
29 // that control the strobe, data and clock of the shift register and a map
30 // of how the shiftregister is connected to the LCD.
31 //
32 //
33 // +--------------------------------------------+
34 // | MCU |
35 // | IO1 IO2 IO3 |
36 // +----+-------------+-------------+-----------+
37 // | | |
38 // | | |
39 // +----+-------------+-------------+-----------+
40 // | Strobe Data Clock |
41 // | 8-bit shift/latch register | 74HC595N
42 // | Qa0 Qb1 Qc2 Qd3 Qe4 Qf5 Qg6 Qh7 |
43 // +----+----+----+----+----+----+----+----+----+
44 // | | | | | | |
45 // |11 |12 |13 |14 |6 |5 |4 (LCD pins)
46 // +----+----+----+----+----+----+----+----+----+
47 // | DB4 DB5 DB6 DB7 E Rw RS |
48 // | LCD Module |
49 //
50 // NOTE: Rw is not used by the driver so it can be connected to GND.
51 //
52 // The functionality provided by this class and its base class is identical
53 // to the original functionality of the Arduino LiquidCrystal library.
54 //
55 //
56 // @author F. Malpartida - fmalpartida@gmail.com
57 // ---------------------------------------------------------------------------
58 #ifndef _LIQUIDCRYSTAL_SR3W_H_
59 #define _LIQUIDCRYSTAL_SR3W_H_
60
61 #include <inttypes.h>
62 #include "LCD.h"
63 #include "FastIO.h"
64
65
66 class LiquidCrystal_SR3W : public LCD
67 {
68 public:
69
90 LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe);
91 // Constructor with backlight control
92 LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe,
93 uint8_t backlighPin, t_backlighPol pol);
94
112 LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe,
113 uint8_t En, uint8_t Rw, uint8_t Rs,
114 uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7 );
115 // Constructor with backlight control
116 LiquidCrystal_SR3W( uint8_t data, uint8_t clk, uint8_t strobe,
117 uint8_t En, uint8_t Rw, uint8_t Rs,
118 uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
119 uint8_t backlighPin, t_backlighPol pol);
120
133 virtual void send(uint8_t value, uint8_t mode);
134
145 void setBacklightPin ( uint8_t value, t_backlighPol pol );
146
156 void setBacklight ( uint8_t value );
157
158 private:
159
165 int init(uint8_t data, uint8_t clk, uint8_t strobe,
166 uint8_t Rs, uint8_t Rw, uint8_t En,
167 uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
168
177 void write4bits(uint8_t value, uint8_t mode);
178
185 void loadSR(uint8_t value);
186
187
188 fio_bit _strobe; // shift register strobe pin
189 fio_register _strobe_reg; // SR strobe pin MCU register
190 fio_bit _data; // shift register data pin
191 fio_register _data_reg; // SR data pin MCU register
192 fio_bit _clk; // shift register clock pin
193 fio_register _clk_reg; // SR clock pin MCU register
194 uint8_t _En; // LCD expander word for enable pin
195 uint8_t _Rw; // LCD expander word for R/W pin
196 uint8_t _Rs; // LCD expander word for Register Select pin
197 uint8_t _data_pins[4]; // LCD data lines
198 uint8_t _backlightPinMask; // Backlight IO pin mask
199 uint8_t _backlightStsMask; // Backlight status mask
200
201 };
202
203 #endif
204
LiquidCrystal_SR3W::setBacklightPin
void setBacklightPin(uint8_t value, t_backlighPol pol)
Definition: LiquidCrystal_SR3W.cpp:183
LiquidCrystal_SR3W
Definition: LiquidCrystal_SR3W.h:66
LiquidCrystal_SR3W::LiquidCrystal_SR3W
LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe)
Definition: LiquidCrystal_SR3W.cpp:133
LCD
Definition: LCD.h:187
LiquidCrystal_SR3W::setBacklight
void setBacklight(uint8_t value)
Definition: LiquidCrystal_SR3W.cpp:191
LiquidCrystal_SR3W::send
virtual void send(uint8_t value, uint8_t mode)
Definition: LiquidCrystal_SR3W.cpp:162