openHAB - LCD 20x4 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 20x4 Bricklet. General information and technical specifications for the LCD 20x4 Bricklet are summarized in its hardware description.

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

Thing

UID:
  • tinkerforge:brickletlcd20x4:[UID]
Required firmware version:
  • 2.0.2
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:brickletlcd20x4:[UID]:BrickletLCD20x4Text
Read only:
  • No
Clear Display

Deletes all characters from the display.

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

Toggles the LCD's backlight.

Type:
  • Switch
UID:
  • tinkerforge:brickletlcd20x4:[UID]:BrickletLCD20x4Backlight
Read only:
  • No
Button 0

This channel triggers if button 0 is pressed or released

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

This channel triggers if button 1 is pressed or released

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

This channel triggers if button 2 is pressed or released

Type:
  • Trigger (system.rawbutton)
UID:
  • tinkerforge:brickletlcd20x4:[UID]:BrickletLCD20x4Button2
Read only:
  • No
Button 3

This channel triggers if button 3 is pressed or released

Type:
  • Trigger (system.rawbutton)
UID:
  • tinkerforge:brickletlcd20x4:[UID]:BrickletLCD20x4Button3
Read only:
  • No
Predicate:
  • This channel will only be available if the Bricklet has a hardware version of at least 1.2 (e.g. if it has 4 buttons)

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:brickletlcd20x4:[UID]")
val hwVersion = actions.brickletLCD20x4GetIdentity().get("hardwareVersion") as short[]
logInfo("Example", "Hardware version: " + hwVersion.get(0) + "." + hwVersion.get(1) + "." + hwVersion.get(2))

Basic Actions

brickletLCD20x4WriteLine(short line, short position, String text)
Parameters:
  • line – Type: short, Range: [0 to 3]
  • position – Type: short, Range: [0 to 19]
  • text – Type: String, Length: up to 20

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

For example: (0, 7, "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.

brickletLCD20x4ClearDisplay()

Deletes all characters from the display.

brickletLCD20x4BacklightOn()

Turns the backlight on.

brickletLCD20x4BacklightOff()

Turns the backlight off.

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

Returns true if the backlight is on and false otherwise.

Advanced Actions

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

Returns the configuration as set by the thing configuration.

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

Returns true if the button (0 to 2 or 0 to 3 since hardware version 1.2) is pressed.

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

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

The LCD 20x4 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 version since 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).

brickletLCD20x4GetCustomCharacter(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).

brickletLCD20x4SetDefaultText(short line, String text)
Parameters:
  • line – Type: short, Range: [0 to 3]
  • text – Type: String, Length: up to 20

Sets the default text for lines 0-3. The max number of characters per line is 20.

The default text is shown on the LCD, if the default text counter expires, see SetDefaultTextCounter().

New in version 2.0.2 (Plugin).

brickletLCD20x4GetDefaultText(short line)
Parameters:
  • line – Type: short, Range: [0 to 3]
Return Map:
  • text – Type: String, Length: up to 20

Returns the default text for a given line (0-3) as set by SetDefaultText().

New in version 2.0.2 (Plugin).

brickletLCD20x4SetDefaultTextCounter(int counter)
Parameters:
  • counter – Type: int, Unit: 1 ms, Range: [-231 to 231 - 1], Default: -1

Sets the default text counter. This counter is decremented each ms by the LCD firmware. If the counter reaches 0, the default text (see SetDefaultText()) is shown on the LCD.

This functionality can be used to show a default text if the controlling program crashes or the connection is interrupted.

A possible approach is to call SetDefaultTextCounter() every minute with the parameter 1000*60*2 (2 minutes). In this case the default text will be shown no later than 2 minutes after the controlling program crashes.

A negative counter turns the default text functionality off.

New in version 2.0.2 (Plugin).

brickletLCD20x4GetDefaultTextCounter()
Return Map:
  • counter – Type: int, Unit: 1 ms, Range: [-231 to 231 - 1], Default: -1

Returns the current value of the default text counter.

New in version 2.0.2 (Plugin).

brickletLCD20x4GetIdentity()
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