Ishraq Ibne Ashraf
and 1 contributors

NAME

Tinkerforge::BrickletLCD20x4 - 20x4 character alphanumeric display with blue backlight

CONSTANTS

DEVICE_IDENTIFIER

This constant is used to identify a LCD 20x4 Bricklet.

The get_identity() subroutine and the CALLBACK_ENUMERATE callback of the IP Connection have a device_identifier parameter to specify the Brick's or Bricklet's type.

DEVICE_DISPLAY_NAME

This constant represents the display name of a LCD 20x4 Bricklet.

CALLBACK_BUTTON_PRESSED

This constant is used with the register_callback() subroutine to specify the CALLBACK_BUTTON_PRESSED callback.

CALLBACK_BUTTON_RELEASED

This constant is used with the register_callback() subroutine to specify the CALLBACK_BUTTON_RELEASED callback.

FUNCTION_WRITE_LINE

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_CLEAR_DISPLAY

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_BACKLIGHT_ON

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_BACKLIGHT_OFF

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_IS_BACKLIGHT_ON

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_SET_CONFIG

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_GET_CONFIG

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_IS_BUTTON_PRESSED

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_SET_CUSTOM_CHARACTER

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_GET_CUSTOM_CHARACTER

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_SET_DEFAULT_TEXT

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_GET_DEFAULT_TEXT

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_SET_DEFAULT_TEXT_COUNTER

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_GET_DEFAULT_TEXT_COUNTER

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTION_GET_IDENTITY

This constant is used with the get_response_expected(), set_response_expected() and set_response_expected_all() subroutines.

FUNCTIONS

new()

Creates an object with the unique device ID *uid* and adds it to the IP Connection *ipcon*.

write_line()

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 <https://github.com/Tinkerforge/lcd-20x4-bricklet/raw/master/datasheets/standard_charset.pdf>`__ for details. The Unicode example above shows how to specify non-ASCII characters and how to translate from Unicode to the LCD charset.

clear_display()

Deletes all characters from the display.

backlight_on()

Turns the backlight on.

backlight_off()

Turns the backlight off.

is_backlight_on()

Returns *true* if the backlight is on and *false* otherwise.

set_config()

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 :func:`Write Line`.

The default is (*false*, *false*).

get_config()

Returns the configuration as set by :func:`Set Config`.

is_button_pressed()

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 :cb:`Button Pressed` and :cb:`Button Released` callbacks.

set_custom_character()

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 :func:`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.

.. versionadded:: 2.0.1$nbsp;(Plugin)

get_custom_character()

Returns the custom character for a given index, as set with :func:`Set Custom Character`.

.. versionadded:: 2.0.1$nbsp;(Plugin)

set_default_text()

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 :func:`Set Default Text Counter`.

.. versionadded:: 2.0.2$nbsp;(Plugin)

get_default_text()

Returns the default text for a given line (0-3) as set by :func:`Set Default Text`.

.. versionadded:: 2.0.2$nbsp;(Plugin)

set_default_text_counter()

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 :func:`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 :func:`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.

.. versionadded:: 2.0.2$nbsp;(Plugin)

get_default_text_counter()

Returns the current value of the default text counter.

.. versionadded:: 2.0.2$nbsp;(Plugin)

get_identity()

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 :ref:`here <device_identifier>`. |device_identifier_constant|