Difference between revisions of "Unit AF16x2LCD"

From Ultibo.org
Jump to: navigation, search
 
(3 intermediate revisions by the same user not shown)
Line 20: Line 20:
  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
<div style="font-size: 14px; padding-left: 12px;">'''AF16x2LCD specific''' <code> AF16X2LCD_* </code></div>
+
<div style="font-size: 14px; padding-left: 12px;">'''AF16x2LCD specific constants''' <code> AF16X2LCD_* </code></div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
Line 172: Line 172:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| Called only during system startup
 
| Called only during system startup
 
|-
 
|-
Line 179: Line 179:
 
<br />  
 
<br />  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function AF16x2LCDStart(Model:LongWord;Invert:Boolean; const Device:String; Address:Word):THandle;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function AF16x2LCDStart(Model:LongWord; Invert:Boolean; const Device:String; Address:Word):THandle;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Start the AF16x2LCD driver and register the GPIO and Console devices associated with the display</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Start the AF16x2LCD driver and register the GPIO and Console devices associated with the display</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Model'''
+
! Model
 
| The Adafruit 16x2 LCD Plate model (eg AF16X2LCD_MODEL_RGB)
 
| The Adafruit 16x2 LCD Plate model (eg AF16X2LCD_MODEL_RGB)
 
|-
 
|-
! '''Invert'''
+
! Invert
 
| Invert the signal level for the LCD backlight (If True then GPIO_LEVEL_LOW equals On)
 
| Invert the signal level for the LCD backlight (If True then GPIO_LEVEL_LOW equals On)
 
|-
 
|-
! '''Device'''
+
! Device
 
| The I2C device that the MCP23017 I/O Expander on the LCD Plate is connected to
 
| The I2C device that the MCP23017 I/O Expander on the LCD Plate is connected to
 
|-
 
|-
! '''Address'''
+
! Address
 
| The I2C address of the MCP23017 I/O Expander on the LCD Plate
 
| The I2C address of the MCP23017 I/O Expander on the LCD Plate
 
|-
 
|-
! '''Return'''
+
! Return
 
| The handle of the AF16x2LCD on success or INVALID_HANDLE_VALUE on failure
 
| The handle of the AF16x2LCD on success or INVALID_HANDLE_VALUE on failure
 
|-
 
|-
! '''Note'''
+
! Note
 
| This function will be called during startup if the parameter AF16X2LCD_AUTOSTART is True
 
| This function will be called during startup if the parameter AF16X2LCD_AUTOSTART is True
 
Can be called multiple times to support more than one 16x2 LCD display
 
Can be called multiple times to support more than one 16x2 LCD display
Line 212: Line 212:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Handle'''
+
! Handle
 
| The handle of the AF16x2LCD or INVALID_HANDLE_VALUE for the default display
 
| The handle of the AF16x2LCD or INVALID_HANDLE_VALUE for the default display
 
|-
 
|-
! '''Return'''
+
! Return
 
| True if completed or False on failure
 
| True if completed or False on failure
 
|-
 
|-
Line 230: Line 230:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Handle'''
+
! Handle
 
| The handle of the AF16x2LCD or INVALID_HANDLE_VALUE for the default display
 
| The handle of the AF16x2LCD or INVALID_HANDLE_VALUE for the default display
 
|-
 
|-
! '''Button'''
+
! Button
 
| The button to get the level for (eg AF16X2LCD_BUTTON_LEFT)
 
| The button to get the level for (eg AF16X2LCD_BUTTON_LEFT)
 
|-
 
|-
! '''Return'''
+
! Return
 
| The GPIO level of the button (eg GPIO_LEVEL_HIGH) or GPIO_LEVEL_UNKNOWN on failure
 
| The GPIO level of the button (eg GPIO_LEVEL_HIGH) or GPIO_LEVEL_UNKNOWN on failure
 
|-
 
|-
Line 248: Line 248:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Handle'''
+
! Handle
 
| The handle of the AF16x2LCD or INVALID_HANDLE_VALUE for the default display
 
| The handle of the AF16x2LCD or INVALID_HANDLE_VALUE for the default display
 
|-
 
|-
! '''Return'''
+
! Return
 
| True if completed or False on failure
 
| True if completed or False on failure
 
|-
 
|-
Line 263: Line 263:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Handle'''
+
! Handle
 
| The handle of the AF16x2LCD or INVALID_HANDLE_VALUE for the default display
 
| The handle of the AF16x2LCD or INVALID_HANDLE_VALUE for the default display
 
|-
 
|-
! '''Return'''
+
! Return
 
| True if completed or False on failure
 
| True if completed or False on failure
 
|-
 
|-
Line 278: Line 278:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Handle'''
+
! Handle
 
| The handle of the AF16x2LCD or INVALID_HANDLE_VALUE for the default display
 
| The handle of the AF16x2LCD or INVALID_HANDLE_VALUE for the default display
 
|-
 
|-
! '''Red'''
+
! Red
| The Red value (0 for Off / 1 for On)
+
| The Red value (0 for Off/1 for On)
 
|-
 
|-
! '''Green'''
+
! Green
| The Green value (0 for Off / 1 for On)
+
| The Green value (0 for Off/1 for On)
 
|-
 
|-
! '''Blue'''
+
! Blue
| The Blue value (0 for Off / 1 for On)
+
| The Blue value (0 for Off/1 for On)
 
|-
 
|-
! '''Return'''
+
! Return
 
| True if completed or False on failure
 
| True if completed or False on failure
 
|-
 
|-

Latest revision as of 04:09, 24 April 2018

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