LCD Software

I didn’t really like any of the packages out there already writen for this particular LCD module, so I decided to write my own.

The library I ended up with consists of two layers: the first layer is a direct implementionation of all functions the HD44780 is capable of. The second layer is a general abstraction of basic screen printing functions.

The ‘lcd’ command

Now that I have a library for interfacing with the LCD, I need a handy little command line program for manipulating it.

The general syntax of the command is this:

lcd [options] commands [parameters]

echo being the default command:

lcd [options] echo 'Hello, World!'

Recognized Commands

echo text

Echo’s the text to the lcd. Default behaviour is to wrap text output from the echo command for lines that are longer than the lcd screen width.

move row col

Move the cursor to the specified column,row. The upper left corner of the lcd screen is column 1 and row 1.

clear

Clears the lcd screen, and resets the curson possition to the upper left corner of the screen.

init

Forces software initialization of the lcd screen (also clears screen).

User defined Characters

The echo command will recognize strings of binary (1’s & 0’s) surrounded by square brackets as custom characters. Three things happen when echo encounters a custom character.

  1. Store the binary character representation in an array, analogous of the LCD custom character ram. This provides a cache of sorts to latter check if the character has already been defined in the LCD’s RAM.
  2. Define the character in LCD RAM if necessary.
  3. Instruct the lcd module to display the custom character in the LCD RAM.

Notes regarding the custom character mechanism:

  • Character definitions are transfered into LCD RAM at the point the character is displayed.
  • Character definitions remain in RAM until the LCD is re-initialized (software reset or hardware reset).
  • If the LCD has for example 8 custom character slots in RAM, the LCD will only be able to display 8 custom characters per screen.