This is the description of the TCP/IP protocol for the LCD 20x4 Bricklet. General information and technical specifications for the LCD 20x4 Bricklet are summarized in its hardware description.
A general description of the TCP/IP protocol structure can be found here.
Function ID: | 1 |
---|---|
Request: |
|
Response: | no response |
Writes text to a specific line (0 to 3) with a specific position (0 to 19). 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.
Function ID: | 2 |
---|---|
Request: | empty payload |
Response: | no response |
Deletes all characters from the display.
Function ID: | 3 |
---|---|
Request: | empty payload |
Response: | no response |
Turns the backlight on.
Function ID: | 4 |
---|---|
Request: | empty payload |
Response: | no response |
Turns the backlight off.
Function ID: | 5 |
---|---|
Request: | empty payload |
Response: |
|
Returns true if the backlight is on and false otherwise.
Function ID: | 6 |
---|---|
Request: |
|
Response: | no response |
Configures if the cursor (shown as "_") should be visible and if it should be blinking (shown as a blinking block). The cursor position is one character behind the the last text written with write_line.
The default is (false, false).
Function ID: | 7 |
---|---|
Request: | empty payload |
Response: |
|
Returns the configuration as set by set_config.
Function ID: | 8 |
---|---|
Request: |
|
Response: |
|
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 CALLBACK_BUTTON_PRESSED and CALLBACK_BUTTON_RELEASED callbacks.
Function ID: | 11 |
---|---|
Request: |
|
Response: | no response |
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:
The characters can later be written with write_line by using the characters with the byte representation 8 ("x08") to 15 ("x0F").
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).
Function ID: | 12 |
---|---|
Request: |
|
Response: |
|
Returns the custom character for a given index, as set with set_custom_character.
New in version 2.0.1 (Plugin).
Function ID: | 13 |
---|---|
Request: |
|
Response: | no response |
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 set_default_text_counter.
New in version 2.0.2 (Plugin).
Function ID: | 14 |
---|---|
Request: |
|
Response: |
|
Returns the default text for a given line (0-3) as set by set_default_text.
New in version 2.0.2 (Plugin).
Function ID: | 15 |
---|---|
Request: |
|
Response: | no response |
Sets the default text counter in ms. This counter is decremented each ms by the LCD firmware. If the counter reaches 0, the default text (see set_default_text) 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 set_default_text_counter 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.
The default is -1.
New in version 2.0.2 (Plugin).
Function ID: | 16 |
---|---|
Request: | empty payload |
Response: |
|
Returns the current value of the default text counter.
New in version 2.0.2 (Plugin).
Function ID: | 255 |
---|---|
Request: | empty payload |
Response: |
|
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' or 'd'.
The device identifier numbers can be found here.
Function ID: | 9 |
---|---|
Response: |
|
This callback is triggered when a button is pressed. The response value is the number of the button (0 to 2 or 0 to 3 since hardware version 1.2).
Function ID: | 10 |
---|---|
Response: |
|
This callback is triggered when a button is released. The response value is the number of the button (0 to 2 or 0 to 3 since hardware version 1.2).