COSA
An Object-Oriented Platform for Arduino Programming
HD44780::SR4W Class Reference

#include <HD44780.hh>

Inheritance diagram for HD44780::SR4W:
Inheritance graph
Collaboration diagram for HD44780::SR4W:
Collaboration graph

Public Member Functions

 SR4W (Board::DigitalPin sda=Board::D7, Board::DigitalPin scl=Board::D6, Board::DigitalPin en=Board::D5, Board::DigitalPin bt=Board::D4)
 
virtual bool setup ()
 
virtual void write4b (uint8_t data)
 
virtual void write8b (uint8_t data)
 
virtual void set_mode (uint8_t flag)
 
virtual void set_backlight (uint8_t flag)
 
virtual void write8n (const void *buf, size_t size)
 

Protected Attributes

OutputPin m_sda
 Serial data output. More...
 
OutputPin m_scl
 Serial clock. More...
 
OutputPin m_en
 Starts data read/write. More...
 
OutputPin m_bt
 Backlight control. More...
 
uint8_t m_rs
 Command/Data select. More...
 

Static Protected Attributes

static const uint16_t SHORT_EXEC_TIME = 16
 

Detailed Description

HD44780 (LCD-II) Dot Matix Liquid Crystal Display Controller/Driver Shift Register 4-Wire/8-bit Port, 74HC595 (SR[pin]), with digital output pins.

Circuit

74HC595 (VCC)
+----U----+ |
(LCD D1)------------1-|Q1 VCC|-16-+
(LCD D2)------------2-|Q2 Q0|-15-----------(LCD D0)
(LCD D3)------------3-|Q3 /OE|-13-----------(GND)
(LCD D4)------------4-|Q4 SER|-14-----------(SDA/D7)
(LCD D5)------------5-|Q5 RCLK|-12-----------(EN/D5)
(LCD D6)------------6-|Q6 SCLK|-11-----------(SCL/D6)
(LCD D7)------------7-|Q7 /MR|-10-----------(VCC)
+-8-|GND Q6'|-9
| +---------+
| 0.1uF
(GND)-----||----(VCC)
(LCD RS)---------------------------------------(SDA/D7)
(LCD EN)---------------------------------------(EN/D5)
(LCD BT)---------------------------------------(BT/D4)
(LCD RW)---------------------------------------(GND)
(LCD K)----------------------------------------(GND)
(LCD A)-----------------[330]------------------(VCC)

Alternative circuit with 74HC164.

74HC164 (VCC)
+----U----+ |
(D7/SDA)----------+-1-|DSA VCC|-14-+
+-2-|DSB Q7|-13--------(LCD D7)
(LCD D4)------------3-|Q0 Q6|-12--------(LCD D6)
(LCD D5)------------4-|Q1 Q5|-11--------(LCD D5)
(LCD D6)------------5-|Q2 Q4|-10--------(LCD D4)
(LCD D7)------------6-|Q3 /MR|--9-----------(VCC)
+-7-|GND CP|--8--------(SCL/D6)
| +---------+
| 0.1uF
(GND)-----||----(VCC)
(LCD RS)---------------------------------------(SDA/D7)
(LCD EN)---------------------------------------(EN/D5)
(LCD BT)---------------------------------------(BT/D4)
(LCD RW)---------------------------------------(GND)
(LCD K)----------------------------------------(GND)
(LCD A)-----------------[330]------------------(VCC)

Performance

Delay required even when using Cosa serial write. No need for SPI. SCL/SDA can still be connected to other inputs. The Backlight control pin (BT) can be removed if always on.

Acknowledgement

Inspired by AVR2LCD, a solution by Frank Henriquez. The original 74HC164 based design is by Stefan Heinzmann and Marc Simons. http://frank.bol.ucla.edu/avr2lcd.htm http://web.archive.org/web/20100210142839/ http://home.iae.nl/users/pouweha/lcd/lcd_examp.shtml#_3

Definition at line 763 of file HD44780.hh.

Constructor & Destructor Documentation

Construct HD44780 4-wire/8-bit serial port connected to given data, clock, enable and backlight control pins.

Parameters
[in]sdaserial data pin (Default D7, Tiny/D1)
[in]sclserial clock pin (Default D6, Tiny/D2)
[in]enenable pulse (Default D5, Tiny/D3)
[in]btbacklight control (Default D4, Tiny/D4)

Definition at line 23 of file HD44780_SR4W.cpp.

Member Function Documentation

void HD44780::SR4W::set_backlight ( uint8_t  flag)
virtual

Set backlight on/off using bt pin.

Parameters
[in]flag.

Implements HD44780::IO.

Definition at line 66 of file HD44780_SR4W.cpp.

void HD44780::SR4W::set_mode ( uint8_t  flag)
virtual

Set instruction/data mode using given rs pin; zero for instruction, non-zero for data mode.

Parameters
[in]flag.

Implements HD44780::IO.

Definition at line 60 of file HD44780_SR4W.cpp.

bool HD44780::SR4W::setup ( )
virtual

Initiate port for 8-bit serial mode. Returns true(1).

Returns
true(1).

Implements HD44780::IO.

Definition at line 36 of file HD44780_SR4W.cpp.

void HD44780::SR4W::write4b ( uint8_t  data)
virtual

Write LSB nibble to display using serial port.

Parameters
[in]data(4b) to write.

Implements HD44780::IO.

Definition at line 42 of file HD44780_SR4W.cpp.

void HD44780::SR4W::write8b ( uint8_t  data)
virtual

Write byte (8bit) to display.

Parameters
[in]data(8b) to write.

Reimplemented from HD44780::IO.

Definition at line 48 of file HD44780_SR4W.cpp.

void HD44780::IO::write8n ( const void *  buf,
size_t  size 
)
virtualinherited

Write character buffer to display.

Parameters
[in]bufpointer to buffer.
[in]sizenumber of bytes in buffer.

Reimplemented in ERM1602_5, Adafruit_I2C_LCD_Backpack, DFRobot_IIC_LCD_Module, MJKDZ_LCD_Module, and SainSmart_LCD2004.

Definition at line 31 of file HD44780_IO.cpp.

Member Data Documentation

OutputPin HD44780::SR4W::m_bt
protected

Backlight control.

Definition at line 828 of file HD44780.hh.

OutputPin HD44780::SR4W::m_en
protected

Starts data read/write.

Definition at line 827 of file HD44780.hh.

uint8_t HD44780::SR4W::m_rs
protected

Command/Data select.

Definition at line 829 of file HD44780.hh.

OutputPin HD44780::SR4W::m_scl
protected

Serial clock.

Definition at line 826 of file HD44780.hh.

OutputPin HD44780::SR4W::m_sda
protected

Serial data output.

Definition at line 825 of file HD44780.hh.

const uint16_t HD44780::SR4W::SHORT_EXEC_TIME = 16
staticprotected

Execution time delay (us).

Definition at line 823 of file HD44780.hh.


The documentation for this class was generated from the following files: