Hitachi HD44780 display controller
Controlled by PCF8574 I2C interface
Functions
hd44780.c File Reference

I2C based PCF8574 access library for HD44780 based LCD on Raspberry Pi using pigpio for I2C access
Copyright U. Raich Jan. 2017
This program is part of a course on embedded systems held at the University of Cape Coast, Ghana in 2017
It is released under the GNU Public License For details please see https://www.gnu.org/licenses/gpl.html. More...

#include <hd44780.h>
Include dependency graph for hd44780.c:

Functions

void hd44780SetDebug (bool onOff)
 switches debug mode on or off More...
 
int hd44780BackLight (bool onOff)
 switches the display back light on or off More...
 
int hd44780Home ()
 Sets the DDRAM address to zero such that the next character is written to the top left position if the LED screen. If the display is shifted it is set back to the original position. More...
 
int hd44780Cursor (bool onOff, bool blink)
 Sets the DDRAM address to zero such that the next character is written to the top left position if the LED screen. If the display is shifted it is set back to the original position. More...
 
int hd44780Display (bool onOff)
 Switches the display on or off. More...
 
int hd44780EntryMode (bool incDec, bool shift)
 Defines if the address counter counts up or down
and sets shifting the whole display on or off. More...
 
int hd44780SecondLine ()
 Sets the DDRAM address to the beginning of the second line. More...
 
int hd44780SetDDRamAddr (unsigned char addr)
 Sets the DDRAM address. More...
 
int hd44780Clear ()
 Clears the display. More...
 
int hd44780PutC (char c)
 Write a character to the display. More...
 
int hd44780PutS (char *text)
 Writes a zero terminated character string to the display Not more than 16 characters are written it no zero is found. More...
 
int hd44780ReadBusy (bool *busy, unsigned char *address)
 Reads the busy flag and the DDRAM address. More...
 
int hd44780GetC (char *c)
 Read a character from the display. More...
 
int hd44780Open ()
 hd44770Open: initializes the pigpio library opens the I2C connection to the pcf8574 which is on the I2C address 0x3f More...
 
void hd44780Close ()
 hd44770Close: closes the I2C connection to the pcf8574 and disconnects from the pigpio library More...
 
int hd44780CreateChar (unsigned char cgramAddr, unsigned char *dotMatrix)
 hd44780CreateChar: creates a character in the character generator RAM (CGRAM) More...
 

Detailed Description

I2C based PCF8574 access library for HD44780 based LCD on Raspberry Pi using pigpio for I2C access
Copyright U. Raich Jan. 2017
This program is part of a course on embedded systems held at the University of Cape Coast, Ghana in 2017
It is released under the GNU Public License For details please see https://www.gnu.org/licenses/gpl.html.

:

Author
Uli Raich

Function Documentation

◆ hd44780BackLight()

int hd44780BackLight ( bool  onOff)

switches the display back light on or off

Parameters
onOfftrue: switches debug mode on
false: switches debug mode off
Returns
result from the call to the pigpio library
Return values
HD44780_SUCCESS-> success
negativeerror code from the pigpio library

◆ hd44780Clear()

int hd44780Clear ( void  )

Clears the display.

Returns
result from the call to the hd44780WriteCmd function
Return values
HD44780_SUCCESS-> success
negativeerror code from the hd44780WriteCmd function

◆ hd44780Close()

void hd44780Close ( void  )

hd44770Close: closes the I2C connection to the pcf8574 and disconnects from the pigpio library

◆ hd44780CreateChar()

int hd44780CreateChar ( unsigned char  cgramAddr,
unsigned char *  dotMatrix 
)

hd44780CreateChar: creates a character in the character generator RAM (CGRAM)

Parameters
addressthe address in the CGRAM where to write the character must be on a 8 byte boundary
characterthe dot matrix consisting of 7 bytes
Return values
HD44780_SUCCESS-> success
negativeerror code from the hd44780putC function

◆ hd44780Cursor()

int hd44780Cursor ( bool  onOff,
bool  blink 
)

Sets the DDRAM address to zero such that the next character is written to the top left position if the LED screen. If the display is shifted it is set back to the original position.

Returns
result from the call to the hd44780WriteCmd function
Return values
HD44780_SUCCESS-> success
negativeerror code from the hd44780WriteCmd function

◆ hd44780Display()

int hd44780Display ( bool  onOff)

Switches the display on or off.

Parameters
onOfffalse: switches the display off
true: switches it on
Returns
result from the call to the hd44780WriteCmd function
Return values
HD44780_SUCCESS-> success
negativeerror code from the hd44780WriteCmd function

◆ hd44780EntryMode()

int hd44780EntryMode ( bool  incDec,
bool  shift 
)

Defines if the address counter counts up or down
and sets shifting the whole display on or off.

Parameters
incDecfalse: the address counter is decremented when a character is written
true: it is incremented
shiftfalse: display shifts are switched off
true: they are switched on
Returns
result from the call to the hd44780WriteCmd function
Return values
HD44780_SUCCESS-> success
negativeerror code from the hd44780WriteCmd function

◆ hd44780GetC()

int hd44780GetC ( char *  c)

Read a character from the display.

Parameters
cpointer to the character read from the display controller
Returns
result from the call to the hd44780Read function
Return values
HD44780_SUCCESS-> success
negativeerror code from the hd44780Read function

◆ hd44780Home()

int hd44780Home ( void  )

Sets the DDRAM address to zero such that the next character is written to the top left position if the LED screen. If the display is shifted it is set back to the original position.

Returns
result from the call to the hd44780WriteCmd function
Return values
HD44780_SUCCESS-> success
negativeerror code from the hd44780WriteCmd function

◆ hd44780Open()

int hd44780Open ( void  )

hd44770Open: initializes the pigpio library opens the I2C connection to the pcf8574 which is on the I2C address 0x3f

Returns
result from the call to the pigpio library
Return values
HD44780_SUCCESS-> success
negativeerror code from the pigpio library

◆ hd44780PutC()

int hd44780PutC ( char  c)

Write a character to the display.

Parameters
cthe character to be written
Returns
result from the call to the hd44780WriteCmd function
Return values
HD44780_SUCCESS-> success
negativeerror code from the hd44780WriteCmd function

◆ hd44780PutS()

int hd44780PutS ( char *  text)

Writes a zero terminated character string to the display Not more than 16 characters are written it no zero is found.

Parameters
textthe zero terminated C character string
Returns
result from the call to the hd44780PutC function
Return values
HD44780_SUCCESS-> success
negativeerror code from the hd44780PutC function

◆ hd44780ReadBusy()

int hd44780ReadBusy ( bool *  busy,
unsigned char *  address 
)

Reads the busy flag and the DDRAM address.

Parameters
*busya pointer to a boolean into which the busy flag will be written
*addressa pointer to an unsigned char into which the DDRAM address will be written
Returns
result from the call to the hd44780Read function
Return values
HD44780_SUCCESS-> success
negativeerror code from the hd44780Read function

◆ hd44780SecondLine()

int hd44780SecondLine ( void  )

Sets the DDRAM address to the beginning of the second line.

Returns
result from the call to hd44780SetDDRamAddr()

◆ hd44780SetDDRamAddr()

int hd44780SetDDRamAddr ( unsigned char  addr)

Sets the DDRAM address.

Parameters
addrthe DDRAM address to which the next character will be written or read from
Returns
result from the call to the hd44780WriteCmd function
Return values
HD44780_SUCCESS-> success
negativeerror code from the hd44780WriteCmd function

◆ hd44780SetDebug()

void hd44780SetDebug ( bool  onOff)

switches debug mode on or off

Parameters
onOfftrue: switches debug mode on
false: switches debug mode off