TCP/IP - LCD 16x2 Bricklet – Tinkerforge

- Getting Started
  - Primer
  - Tutorials
  - FAQ
- Hardware
  - Bricks
  - Bricklets
  - Master Extensions
  - Power Supplies
  - Accessories
  - Timeline
- Software
  - Brick Daemon (brickd)
  - Brick Viewer (brickv)
  - API Bindings
  - Firmwares and Plugins
  - Device Identifier
  - Source Code and Bug Tracking
  - Programming Interface
- Starter Kits
  - Weather Station
  - Hardware Hacking
  - Server Room Monitoring
  - Blinkenlights
  - Internet of Things
  - Camera Slider
- Embedded Boards
  - Raspberry Pi
- Specifications
  - Technical Data
  - TCP/IP Protocol
    - Protocol
    - API
      - Brick Daemon Functions
      - Broadcast Functions
      - General Callbacks
      - Bricks and Bricklets
        - Bricks
        - Bricklets
          - Ambient Light Bricklet
          - Analog In Bricklet
          - Analog Out Bricklet
          - Barometer Bricklet
          - Color Bricklet
          - Current12 Bricklet
          - Current25 Bricklet
          - Distance IR Bricklet
          - Distance US Bricklet
          - Dual Button Bricklet
          - Dual Relay Bricklet
          - GPS Bricklet
          - Hall Effect Bricklet
          - Humidity Bricklet
          - Industrial Digital In 4 Bricklet
          - Industrial Digital Out 4 Bricklet
          - Industrial Dual 0-20mA Bricklet
          - Industrial Quad Relay Bricklet
          - IO-16 Bricklet
          - IO-4 Bricklet
          - Joystick Bricklet
          - LCD 16x2 Bricklet
            - API
              - Basic Functions
              - Advanced Functions
              - Callbacks
          - LCD 20x4 Bricklet
          - LED Strip Bricklet
          - Line Bricklet
          - Linear Poti Bricklet
          - Moisture Bricklet
          - Motion Detector Bricklet
          - Multi Touch Bricklet
          - NFC/RFID Bricklet
          - Piezo Buzzer Bricklet
          - Piezo Speaker Bricklet
          - PTC Bricklet
          - Remote Switch Bricklet
          - Rotary Encoder Bricklet
          - Rotary Poti Bricklet
          - Segment Display 4x7 Bricklet
          - Solid State Relay Bricklet
          - Sound Intensity Bricklet
          - Temperature Bricklet
          - Temperature IR Bricklet
          - Tilt Bricklet
          - Voltage Bricklet
          - Voltage/Current Bricklet
  - Modbus Protocol
  - Wireshark Dissector

# TCP/IP - LCD 16x2 Bricklet

This is the description of the TCP/IP protocol for the LCD 16x2 Bricklet. General information and technical specifications for the LCD 16x2 Bricklet are summarized in its hardware description.

## API

A general description of the TCP/IP protocol structure can be found here.

### Basic Functions

`BrickletLCD16x2.``write_line`

  Function ID: | 1

  Request:

  - line -- uint8
  - position -- uint8
  - text -- char[16]

  Response: | no response

  Writes text to a specific line (0 to 1) with a specific position (0 to 15). 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.

`BrickletLCD16x2.``clear_display`

  Function ID: | 2
  Request: | empty payload
  Response: | no response

  Deletes all characters from the display.

`BrickletLCD16x2.``backlight_on`

  Function ID: | 3
  Request: | empty payload
  Response: | no response

  Turns the backlight on.

`BrickletLCD16x2.``backlight_off`

  Function ID: | 4
  Request: | empty payload
  Response: | no response

  Turns the backlight off.

`BrickletLCD16x2.``is_backlight_on`

  Function ID: | 5
  Request: | empty payload

  Response:

  - backlight -- bool

  Returns true if the backlight is on and false otherwise.

### Advanced Functions

`BrickletLCD16x2.``set_config`

  Function ID: | 6

  Request:

  - cursor -- bool
  - blinking -- bool

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

`BrickletLCD16x2.``get_config`

  Function ID: | 7
  Request: | empty payload

  Response:

  - cursor -- bool
  - blinking -- bool

  Returns the configuration as set by `set_config`.

`BrickletLCD16x2.``is_button_pressed`

  Function ID: | 8

  Request:

  - button -- uint8

  Response:

  - pressed -- bool

  Returns true if the button (0 to 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.

`BrickletLCD16x2.``set_custom_character`

  Function ID: | 11

  Request:

  - index -- uint8
  - character -- uint8[8]

  Response: | no response

  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 `write_line` by using the characters with the byte representation 8 to 15.

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

`BrickletLCD16x2.``get_custom_character`

  Function ID: | 12

  Request:

  - index -- uint8

  Response:

  - character -- uint8[8]

  Returns the custom character for a given index, as set with `set_custom_character`.

  New in version 2.0.1 (Plugin).

`BrickletLCD16x2.``get_identity`

  Function ID: | 255
  Request: | empty payload

  Response:

  - uid -- char[8]
  - connected_uid -- char[8]
  - position -- char
  - hardware_version -- uint8[3]
  - firmware_version -- uint8[3]
  - device_identifier -- uint16

  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.

### Callbacks

`BrickletLCD16x2.``CALLBACK_BUTTON_PRESSED`

  Function ID: | 9

  Response:

  - button -- uint8

  This callback is triggered when a button is pressed. The response value is the number of the button (0 to 2).

`BrickletLCD16x2.``CALLBACK_BUTTON_RELEASED`

  Function ID: | 10

  Response:

  - button -- uint8

  This callback is triggered when a button is released. The response value is the number of the button (0 to 2).

The content of this page is licensed under Creative Commons Attribution 3.0 Unported License.