openHAB - LCD 16x2 Bricklet

Warning

The openHAB bindings are still in beta, but the development was stopped.

This is the description of the openHAB API bindings for the LCD 16x2 Bricklet. General information and technical specifications for the LCD 16x2 Bricklet are summarized in its hardware description.

An installation guide for the openHAB API bindings is part of their general description.

Thing

UID:
  • tinkerforge:brickletlcd16x2:[UID]
Required firmware version:
  • 2.0.1
Firmware update supported:
  • yes
Channels:
Actions:
Parameters:
  • Show Cursor – Type: boolean, Default: false
  • Configures if the cursor (shown as '_') should be visible. The cursor position is one character behind the the last text written.

  • Show Blinking Cursor – Type: boolean, Default: false
  • Configures if the blinking cursor (shown as a blinking block) should be visible. The cursor position is one character behind the the last text written.

Channels

Text

Text to display on the LCD. Command format is [line],[position],[text].

Additional ',' are handled as part of the text. Unicode characters are converted to the LCD character set if possible. Additionally you can use \x[two hex digits] to use a character of the LCD character set directly.

Type:
  • String
UID:
  • tinkerforge:brickletlcd16x2:[UID]:BrickletLCD16x2Text
Read only:
  • No
Clear Display

Deletes all characters from the display.

Type:
  • Commands (String)
UID:
  • tinkerforge:brickletlcd16x2:[UID]:BrickletLCD16x2ClearDisplay
Read only:
  • No
Commands:
  • Accepts any string
Backlight

Toggles the LCD's backlight.

Type:
  • Switch
UID:
  • tinkerforge:brickletlcd16x2:[UID]:BrickletLCD16x2Backlight
Read only:
  • No
Button 0

This channel triggers if button 0 is pressed or released

Type:
  • Trigger (system.rawbutton)
UID:
  • tinkerforge:brickletlcd16x2:[UID]:BrickletLCD16x2Button0
Read only:
  • No
Button 1

This channel triggers if button 1 is pressed or released

Type:
  • Trigger (system.rawbutton)
UID:
  • tinkerforge:brickletlcd16x2:[UID]:BrickletLCD16x2Button1
Read only:
  • No
Button 2

This channel triggers if button 2 is pressed or released

Type:
  • Trigger (system.rawbutton)
UID:
  • tinkerforge:brickletlcd16x2:[UID]:BrickletLCD16x2Button2
Read only:
  • No

Actions

Actions can be used in rules by creating an action object. All actions return a Map<String, Object>. Returned values can be accessed by name, sometimes the type deduction needs some hints, as shown below:

val actions = getActions("tinkerforge", "tinkerforge:brickletlcd16x2:[UID]")
val hwVersion = actions.brickletLCD16x2GetIdentity().get("hardwareVersion") as short[]
logInfo("Example", "Hardware version: " + hwVersion.get(0) + "." + hwVersion.get(1) + "." + hwVersion.get(2))

Basic Actions

brickletLCD16x2WriteLine(short line, short position, String text)
Parameters:
  • line – Type: short, Range: [0 to 1]
  • position – Type: short, Range: [0 to 15]
  • text – Type: String, Length: up to 16

Writes text to a specific line with a specific position. The text can have a maximum of 16 characters.

For example: (0, 5, "Hello") will write Hello in the middle of the first line of the display.

The display uses a special charset that includes all ASCII characters except backslash and tilde. The LCD charset also includes several other non-ASCII characters, see the charset specification for details. The Unicode example above shows how to specify non-ASCII characters and how to translate from Unicode to the LCD charset.

brickletLCD16x2ClearDisplay()

Deletes all characters from the display.

brickletLCD16x2BacklightOn()

Turns the backlight on.

brickletLCD16x2BacklightOff()

Turns the backlight off.

brickletLCD16x2IsBacklightOn()
Return Map:
  • backlight – Type: boolean

Returns true if the backlight is on and false otherwise.

Advanced Actions

brickletLCD16x2GetConfig()
Return Map:
  • cursor – Type: boolean, Default: false
  • blinking – Type: boolean, Default: false

Returns the configuration as set by the thing configuration.

brickletLCD16x2IsButtonPressed(short button)
Parameters:
  • button – Type: short, Range: [0 to 2]
Return Map:
  • pressed – Type: boolean

Returns true if the button is pressed.

If you want to react on button presses and releases it is recommended to use the Button 0 and Button 0 channels.

brickletLCD16x2SetCustomCharacter(short index, short[] character)
Parameters:
  • index – Type: short, Range: [0 to 7]
  • character – Type: short[], Length: 8, Range: [0 to 31]

The LCD 16x2 Bricklet can store up to 8 custom characters. The characters consist of 5x8 pixels and can be addressed with the index 0-7. To describe the pixels, the first 5 bits of 8 bytes are used. For example, to make a custom character "H", you should transfer the following:

  • character[0] = 0b00010001 (decimal value 17)
  • character[1] = 0b00010001 (decimal value 17)
  • character[2] = 0b00010001 (decimal value 17)
  • character[3] = 0b00011111 (decimal value 31)
  • character[4] = 0b00010001 (decimal value 17)
  • character[5] = 0b00010001 (decimal value 17)
  • character[6] = 0b00010001 (decimal value 17)
  • character[7] = 0b00000000 (decimal value 0)

The characters can later be written with Text by using the characters with the byte representation 8 ("\x08" or "\u0008") to 15 ("\x0F" or "\u000F").

You can play around with the custom characters in Brick Viewer since version 2.0.1.

Custom characters are stored by the LCD in RAM, so they have to be set after each startup.

New in version 2.0.1 (Plugin).

brickletLCD16x2GetCustomCharacter(short index)
Parameters:
  • index – Type: short, Range: [0 to 7]
Return Map:
  • character – Type: short[], Length: 8, Range: [0 to 31]

Returns the custom character for a given index, as set with SetCustomCharacter().

New in version 2.0.1 (Plugin).

brickletLCD16x2GetIdentity()
Return Map:
  • uid – Type: String, Length: up to 8
  • connectedUid – Type: String, Length: up to 8
  • position – Type: char, Range: ['a' to 'h', 'z']
  • hardwareVersion – Type: short[], Length: 3
    • 0: major – Type: short, Range: [0 to 255]
    • 1: minor – Type: short, Range: [0 to 255]
    • 2: revision – Type: short, Range: [0 to 255]
  • firmwareVersion – Type: short[], Length: 3
    • 0: major – Type: short, Range: [0 to 255]
    • 1: minor – Type: short, Range: [0 to 255]
    • 2: revision – Type: short, Range: [0 to 255]
  • deviceIdentifier – Type: int, Range: [0 to 216 - 1]

Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.

The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). A Bricklet connected to an Isolator Bricklet is always at position 'z'.

The device identifier numbers can be found here