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

#include <HD44780.hh>

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

Classes

class  IO
 
class  Port4b
 
class  SR3W
 
class  SR3WSPI
 
class  SR4W
 

Public Types

enum  {
  CLEAR_DISPLAY = 0x01, RETURN_HOME = 0x02, ENTRY_MODE_SET = 0x04, CONTROL_SET = 0x08,
  SHIFT_SET = 0x10, FUNCTION_SET = 0x20, SET_CGRAM_ADDR = 0x40, SET_CGRAM_MASK = 0x3f,
  SET_DDRAM_ADDR = 0x80, SET_DDRAM_MASK = 0x7f, BIAS_RESISTOR_SET = 0x04, BIAS_RESISTOR_MASK = 0x03,
  COM_SEG_SET = 0x40, COM_SET_MASK = 0x0f, SET_DDATA_LENGTH = 0x80, SET_DDATA_MASK = 0x7f
}
 
enum  { DISPLAY_SHIFT = 0x01, INCREMENT = 0x02, DECREMENT = 0x00 }
 
enum  { BLINK_ON = 0x01, CURSOR_ON = 0x02, DISPLAY_ON = 0x04 }
 
enum  { MOVE_LEFT = 0x00, MOVE_RIGHT = 0x04, CURSOR_MODE = 0x00, DISPLAY_MOVE = 0x08 }
 
enum  {
  DATA_LENGTH_4BITS = 0x00, DATA_LENGTH_8BITS = 0x10, NR_LINES_1 = 0x00, NR_LINES_2 = 0x08,
  FONT_5X8DOTS = 0x00, FONT_5X10DOTS = 0x04, BASIC_SET = 0x00, EXTENDED_SET = 0x04
}
 
enum  TextMode { NORMAL_TEXT_MODE = 0x00, INVERTED_TEXT_MODE = 0xff }
 

Public Member Functions

 HD44780 (IO *io, uint8_t width=16, uint8_t height=2)
 
virtual bool begin ()
 
virtual bool end ()
 
virtual void backlight_on ()
 
virtual void backlight_off ()
 
virtual void display_on ()
 
virtual void display_off ()
 
void display_scroll_left ()
 
void display_scroll_right ()
 
virtual void display_clear ()
 
void line_clear ()
 
void cursor_home ()
 
void cursor_underline_on ()
 
void cursor_underline_off ()
 
void cursor_blink_on ()
 
void cursor_blink_off ()
 
virtual void set_cursor (uint8_t x, uint8_t y)
 
void text_flow_left_to_right ()
 
void text_flow_right_to_left ()
 
void text_scroll_left_adjust ()
 
void text_scroll_right_adjust ()
 
void set_custom_char (uint8_t id, const uint8_t *bitmap)
 
void set_custom_char_P (uint8_t id, const uint8_t *bitmap)
 
virtual int putchar (char c)
 
virtual int write (const void *buf, size_t size)
 
void write (uint8_t data)
 
void set (uint8_t &cmd, uint8_t mask)
 
void clear (uint8_t &cmd, uint8_t mask)
 
void set_data_mode ()
 
void set_instruction_mode ()
 
virtual void display_contrast (uint8_t level)
 
virtual void display_normal ()
 
virtual void display_inverse ()
 
void get_cursor (uint8_t &x, uint8_t &y) const
 
uint8_t get_tab_step () const
 
void set_tab_step (uint8_t step)
 
TextMode text_mode (TextMode mode)
 
void non_blocking ()
 
void blocking ()
 
bool is_blocking () const
 
void eol (Mode mode)
 
Mode eol () const
 
virtual int available ()
 
virtual int room ()
 
virtual int puts (const char *s)
 
virtual int puts (str_P s)
 
virtual int write (const iovec_t *vec)
 
virtual int write_P (const void *buf, size_t size)
 
virtual int peekchar ()
 
virtual int peekchar (char c)
 
virtual int getchar ()
 
virtual char * gets (char *s, size_t count)
 
virtual int read (void *buf, size_t size)
 
virtual int read (iovec_t *vec)
 
virtual int flush ()
 
virtual void empty ()
 

Public Attributes

const uint8_t WIDTH
 
const uint8_t HEIGHT
 
IOm_io
 IO port handler. More...
 
uint8_t m_mode
 Entry mode. More...
 
uint8_t m_cntl
 Control. More...
 
uint8_t m_func
 Function set. More...
 
const uint8_t * m_offset
 Row offset table. More...
 

Static Public Attributes

static const uint8_t BITMAP_MAX = 8
 
static const uint16_t LONG_EXEC_TIME = 1600
 
static const uint16_t POWER_ON_TIME = 48
 
static const uint16_t INIT0_TIME = 4500
 
static const uint16_t INIT1_TIME = 150
 
static const uint8_t offset0 []
 
static const uint8_t offset1 [] = { 0x00, 0x40, 0x10, 0x50 }
 

Protected Attributes

uint8_t m_x
 Cursor position x. More...
 
uint8_t m_y
 Cursor position y. More...
 
uint8_t m_tab
 Tab step. More...
 
bool m_blocking
 
Mode m_eol
 

Detailed Description

HD44780 (LCD-II) Dot Matix Liquid Crystal Display Controller/Driver for LCD/IOStream access. Binding to trace, etc. Supports simple text scroll, cursor, and handling of special characters such as carriage- return, form-feed, back-space, horizontal tab and new-line.

References

  1. Product Specification, Hitachi, HD4478U, ADE-207-272(Z), '99.9, Rev. 0.0.

Definition at line 37 of file HD44780.hh.

Member Enumeration Documentation

anonymous enum

Instructions (Table 6, pp. 24), RS(0), RW(0).

Enumerator
CLEAR_DISPLAY 

Clears entrire display and return home.

RETURN_HOME 

Sets DDRAM 0 in address counter.

ENTRY_MODE_SET 

Sets cursor move direction and display shift.

CONTROL_SET 

Set display, cursor and blinking controls.

SHIFT_SET 

Set cursor and shifts display.

FUNCTION_SET 

Sets interface data length, line and font.

SET_CGRAM_ADDR 

Sets CGRAM address.

SET_CGRAM_MASK 
  • Mask (6-bit).
SET_DDRAM_ADDR 

Sets DDRAM address.

SET_DDRAM_MASK 
  • Mask (7-bit).
BIAS_RESISTOR_SET 

Bias resistor select.

BIAS_RESISTOR_MASK 
  • Mask (2-bit).
COM_SEG_SET 

COM SEG direction select.

COM_SET_MASK 
  • mask (4 bit).
SET_DDATA_LENGTH 

Set display data length.

SET_DDATA_MASK 
  • mask (7 bit, 0..79 => 1..80).

Definition at line 843 of file HD44780.hh.

anonymous enum

ENTRY_MODE_SET attributes.

Enumerator
DISPLAY_SHIFT 

Shift the entire display not cursor.

INCREMENT 

Increment (right) on write.

DECREMENT 

Decrement (left) on write.

Definition at line 865 of file HD44780.hh.

anonymous enum

CONTROL_SET attributes.

Enumerator
BLINK_ON 

The character indicated by cursor blinks.

CURSOR_ON 

The cursor is displayed.

DISPLAY_ON 

The display is on.

Definition at line 874 of file HD44780.hh.

anonymous enum

SHIFT_SET attributes.

Enumerator
MOVE_LEFT 

Moves cursor and shifts display.

MOVE_RIGHT 

without changing DDRAM contents.

CURSOR_MODE 
DISPLAY_MOVE 

Definition at line 883 of file HD44780.hh.

anonymous enum

FUNCTION_SET attributes.

Enumerator
DATA_LENGTH_4BITS 

Sets the interface data length, 4-bit or.

DATA_LENGTH_8BITS 
  • 8-bit.
NR_LINES_1 

Sets the number of display lines, 1 or.

NR_LINES_2 
  • 2.
FONT_5X8DOTS 

Sets the character font, 5X8 dots or.

FONT_5X10DOTS 
  • 5X10 dots.
BASIC_SET 

Sets basic instruction set.

EXTENDED_SET 
  • extended instruction set.

Definition at line 893 of file HD44780.hh.

enum LCD::Device::TextMode
inherited

Text display mode.

Enumerator
NORMAL_TEXT_MODE 
INVERTED_TEXT_MODE 

Definition at line 45 of file LCD.hh.

Constructor & Destructor Documentation

HD44780::HD44780 ( IO io,
uint8_t  width = 16,
uint8_t  height = 2 
)
inline

Construct HD44780 LCD connected to given io port handler. The display is initiated when calling begin().

Parameters
[in]iohandler.
[in]widthof display, characters per line (Default 16).
[in]heightof display, number of lines (Default 2).

Definition at line 108 of file HD44780.hh.

Member Function Documentation

int IOStream::Device::available ( )
virtualinherited

Number of bytes available (possible to read).

Returns
bytes.

Reimplemented in W5200::Driver, W5500::Driver, W5100::Driver, Soft::UART, UART, IOBuffer< SIZE >, and CC3000::Driver.

Definition at line 24 of file IOStream_Device.cpp.

void HD44780::backlight_off ( )
virtual

Turn display backlight off.

Reimplemented from LCD::Device.

Definition at line 80 of file HD44780.cpp.

void HD44780::backlight_on ( )
virtual

Turn display backlight on.

Reimplemented from LCD::Device.

Definition at line 74 of file HD44780.cpp.

bool HD44780::begin ( )
virtual

Start display for text output. Returns true if successful otherwise false.

Returns
boolean.

Implements LCD::Device.

Definition at line 30 of file HD44780.cpp.

void IOStream::Device::blocking ( )
inlineinherited

Set blocking mode.

Definition at line 85 of file IOStream.hh.

void HD44780::clear ( uint8_t &  cmd,
uint8_t  mask 
)
inline

Clear display attribute and update driver mirror variable.

Parameters
[in,out]cmdcommand variable.
[in]maskfunction.

Definition at line 941 of file HD44780.hh.

void HD44780::cursor_blink_off ( )
inline

Turn cursor blink off.

Definition at line 225 of file HD44780.hh.

void HD44780::cursor_blink_on ( )
inline

Turn cursor blink on.

Definition at line 216 of file HD44780.hh.

void HD44780::cursor_home ( )

Move cursor to home position(0, 0) .

Definition at line 108 of file HD44780.cpp.

void HD44780::cursor_underline_off ( )
inline

Turn underline cursor off.

Definition at line 207 of file HD44780.hh.

void HD44780::cursor_underline_on ( )
inline

Turn underline cursor on.

Definition at line 198 of file HD44780.hh.

void HD44780::display_clear ( )
virtual

Clear display and move cursor to home(0, 0).

Implements LCD::Device.

Definition at line 98 of file HD44780.cpp.

virtual void LCD::Device::display_contrast ( uint8_t  level)
inlinevirtualinherited

Set display contrast level.

Parameters
[in]levelto set.

Reimplemented in ST7565, PCD8544, and MAX72XX.

Definition at line 93 of file LCD.hh.

virtual void LCD::Device::display_inverse ( )
inlinevirtualinherited

Display inverse mode.

Reimplemented in ST7565, and PCD8544.

Definition at line 120 of file LCD.hh.

virtual void LCD::Device::display_normal ( )
inlinevirtualinherited

Display normal mode.

Reimplemented in ST7565, and PCD8544.

Definition at line 114 of file LCD.hh.

void HD44780::display_off ( )
virtual

Turn display off.

Implements LCD::Device.

Definition at line 92 of file HD44780.cpp.

void HD44780::display_on ( )
virtual

Turn display on.

Implements LCD::Device.

Definition at line 86 of file HD44780.cpp.

void HD44780::display_scroll_left ( )
inline

Set display scrolling left.

Definition at line 161 of file HD44780.hh.

void HD44780::display_scroll_right ( )
inline

Set display scrolling right.

Definition at line 170 of file HD44780.hh.

void IOStream::Device::empty ( )
virtualinherited

Empty internal device buffers.

Reimplemented in Soft::UART, UART, and IOBuffer< SIZE >.

Definition at line 175 of file IOStream_Device.cpp.

bool HD44780::end ( )
virtual

Stop display and power down. Returns true if successful otherwise false.

Implements LCD::Device.

Definition at line 67 of file HD44780.cpp.

void IOStream::Device::eol ( Mode  mode)
inlineinherited

Set end of line mode.

Parameters
[in]modefor end of line.

Definition at line 103 of file IOStream.hh.

Mode IOStream::Device::eol ( ) const
inlineinherited

Get end of line mode.

Returns
mode.

Definition at line 112 of file IOStream.hh.

int IOStream::Device::flush ( )
virtualinherited

Flush internal device buffers. Wait for device to become idle.

Returns
zero(0) or negative error code.

Reimplemented in W5200::Driver, W5500::Driver, W5100::Driver, UART, IOBuffer< SIZE >, CC3000::Driver, and WIO.

Definition at line 169 of file IOStream_Device.cpp.

void LCD::Device::get_cursor ( uint8_t &  x,
uint8_t &  y 
) const
inlineinherited

Get current cursor position.

Parameters
[out]x.
[out]y.

Definition at line 133 of file LCD.hh.

uint8_t LCD::Device::get_tab_step ( ) const
inlineinherited

Get tab step.

Returns
tab step.

Definition at line 152 of file LCD.hh.

int IOStream::Device::getchar ( )
virtualinherited

Read character from device.

Returns
character or EOF(-1).

Reimplemented in FAT16::File, CFFS::File, Soft::UART, UART, IOBuffer< SIZE >, and Socket.

Definition at line 112 of file IOStream_Device.cpp.

char * IOStream::Device::gets ( char *  s,
size_t  count 
)
virtualinherited

Read string terminated by new-line or until size into given string buffer. Returns pointer to string or NULL if empty line.

Parameters
[in]sstring buffer to read into.
[in]countmax number of bytes to read.
Returns
string pointer or NULL.

Definition at line 118 of file IOStream_Device.cpp.

bool IOStream::Device::is_blocking ( ) const
inlineinherited

Is blocking mode?

Returns
bool.

Definition at line 94 of file IOStream.hh.

void HD44780::line_clear ( )
inline

Clear to end of line.

Definition at line 185 of file HD44780.hh.

void IOStream::Device::non_blocking ( )
inlineinherited

Set non-blocking mode.

Definition at line 77 of file IOStream.hh.

int IOStream::Device::peekchar ( )
virtualinherited

Peek at the next character from device.

Returns
character or EOF(-1).

Reimplemented in Soft::UART, UART, and IOBuffer< SIZE >.

Definition at line 99 of file IOStream_Device.cpp.

int IOStream::Device::peekchar ( char  c)
virtualinherited

Peek for the given character in device buffer. Return number of characters or EOF(-1).

Parameters
[in]ccharacter to peek for.
Returns
available or EOF(-1).

Reimplemented in Soft::UART, UART, and IOBuffer< SIZE >.

Definition at line 105 of file IOStream_Device.cpp.

int HD44780::putchar ( char  c)
virtual

Write character to display. Handles carriage-return-line-feed, back- space, alert, horizontal tab and form-feed. Returns character or EOF on error.

Parameters
[in]ccharacter to write.
Returns
character written or EOF(-1).

Reimplemented from IOStream::Device.

Definition at line 152 of file HD44780.cpp.

int IOStream::Device::puts ( const char *  s)
virtualinherited

Write null terminated string to device. Terminating null is not written.

Parameters
[in]sstring to write.
Returns
zero(0) or negative error code.

Definition at line 43 of file IOStream_Device.cpp.

int IOStream::Device::puts ( str_P  s)
virtualinherited

Write null terminated string from program memory to device. Terminating null is not written.

Parameters
[in]sstring in program memory to write.
Returns
zero(0) or negative error code.

Definition at line 54 of file IOStream_Device.cpp.

int IOStream::Device::read ( void *  buf,
size_t  size 
)
virtualinherited

Read data to given buffer with given size from device.

Parameters
[in]bufbuffer to read into.
[in]sizenumber of bytes to read.
Returns
number of bytes read or EOF(-1).

Reimplemented in FAT16::File, W5200::Driver, W5500::Driver, W5100::Driver, CFFS::File, Socket, and CC3000::Driver.

Definition at line 144 of file IOStream_Device.cpp.

int IOStream::Device::read ( iovec_t vec)
virtualinherited

Read data to given buffers in null terminated io vector.

Parameters
[in]vecio vector with buffers to read into.
Returns
number of bytes read or EOF(-1).

Definition at line 157 of file IOStream_Device.cpp.

int IOStream::Device::room ( )
virtualinherited

Number of bytes room (write without blocking).

Returns
bytes.

Reimplemented in W5200::Driver, W5500::Driver, W5100::Driver, UART, IOBuffer< SIZE >, CC3000::Driver, and WIO.

Definition at line 30 of file IOStream_Device.cpp.

void HD44780::set ( uint8_t &  cmd,
uint8_t  mask 
)
inline

Set display attribute and update driver mirror variable.

Parameters
[in,out]cmdcommand variable.
[in]maskfunction.

Definition at line 930 of file HD44780.hh.

void HD44780::set_cursor ( uint8_t  x,
uint8_t  y 
)
virtual

Set cursor position to given position.

Parameters
[in]x.
[in]y.

Implements LCD::Device.

Definition at line 117 of file HD44780.cpp.

void HD44780::set_custom_char ( uint8_t  id,
const uint8_t *  bitmap 
)

Set custom character bitmap for given identity (0..7).

Parameters
[in]idcharacter.
[in]bitmappointer to bitmap.

Definition at line 128 of file HD44780.cpp.

void HD44780::set_custom_char_P ( uint8_t  id,
const uint8_t *  bitmap 
)

Set custom character bitmap to given identity (0..7). The bitmap should be stored in program memory.

Parameters
[in]idcharacter.
[in]bitmappointer to program memory bitmap.

Definition at line 140 of file HD44780.cpp.

void HD44780::set_data_mode ( )
inline

Set communication in data stream mode.

Definition at line 950 of file HD44780.hh.

void HD44780::set_instruction_mode ( )
inline

Set communication in instruction stream mode.

Definition at line 959 of file HD44780.hh.

void LCD::Device::set_tab_step ( uint8_t  step)
inlineinherited

Set tab step to given value.

Parameters
[in]steptab.

Definition at line 161 of file LCD.hh.

void HD44780::text_flow_left_to_right ( )
inline

Set text flow left-to-right.

Definition at line 242 of file HD44780.hh.

void HD44780::text_flow_right_to_left ( )
inline

Set text flow right-to-left.

Definition at line 251 of file HD44780.hh.

TextMode LCD::Device::text_mode ( TextMode  mode)
inlineinherited

Set text mode. Return previous text mode.

Parameters
[in]modenew text mode.
Returns
previous text mode.

Definition at line 171 of file LCD.hh.

void HD44780::text_scroll_left_adjust ( )
inline

Set text scroll left adjust.

Definition at line 260 of file HD44780.hh.

void HD44780::text_scroll_right_adjust ( )
inline

Set text scroll right adjust.

Definition at line 269 of file HD44780.hh.

int IOStream::Device::write ( const iovec_t vec)
virtualinherited

Write data from buffers in null terminated io vector.

Parameters
[in]vecio vector with buffers to write.
Returns
number of bytes written or EOF(-1).

Definition at line 87 of file IOStream_Device.cpp.

int HD44780::write ( const void *  buf,
size_t  size 
)
virtual

Write data from buffer with given size to device.

Parameters
[in]bufbuffer to write.
[in]sizenumber of bytes to write.
Returns
number of bytes written or EOF(-1).

Reimplemented from IOStream::Device.

Definition at line 219 of file HD44780.cpp.

void HD44780::write ( uint8_t  data)
inline

Write data or command to display.

Parameters
[in]datato write.

Definition at line 919 of file HD44780.hh.

int IOStream::Device::write_P ( const void *  buf,
size_t  size 
)
virtualinherited

Write data from buffer in program memory with given size to device.

Parameters
[in]bufbuffer to write.
[in]sizenumber of bytes to write.
Returns
number of bytes written or EOF(-1).

Reimplemented in CFFS::File, Socket, and CC3000::Driver.

Definition at line 76 of file IOStream_Device.cpp.

Member Data Documentation

const uint8_t HD44780::BITMAP_MAX = 8
static

Max size of custom character font bitmap.

Definition at line 93 of file HD44780.hh.

const uint8_t HD44780::HEIGHT

Display height (lines).

Definition at line 99 of file HD44780.hh.

const uint16_t HD44780::INIT0_TIME = 4500
static

Definition at line 837 of file HD44780.hh.

const uint16_t HD44780::INIT1_TIME = 150
static

Definition at line 838 of file HD44780.hh.

const uint16_t HD44780::LONG_EXEC_TIME = 1600
static

Bus Timing Characteristics (in micro-seconds), fig. 25, pp. 50.

Definition at line 835 of file HD44780.hh.

bool IOStream::Device::m_blocking
protectedinherited

Blocking state

Definition at line 248 of file IOStream.hh.

uint8_t HD44780::m_cntl

Control.

Definition at line 911 of file HD44780.hh.

Mode IOStream::Device::m_eol
protectedinherited

End of line mode

Definition at line 251 of file IOStream.hh.

uint8_t HD44780::m_func

Function set.

Definition at line 912 of file HD44780.hh.

IO* HD44780::m_io

IO port handler.

Display pins and state (mirror of device registers).

Definition at line 909 of file HD44780.hh.

uint8_t HD44780::m_mode

Entry mode.

Definition at line 910 of file HD44780.hh.

const uint8_t* HD44780::m_offset

Row offset table.

Definition at line 913 of file HD44780.hh.

uint8_t LCD::Device::m_tab
protectedinherited

Tab step.

Definition at line 182 of file LCD.hh.

uint8_t LCD::Device::m_x
protectedinherited

Cursor position x.

Definition at line 180 of file LCD.hh.

uint8_t LCD::Device::m_y
protectedinherited

Cursor position y.

Definition at line 181 of file LCD.hh.

const uint8_t HD44780::offset0[]
static

Row offset tables for display dimensions (16X1, 16X2, 16X4, 20X4).

Definition at line 905 of file HD44780.hh.

const uint8_t HD44780::offset1 = { 0x00, 0x40, 0x10, 0x50 }
static

Definition at line 906 of file HD44780.hh.

const uint16_t HD44780::POWER_ON_TIME = 48
static

Definition at line 836 of file HD44780.hh.

const uint8_t HD44780::WIDTH

Display width (characters per line).

Definition at line 96 of file HD44780.hh.


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