/Users/fmalpartida/Documents/development/mercurial repos/SW/NewLiquidCrystal_lib/LiquidCrystal_SR3W.h
// ---------------------------------------------------------------------------
// Created by Francisco Malpartida on 7.3.2012.
// Copyright (C) - 2018
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License v3.0
// along with this program.
// If not, see <https://www.gnu.org/licenses/gpl-3.0.en.html>.
//
// ---------------------------------------------------------------------------
//
// Thread Safe: No
// Extendable: Yes
//
// @file LiquidCrystal_SR3W.h
// This file implements a basic liquid crystal library that comes as standard
// in the Arduino SDK but using a generic SHIFT REGISTER extension board.
//
// @brief
// This is a basic implementation of the LiquidCrystal library of the
// Arduino SDK. The original library has been reworked in such a way that
// this class implements the all methods to command an LCD based
// on the Hitachi HD44780 and compatible chipsets using a 3 wire latching
// shift register. While it has been tested with a 74HC595N shift register
// it should also work with other latching shift registers such as the MC14094
// and the HEF4094
//
// This particular driver has been created as generic as possible to enable
// users to configure and connect their LCDs using just 3 digital IOs from the
// AVR or Arduino, and connect the LCD to the outputs of the shiftregister
// in any configuration. The library is configured by passing the IO pins
// that control the strobe, data and clock of the shift register and a map
// of how the shiftregister is connected to the LCD.
//
//
// +--------------------------------------------+
// | MCU |
// | IO1 IO2 IO3 |
// +----+-------------+-------------+-----------+
// | | |
// | | |
// +----+-------------+-------------+-----------+
// | Strobe Data Clock |
// | 8-bit shift/latch register | 74HC595N
// | Qa0 Qb1 Qc2 Qd3 Qe4 Qf5 Qg6 Qh7 |
// +----+----+----+----+----+----+----+----+----+
// | | | | | | |
// |11 |12 |13 |14 |6 |5 |4 (LCD pins)
// +----+----+----+----+----+----+----+----+----+
// | DB4 DB5 DB6 DB7 E Rw RS |
// | LCD Module |
//
// NOTE: Rw is not used by the driver so it can be connected to GND.
//
// The functionality provided by this class and its base class is identical
// to the original functionality of the Arduino LiquidCrystal library.
//
//
// @author F. Malpartida - fmalpartida@gmail.com
// ---------------------------------------------------------------------------
#ifndef _LIQUIDCRYSTAL_SR3W_H_
#define _LIQUIDCRYSTAL_SR3W_H_
#include <inttypes.h>
#include "LCD.h"
#include "FastIO.h"
class LiquidCrystal_SR3W : public LCD
{
public:
LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe);
// Constructor with backlight control
LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe,
uint8_t backlighPin, t_backlightPol pol);
LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe,
uint8_t En, uint8_t Rw, uint8_t Rs,
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7 );
// Constructor with backlight control
LiquidCrystal_SR3W( uint8_t data, uint8_t clk, uint8_t strobe,
uint8_t En, uint8_t Rw, uint8_t Rs,
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
uint8_t backlighPin, t_backlightPol pol);
virtual void send(uint8_t value, uint8_t mode);
void setBacklightPin ( uint8_t value, t_backlightPol pol );
void setBacklight ( uint8_t value );
private:
int init(uint8_t data, uint8_t clk, uint8_t strobe,
uint8_t Rs, uint8_t Rw, uint8_t En,
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
void write4bits(uint8_t value, uint8_t mode);
void loadSR(uint8_t value);
fio_bit _strobe; // shift register strobe pin
fio_register _strobe_reg; // SR strobe pin MCU register
fio_bit _data; // shift register data pin
fio_register _data_reg; // SR data pin MCU register
fio_bit _clk; // shift register clock pin
fio_register _clk_reg; // SR clock pin MCU register
uint8_t _En; // LCD expander word for enable pin
uint8_t _Rw; // LCD expander word for R/W pin
uint8_t _Rs; // LCD expander word for Register Select pin
uint8_t _data_pins[4]; // LCD data lines
uint8_t _backlightPinMask; // Backlight IO pin mask
uint8_t _backlightStsMask; // Backlight status mask
};
#endif
LiquidCrystal_SR3W
Definition: LiquidCrystal_SR3W.h:78
LiquidCrystal_SR3W::LiquidCrystal_SR3W
LiquidCrystal_SR3W(uint8_t data, uint8_t clk, uint8_t strobe)
Definition: LiquidCrystal_SR3W.cpp:148
LCD
Definition: LCD.h:199
LiquidCrystal_SR3W::setBacklight
void setBacklight(uint8_t value)
Definition: LiquidCrystal_SR3W.cpp:206
LiquidCrystal_SR3W::send
virtual void send(uint8_t value, uint8_t mode)
Definition: LiquidCrystal_SR3W.cpp:177
LiquidCrystal_SR3W::setBacklightPin
void setBacklightPin(uint8_t value, t_backlightPol pol)
Definition: LiquidCrystal_SR3W.cpp:198