![]() | LCD Library 1.2.1 LCD Library - LCD control class hierarchy library. Drop in replacement for the LiquidCrystal Library. |
00001 // ---------------------------------------------------------------------------00002 // Created by Francisco Malpartida on 7.3.2012.00003 // Copyright 2011 - Under creative commons license 3.0:00004 // Attribution-ShareAlike CC BY-SA00005 //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: No00010 // Extendable: Yes00011 //00012 // @file LiquidCrystal_SR3W.h00013 // This file implements a basic liquid crystal library that comes as standard00014 // in the Arduino SDK but using a generic SHIFT REGISTER extension board.00015 // 00016 // @brief 00017 // This is a basic implementation of the LiquidCrystal library of the00018 // Arduino SDK. The original library has been reworked in such a way that 00019 // this class implements the all methods to command an LCD based00020 // on the Hitachi HD44780 and compatible chipsets using a 3 wire latching00021 // shift register. While it has been tested with a 74HC595N shift register00022 // it should also work with other latching shift registers such as the MC1409400023 // and the HEF409400024 //00025 // This particular driver has been created as generic as possible to enable00026 // users to configure and connect their LCDs using just 3 digital IOs from the00027 // AVR or Arduino, and connect the LCD to the outputs of the shiftregister00028 // in any configuration. The library is configured by passing the IO pins00029 // that control the strobe, data and clock of the shift register and a map00030 // of how the shiftregister is connected to the LCD.00031 // 00032 //00033 // +--------------------------------------------+00034 // | MCU |00035 // | IO1 IO2 IO3 |00036 // +----+-------------+-------------+-----------+00037 // | | |00038 // | | |00039 // +----+-------------+-------------+-----------+00040 // | Strobe Data Clock |00041 // | 8-bit shift/latch register | 74HC595N00042 // | Qa0 Qb1 Qc2 Qd3 Qe4 Qf5 Qg6 Qh7 |00043 // +----+----+----+----+----+----+----+----+----+00044 // | | | | | | | 00045 // |11 |12 |13 |14 |6 |5 |4 (LCD pins)00046 // +----+----+----+----+----+----+----+----+----+00047 // | DB4 DB5 DB6 DB7 E Rw RS |00048 // | LCD Module |00049 //00050 // NOTE: Rw is not used by the driver so it can be connected to GND.00051 //00052 // The functionality provided by this class and its base class is identical00053 // to the original functionality of the Arduino LiquidCrystal library.00054 //00055 //00056 // @author F. Malpartida - fmalpartida@gmail.com00057 // ---------------------------------------------------------------------------00058 #ifndef _LIQUIDCRYSTAL_SR3W_H_00059 #define _LIQUIDCRYSTAL_SR3W_H_00060 00061 #include <inttypes.h>00062 #include "LCD.h"00063 #include "FastIO.h"00064 00065 00066class LiquidCrystal_SR3W : publicLCD00067 { 00068 public: 00069 00090 LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe); 00091 // Constructor with backlight control00092 LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe, 00093 uint8_t backlighPin, t_backlighPol pol); 00094 00112 LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe, 00113 uint8_t En, uint8_t Rw, uint8_t Rs, 00114 uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7 ); 00115 // Constructor with backlight control00116 LiquidCrystal_SR3W( uint8_t data, uint8_t clk, uint8_t strobe, 00117 uint8_t En, uint8_t Rw, uint8_t Rs, 00118 uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 00119 uint8_t backlighPin, t_backlighPol pol); 00120 00133 virtualvoidsend(uint8_t value, uint8_t mode); 00134 00143 voidsetBacklightPin ( uint8_t value, t_backlighPol pol ); 00144 00154 voidsetBacklight ( uint8_t value ); 00155 00156 private: 00157 00163 int init(uint8_t data, uint8_t clk, uint8_t strobe, 00164 uint8_t Rs, uint8_t Rw, uint8_t En, 00165 uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); 00166 00175 void write4bits(uint8_t value, uint8_t mode); 00176 00183 void loadSR(uint8_t value); 00184 00185 00186 fio_bit _strobe; // shift register strobe pin00187 fio_register _strobe_reg; // SR strobe pin MCU register00188 fio_bit _data; // shift register data pin00189 fio_register _data_reg; // SR data pin MCU register00190 fio_bit _clk; // shift register clock pin00191 fio_register _clk_reg; // SR clock pin MCU register00192 uint8_t _En; // LCD expander word for enable pin00193 uint8_t _Rw; // LCD expander word for R/W pin00194 uint8_t _Rs; // LCD expander word for Register Select pin00195 uint8_t _data_pins[4]; // LCD data lines00196 uint8_t _backlightPinMask; // Backlight IO pin mask00197 uint8_t _backlightStsMask; // Backlight status mask00198 00199 }; 00200 00201 #endif00202