PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
PropWare::HD44780 Class Reference

Support for the common "character LCD" modules using the HD44780 controller for the Parallax Propeller. More...

#include <PropWare/hmi/output/hd44780.h>

+ Inheritance diagram for PropWare::HD44780:
+ Collaboration diagram for PropWare::HD44780:

Public Types

enum  BusWidth {
  BusWidth::WIDTH4 = 4,
  BusWidth::WIDTH8 = 8
}
 LCD databus width. More...
 
enum  Dimensions {
  Dimensions::DIM_8x1,
  Dimensions::DIM_8x2,
  Dimensions::DIM_8x4,
  Dimensions::DIM_16x1_1,
  Dimensions::DIM_16x1_2,
  Dimensions::DIM_16x2,
  Dimensions::DIM_16x4,
  Dimensions::DIM_20x1,
  Dimensions::DIM_20x2,
  Dimensions::DIM_20x4,
  Dimensions::DIM_24x1,
  Dimensions::DIM_24x2,
  Dimensions::DIM_40x1,
  Dimensions::DIM_40x2
}
 Supported LCD dimensions; Used for determining cursor placement. More...
 
enum  ErrorCode {
  NO_ERROR = 0,
  BEG_ERROR = HD44780_ERRORS_BASE,
  INVALID_CTRL_SGNL = HD44780::BEG_ERROR,
  INVALID_DIMENSIONS,
  END_ERROR = HD44780::INVALID_DIMENSIONS
}
 

Public Member Functions

 HD44780 (const Pin::Mask lsbDataPin, const Pin::Mask rs, const Pin::Mask rw, const Pin::Mask en, const HD44780::BusWidth bitMode, const HD44780::Dimensions dimensions)
 Construct an LCD object. More...
 
void start ()
 Initialize an HD44780 LCD display. More...
 
void clear (void)
 Clear the LCD display and return cursor to home.
 
void move (const uint8_t row, const uint8_t col)
 Move the cursor to a specified column and row. More...
 
void puts (const char string[])
 Send a null-terminated character array. Though this method could be created using put_char, some objects (such as PropWare::UART), have optimized methods for sending a string and PrintCapable::puts can utilize them. More...
 
void put_char (const char c)
 Print a single character. More...
 
void cmd (const uint8_t command) const
 Send a control command to the LCD module. More...
 

Static Public Member Functions

static void print_error_str (const Printer &printer, const HD44780::ErrorCode err)
 

Static Public Attributes

static const uint8_t TAB_WIDTH = 4
 
Commands
Note
Must be combined with arguments below to create a parameter for the HD44780
static const uint8_t CLEAR = BIT_0
 
static const uint8_t RET_HOME = BIT_1
 
static const uint8_t ENTRY_MODE_SET = BIT_2
 
static const uint8_t DISPLAY_CTRL = BIT_3
 
static const uint8_t SHIFT = BIT_4
 
static const uint8_t FUNCTION_SET = BIT_5
 
static const uint8_t SET_CGRAM_ADDR = BIT_6
 
static const uint8_t SET_DDRAM_ADDR = BIT_7
 
Entry mode arguments
static const uint8_t SHIFT_INC = BIT_1
 
static const uint8_t SHIFT_EN = BIT_0
 
Display control arguments
static const uint8_t DISPLAY_PWR = BIT_2
 
static const uint8_t CURSOR = BIT_1
 
static const uint8_t BLINK = BIT_0
 
Cursor/display shift arguments
static const uint8_t SHIFT_DISPLAY = BIT_3
 
static const uint8_t SHIFT_RIGHT = BIT_2
 
Function set arguments
static const uint8_t FUNC_8BIT_MODE = BIT_4
 
static const uint8_t FUNC_2LINE_MODE = BIT_3
 
static const uint8_t FUNC_5x10_CHAR = BIT_2
 

Detailed Description

Support for the common "character LCD" modules using the HD44780 controller for the Parallax Propeller.

Note
Does not natively support 40x4 or 24x4 character displays
Examples
HD44780_Demo.cpp.

Definition at line 43 of file hd44780.h.

Member Enumeration Documentation

◆ BusWidth

LCD databus width.

Enumerator
WIDTH4 

4-bit mode

WIDTH8 

8-bit mode

Definition at line 48 of file hd44780.h.

◆ Dimensions

Supported LCD dimensions; Used for determining cursor placement.

Note
There are two variations of 16x1 character LCDs; if you're unsure which version you have, try 16x1_1 first, it is more common. 16x1_1 uses both DDRAM lines of the controller, 8-characters on each line; 16x1_2 places all 16 characters are a single line of DDRAM.
Enumerator
DIM_8x1 

8x1

DIM_8x2 

8x2

DIM_8x4 

8x2

DIM_16x1_1 

16x1 mode 1

DIM_16x1_2 

16x1 mode 2

DIM_16x2 

16x2

DIM_16x4 

16x2

DIM_20x1 

20x1

DIM_20x2 

20x2

DIM_20x4 

20x2

DIM_24x1 

24x1

DIM_24x2 

24x2

DIM_40x1 

40x1

DIM_40x2 

40x2

Definition at line 62 of file hd44780.h.

◆ ErrorCode

Error codes - Proceeded by SD, SPI

Enumerator
NO_ERROR 

No error

BEG_ERROR 

First HD44780 error

INVALID_CTRL_SGNL 

HD44780 Error 0

INVALID_DIMENSIONS 

HD44780 Error 1

END_ERROR 

Last HD44780 error

Definition at line 87 of file hd44780.h.

Constructor & Destructor Documentation

◆ HD44780()

PropWare::HD44780::HD44780 ( const Pin::Mask  lsbDataPin,
const Pin::Mask  rs,
const Pin::Mask  rw,
const Pin::Mask  en,
const HD44780::BusWidth  bitMode,
const HD44780::Dimensions  dimensions 
)

Construct an LCD object.

Parameters
[in]lsbDataPinPin mask for the least significant pin of the data port
[in]rsPin mask connected to the register select control pin of the LCD driver
[in]rwPin mask connected to the read/write control pin of the LCD driver
[in]enPin mask connected to the enable control pin of the LCD driver
[in]bitModeSelect between whether the parallel bus is using 4 or 8 pins
[in]dimensionsDimensions of your LCD device. Most common is HD44780::DIM_16x2

Definition at line 189 of file hd44780.h.

+ Here is the call graph for this function:

Member Function Documentation

◆ cmd()

void PropWare::HD44780::cmd ( const uint8_t  command) const

Send a control command to the LCD module.

Parameters
[in]command8-bit command to send to the LCD

Definition at line 362 of file hd44780.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ move()

void PropWare::HD44780::move ( const uint8_t  row,
const uint8_t  col 
)

Move the cursor to a specified column and row.

Parameters
[in]rowZero-indexed row to place the cursor
[in]colZero indexed column to place the cursor

Definition at line 286 of file hd44780.h.

+ Here is the caller graph for this function:

◆ put_char()

void PropWare::HD44780::put_char ( const char  c)
virtual

Print a single character.

Parameters
[in]cIndividual char to be printed

Implements PropWare::PrintCapable.

Definition at line 324 of file hd44780.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ puts()

void PropWare::HD44780::puts ( const char  string[])
virtual

Send a null-terminated character array. Though this method could be created using put_char, some objects (such as PropWare::UART), have optimized methods for sending a string and PrintCapable::puts can utilize them.

Precondition
string[] must be terminated with a null terminator
Parameters
[in]string[]Array of data words with the final word being 0 - the null terminator

Implements PropWare::PrintCapable.

Definition at line 315 of file hd44780.h.

+ Here is the call graph for this function:

◆ start()

void PropWare::HD44780::start ( )

Initialize an HD44780 LCD display.

Note
A 250 ms delay is called while the LCD does internal initialization
Returns
Returns 0 upon success, otherwise error code

Definition at line 217 of file hd44780.h.

Member Data Documentation

◆ FUNC_2LINE_MODE

const uint8_t PropWare::HD44780::FUNC_2LINE_MODE = BIT_3
static

0 = "1-line" mode - use 2-line mode for 2- and 4-line displays

Definition at line 168 of file hd44780.h.

◆ FUNC_5x10_CHAR

const uint8_t PropWare::HD44780::FUNC_5x10_CHAR = BIT_2
static

0 = 5x8 dot mode

Definition at line 172 of file hd44780.h.

◆ FUNC_8BIT_MODE

const uint8_t PropWare::HD44780::FUNC_8BIT_MODE = BIT_4
static

0 = 4-bit mode

Definition at line 164 of file hd44780.h.

◆ TAB_WIDTH

const uint8_t PropWare::HD44780::TAB_WIDTH = 4
static

Number of spaces inserted for '\t'

Definition at line 115 of file hd44780.h.


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