Unit AF16x2LCD

From Ultibo.org
Jump to: navigation, search

Return to Unit Reference


Description


Adafruit 16x2 Character LCD + Keypad Driver unit

The Adafruit 16x2 LCD + Keypad is a kit that includes both a 16x2 LCD display using the Hitachi HD44780 LCD controller as well as a custom PCB with an MCP23017 I/O expander to connect it to a Raspberry Pi (any model) using I2C. It is available in Monochrome or RGB Positive and Negative versions.

This unit ties together the various components needed to make one of these boards work with Ultibo by finding the correct I2C device, creating the MCP230XX GPIO device, creating the HD44780 Console device and registering all of it with the correct parameters for the Adafruit kit.

The unit also includes functions to read the 5 buttons on the board and control the LCD backlight.

You will find many LCD display boards based on the Hitachi HD44780 controller and this unit gives an example of how to assembler the available units to create your own driver for a different board.

Constants



[Expand]
AF16x2LCD specific constants AF16X2LCD_*


[Expand]
AF16x2LCD GPIO pin GPIO_PIN_*


Type definitions



AF16x2LCD specific types

[Expand]

PAF16x2LCDPlate = ^TAF16x2LCDPlate;

TAF16x2LCDPlate = record


Public variables



AF16x2LCD specific variables

AF16X2LCD_MODEL:LongWord = AF16X2LCD_MODEL_RGB;
AF16X2LCD_I2C_ADDRESS:Word = $20;
AF16X2LCD_I2C_DEVICE:String = 'I2C0';


Function declarations



Initialization functions

[Expand]
procedure AF16x2LCDInit;
Description: Initialize the AF16x2LCD unit and parameters


[Expand]
function AF16x2LCDStart(Model:LongWord; Invert:Boolean; const Device:String; Address:Word):THandle;
Description: Start the AF16x2LCD driver and register the GPIO and Console devices associated with the display


[Expand]
function AF16x2LCDStop(Handle:THandle):Boolean;
Description: Stop the AF16x2LCD driver and deregister the GPIO and Console devices associated with the display


AF16x2LCD functions

[Expand]
function AF16x2LCDGetButton(Handle:THandle; Button:LongWord):LongWord;
Description: Get the GPIO level of a button on the AF16x2LCD display


[Expand]
function AF16x2LCDBacklightOn(Handle:THandle):Boolean;
Description: Turn on the backlight on the AF16x2LCD display


[Expand]
function AF16x2LCDBacklightOff(Handle:THandle):Boolean;
Description: Turn off the backlight on the AF16x2LCD display


[Expand]
function AF16x2LCDBacklightColor(Handle:THandle; Red,Green,Blue:Byte):Boolean;
Description: Set the backlight color on the AF16x2LCD display


Return to Unit Reference