### Sample LCD20x4

Several examples using MQTT for the LCD20x4 Bricklet.
LCD20x4 Backlight On / Off
LCD20x4 Bricklet with UID rTS set the backlight on or off
Private mqtt As MqttClient
mqtt.Subscribe("tinkerforge/bricklet/lcd_20x4/rTS/backlight_on/set", 0)
mqtt.Subscribe("tinkerforge/bricklet/lcd_20x4/rTS/backlight_off/set", 0)
LCD20x4 write a line
LCD20x4 Bricklet with UID rTS write a line.
`Subscribe first:
mqtt.Subscribe("tinkerforge/bricklet/lcd_20x4/rTS/write_line/set", 0)
Publish:
On the TinkerForge LCD20x4 Bricket with UID rTS write the Text "Hello World" at line 0 and position 7.
The terminal command would be - this is always a good way to test prior coding
$mosquitto_pub -t tinkerforge/bricklet/lcd_20x4/rTS/write_line/set -m '{"line":0, "position":7, "text":"hello world"}'
Private mqtt As MqttClient
'B4J Define the JSON payload
Dim PayloadStr as String = "{""line"":0, ""position"":7, ""text"":""Hello World""}"
'Publish using the prefix write_line/set and convert the payload string in bytes array
mqtt.Publish("tinkerforge/bricklet/lcd_20x4/rTS/write_line/set", PayloadStr.GetBytes("UTF8"))
LCD20x4 Bricklet Custom Chars
Utility to create Custom Characters for the TinkerForge LCD Bricklets:
Documentation on request.
Purpose to define Custom Characters for use with the TinkerForge Bricklet LCD Displays.
The defined characters can be
• saved and restored using textfile
• used for example via the Brick MQTT Proxy as the JSON string is created according the character defined
B4J Example:
'LCD20x4 define UID and Custom Character Index for the Arrow Up
Private BrickletLCDUID As String = "rTS"
Private LCDArrowUp As String = "\u0008"
'Define and publish
'Terminal command for tests:
'$mosquitto_pub -t tinkerforge/bricklet/lcd_20x4/SCD32/custom_character/set -m '{"index":0, "character":[0,4,10,27,4,4,14,0]}'
'Arrow Up at Index 0 to be published as \u0008
Dim PayloadStr As String = "{""index"":0, ""character"":[0,4,14,31,4,4,4,0]}"
mqtt.Publish("tinkerforge/bricklet/lcd_20x4/" & BrickletLCDUID & "/custom_character/set", PayloadStr.GetBytes("UTF8"))
'Publish the Arror Up using write_line
Dim MessageStr as String = "This is an Arrow Up " & LCDArrowUp
Dim PayloadStr as String = "{""line"":1, ""position"":0, ""text"":""" & MessageStr & """}"
'Publish using the prefix write_line/set and convert the payload string in bytes array
mqtt.Publish("tinkerforge/bricklet/lcd_20x4/" & BrickletLCDUID & "/write_line/set", PayloadStr.GetBytes("UTF8"))
LCD20x4 Bricklet Clear Display
Example Sub to clear the LCD20x4 Display.
'Define the Bricklet UID
Private BrickletLCDUID As String = "rTS"
'Clear the LCD20x4 display
Sub LCD20x4ClearDisplay
'DSet an empty payload
Dim PayloadStr As String = ""
mqtt.Publish("tinkerforge/bricklet/lcd_20x4/" & BrickletLCDUID & "/clear_display/set", PayloadStr.GetBytes("UTF8"))
End Sub`

Changed: 2018-06-07 09:25, Category: TinkerForge MQTT, File: T6C266M1981.htm, ID: 1981