MQTT - OLED 64x48 Bricklet

This is the description of the MQTT API bindings for the OLED 64x48 Bricklet. General information and technical specifications for the OLED 64x48 Bricklet are summarized in its hardware description.

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

Examples

The example code below is Public Domain (CC0 1.0).

Hello World

Download (example-hello-world.txt)

1
2
3
4
5
6
7
8
# Change XYZ to the UID of your OLED 64x48 Bricklet

setup:
    # Clear display
    publish '' to tinkerforge/request/oled_64x48_bricklet/XYZ/clear_display

    # Write "Hello World" starting from upper left corner of the screen
    publish '{"line": 0, "position": 0, "text": "Hello World"}' to tinkerforge/request/oled_64x48_bricklet/XYZ/write_line

Pixel Matrix

Download (example-pixel-matrix.txt)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Change XYZ to the UID of your OLED 64x48 Bricklet

setup:
    set WIDTH to 64
    set HEIGHT to 48

    # Clear display
    publish '' to tinkerforge/request/oled_64x48_bricklet/XYZ/clear_display

    set pixels to create_pixel_pattern() # This function should create a checkerboard pattern as an array of booleans. See examples for other languages.
    set pages to create_pages_from_pixels() # This function should translate a pixel array to a page array, See drawMatrix in examples for other languages.
    set column_to to WIDTH - 1
    set row_to to HEIGHT / 8 - 1

    publish {"column_from": 0, "column_to": column_to, "row_from": 0, "row_to": row_to} to tinkerforge/request/oled_64x48_bricklet/XYZ/new_window

    for row in 0..HEIGHT/8:
        publish {"data": pages[row]} to tinkerforge/request/oled_64x48_bricklet/XYZ/write
    endfor

API

All published payloads to and from the MQTT bindings are in JSON format.

If an error occures, the bindings publish a JSON object containing the error message as member _ERROR. It is published on the corresponding response topic: .../response/... for .../request/... and .../callback/... for .../register/....

Basic Functions

request/oled_64x48_bricklet/<UID>/write
Request:
  • data – Type: [int, ...], Length: 64, Range: [0 to 255]
Response:
  • no response

Appends 64 byte of data to the window as set by request/oled_64x48_bricklet/<UID>/new_window.

Each row has a height of 8 pixels which corresponds to one byte of data.

Example: if you call request/oled_64x48_bricklet/<UID>/new_window with column from 0 to 63 and row from 0 to 5 (the whole display) each call of request/oled_64x48_bricklet/<UID>/write (red arrow) will write one row.

Display pixel order

The LSB (D0) of each data byte is at the top and the MSB (D7) is at the bottom of the row.

The next call of request/oled_64x48_bricklet/<UID>/write will write the second row and so on. To fill the whole display you need to call request/oled_64x48_bricklet/<UID>/write 6 times.

request/oled_64x48_bricklet/<UID>/new_window
Request:
  • column_from – Type: int, Range: [0 to 63]
  • column_to – Type: int, Range: [0 to 63]
  • row_from – Type: int, Range: [0 to 5]
  • row_to – Type: int, Range: [0 to 5]
Response:
  • no response

Sets the window in which you can write with request/oled_64x48_bricklet/<UID>/write. One row has a height of 8 pixels.

request/oled_64x48_bricklet/<UID>/clear_display
Request:
  • empty payload
Response:
  • no response

Clears the current content of the window as set by request/oled_64x48_bricklet/<UID>/new_window.

request/oled_64x48_bricklet/<UID>/write_line
Request:
  • line – Type: int, Range: [0 to 5]
  • position – Type: int, Range: [0 to 12]
  • text – Type: string, Length: up to 13
Response:
  • no response

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

For example: (1, 4, "Hello") will write Hello in the middle of the second line of the display.

You can draw to the display with request/oled_64x48_bricklet/<UID>/write and then add text to it afterwards.

The display uses a special 5x7 pixel charset. You can view the characters of the charset in Brick Viewer.

The font conforms to code page 437.

Advanced Functions

request/oled_64x48_bricklet/<UID>/set_display_configuration
Request:
  • contrast – Type: int, Range: [0 to 255], Default: 143
  • invert – Type: bool, Default: false
Response:
  • no response

Sets the configuration of the display.

You can set a contrast value from 0 to 255 and you can invert the color (black/white) of the display.

request/oled_64x48_bricklet/<UID>/get_display_configuration
Request:
  • empty payload
Response:
  • contrast – Type: int, Range: [0 to 255], Default: 143
  • invert – Type: bool, Default: false

Returns the configuration as set by request/oled_64x48_bricklet/<UID>/set_display_configuration.

request/oled_64x48_bricklet/<UID>/get_identity
Request:
  • empty payload
Response:
  • uid – Type: string, Length: up to 8
  • connected_uid – Type: string, Length: up to 8
  • position – Type: char, Range: ["a" to "h", "z"]
  • hardware_version – Type: [int, ...], Length: 3
    • 0: major – Type: int, Range: [0 to 255]
    • 1: minor – Type: int, Range: [0 to 255]
    • 2: revision – Type: int, Range: [0 to 255]
  • firmware_version – Type: [int, ...], Length: 3
    • 0: major – Type: int, Range: [0 to 255]
    • 1: minor – Type: int, Range: [0 to 255]
    • 2: revision – Type: int, Range: [0 to 255]
  • device_identifier – Type: int, Range: [0 to 216 - 1]
  • _display_name – Type: string

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. If symbolic output is not disabled, the device identifier is mapped to the corresponding name in the format used in topics.

The display name contains the OLED 64x48's name in a human readable form.