HWA
Bare metal programming with style
HD44780 LCD controller

Detailed Description

This class implements a HD44780 LCD controller.

Header file:

Constructor



HW_HD44780(...) declares a HD44780 object. You must provide:

#define PCF HW_PCF8574( interface, twi0, address, 0x27 )
#define LCD HW_HD44780( lines, 2, \
cols, 16, \
e, (PCF, 1, 2), \
rs, (PCF, 1, 0), \
rw, (PCF, 1, 1), \
data, (PCF, 4, 4) )

Currently, HWA supports only the driving of the HD44780 in 4-bit mode through a single dedicated I²C bus expander PCF8574.

The implementation of this device focuses on code size rather than on speed, so it relies on extern C functions rather than on inlined code. You must use HW_IMPLEMENT() to have these functions defined.



HW_DECLARE( LCD ) declares the functions that implement the device. You can put it in your header files:

HW_DECLARE( LCD );



HW_IMPLEMENT( LCD ) defines the functions that implement the device. This must appear in one of your source files:

HW_IMPLEMENT( LCD );

Relatives

HW(LCD,putchar)('x'); // Write 'x' on the LCD using its putchar function

Assuming that myprintf takes the address of a putchar function as first argument:

myprintf( HW(LCD,putchar), "ADC=%03d\n", hw(read,adc0));

Actions



hw( configure, LCD, ... ) configures the LCD:

hw( configure, LCD,
[ init, yes | no, ] // Initialize (no)
[ display, on | off, // Text visibility (on)
cursor, on | off, // '_' visibility (off)
blink, on | off, ] // Blinking block (off)
[ shift, cursor | display, //
direction, left | right ] //
);



hw( cls, LCD ) clears the screen:

hw( cls, LCD );



hw( gotoxy, LCD, x, y ) moves the cursor to column x, line y:

hw( gotoxy, LCD, x, y );



hw( newline, LCD ) moves the cursor to the start of the next line:

hw( newline, LCD, pos );



hw( home, LCD ) moves the cursor to the home position:

hw( home, LCD );



hw( putchar, LCD, c ) writes a character at the current position:

hw( putchar, LCD, c );

Macros

#define HW_DECLARE__hd44780
 
#define HW_HD44780(...)
 
#define HW_IMPLEMENT__hd44780
 
HW_DECLARE
#define HW_DECLARE(...)
Declares the functions that implement an object.
Definition: hwa_1.h:526
hw
#define hw(...)
hw( action, object [,...] ) executes an action immediately on an object.
Definition: hwa_macros.h:523
HW
#define HW(...)
Get the definition of an object or a function name from a path.
Definition: hwa_path.h:268
hd44780.h
HD44780 LCD controller.
HW_IMPLEMENT
#define HW_IMPLEMENT(...)
Defines the functions that implement an object.
Definition: hwa_1.h:548