New LiquidCrystal library  1.5.0
Generic LCD control library
/Users/fmalpartida/Documents/development/mercurial repos/SW/NewLiquidCrystal_lib/LiquidCrystal_SR3W.h
1 // ---------------------------------------------------------------------------
2 // Created by Francisco Malpartida on 7.3.2012.
3 // Copyright (C) - 2018
4 //
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License v3.0
16 // along with this program.
17 // If not, see <https://www.gnu.org/licenses/gpl-3.0.en.html>.
18 //
19 // ---------------------------------------------------------------------------
20 //
21 // Thread Safe: No
22 // Extendable: Yes
23 //
24 // @file LiquidCrystal_SR3W.h
25 // This file implements a basic liquid crystal library that comes as standard
26 // in the Arduino SDK but using a generic SHIFT REGISTER extension board.
27 //
28 // @brief
29 // This is a basic implementation of the LiquidCrystal library of the
30 // Arduino SDK. The original library has been reworked in such a way that
31 // this class implements the all methods to command an LCD based
32 // on the Hitachi HD44780 and compatible chipsets using a 3 wire latching
33 // shift register. While it has been tested with a 74HC595N shift register
34 // it should also work with other latching shift registers such as the MC14094
35 // and the HEF4094
36 //
37 // This particular driver has been created as generic as possible to enable
38 // users to configure and connect their LCDs using just 3 digital IOs from the
39 // AVR or Arduino, and connect the LCD to the outputs of the shiftregister
40 // in any configuration. The library is configured by passing the IO pins
41 // that control the strobe, data and clock of the shift register and a map
42 // of how the shiftregister is connected to the LCD.
43 //
44 //
45 // +--------------------------------------------+
46 // | MCU |
47 // | IO1 IO2 IO3 |
48 // +----+-------------+-------------+-----------+
49 // | | |
50 // | | |
51 // +----+-------------+-------------+-----------+
52 // | Strobe Data Clock |
53 // | 8-bit shift/latch register | 74HC595N
54 // | Qa0 Qb1 Qc2 Qd3 Qe4 Qf5 Qg6 Qh7 |
55 // +----+----+----+----+----+----+----+----+----+
56 // | | | | | | |
57 // |11 |12 |13 |14 |6 |5 |4 (LCD pins)
58 // +----+----+----+----+----+----+----+----+----+
59 // | DB4 DB5 DB6 DB7 E Rw RS |
60 // | LCD Module |
61 //
62 // NOTE: Rw is not used by the driver so it can be connected to GND.
63 //
64 // The functionality provided by this class and its base class is identical
65 // to the original functionality of the Arduino LiquidCrystal library.
66 //
67 //
68 // @author F. Malpartida - fmalpartida@gmail.com
69 // ---------------------------------------------------------------------------
70 #ifndef _LIQUIDCRYSTAL_SR3W_H_
71 #define _LIQUIDCRYSTAL_SR3W_H_
72 
73 #include <inttypes.h>
74 #include "LCD.h"
75 #include "FastIO.h"
76 
77 
78 class LiquidCrystal_SR3W : public LCD
79 {
80 public:
81 
102  LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe);
103  // Constructor with backlight control
104  LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe,
105  uint8_t backlighPin, t_backlightPol pol);
106 
124  LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe,
125  uint8_t En, uint8_t Rw, uint8_t Rs,
126  uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7 );
127  // Constructor with backlight control
128  LiquidCrystal_SR3W( uint8_t data, uint8_t clk, uint8_t strobe,
129  uint8_t En, uint8_t Rw, uint8_t Rs,
130  uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
131  uint8_t backlighPin, t_backlightPol pol);
132 
145  virtual void send(uint8_t value, uint8_t mode);
146 
157  void setBacklightPin ( uint8_t value, t_backlightPol pol );
158 
168  void setBacklight ( uint8_t value );
169 
170 private:
171 
177  int init(uint8_t data, uint8_t clk, uint8_t strobe,
178  uint8_t Rs, uint8_t Rw, uint8_t En,
179  uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
180 
189  void write4bits(uint8_t value, uint8_t mode);
190 
197  void loadSR(uint8_t value);
198 
199 
200  fio_bit _strobe; // shift register strobe pin
201  fio_register _strobe_reg; // SR strobe pin MCU register
202  fio_bit _data; // shift register data pin
203  fio_register _data_reg; // SR data pin MCU register
204  fio_bit _clk; // shift register clock pin
205  fio_register _clk_reg; // SR clock pin MCU register
206  uint8_t _En; // LCD expander word for enable pin
207  uint8_t _Rw; // LCD expander word for R/W pin
208  uint8_t _Rs; // LCD expander word for Register Select pin
209  uint8_t _data_pins[4]; // LCD data lines
210  uint8_t _backlightPinMask; // Backlight IO pin mask
211  uint8_t _backlightStsMask; // Backlight status mask
212 
213 };
214 
215 #endif
216 
Definition: LiquidCrystal_SR3W.h:78
LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe)
Definition: LiquidCrystal_SR3W.cpp:148
Definition: LCD.h:199
void setBacklight(uint8_t value)
Definition: LiquidCrystal_SR3W.cpp:206
virtual void send(uint8_t value, uint8_t mode)
Definition: LiquidCrystal_SR3W.cpp:177
void setBacklightPin(uint8_t value, t_backlightPol pol)
Definition: LiquidCrystal_SR3W.cpp:198