MQTT - OLED 128x64 Bricklet

This is the description of the MQTT API bindings for the OLED 128x64 Bricklet. General information and technical specifications for the OLED 128x64 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 128x64 Bricklet

setup:
    # Clear display
    publish '' to tinkerforge/request/oled_128x64_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_128x64_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
20
21
# Change XYZ to the UID of your OLED 128x64 Bricklet

setup:
    set WIDTH to 128
    set HEIGHT to 64

    # Clear display
    publish '' to tinkerforge/request/oled_128x64_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_128x64_bricklet/XYZ/new_window
    
    for row in 0..HEIGHT/8:
        publish {"data": pages[row]} to tinkerforge/request/oled_128x64_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 attribute "_ERROR". It is published on the corresponding response topic: .../response/... for .../request/... and .../callback/... for .../register/....

Basic Functions

request/oled_128x64_bricklet/<UID>/write
Request payload:
 
  • data -- [int,... (x64)]

Appends 64 byte of data to the window as set by request/oled_128x64_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_128x64_bricklet/<UID>/new_window with column from 0 to 127 and row from 0 to 7 (the whole display) each call of request/oled_128x64_bricklet/<UID>/write (red arrow) will write half of a 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_128x64_bricklet/<UID>/write will write the second half of the row and the next two the second row and so on. To fill the whole display you need to call request/oled_128x64_bricklet/<UID>/write 16 times.

request/oled_128x64_bricklet/<UID>/new_window
Request payload:
 
  • column_from -- int
  • column_to -- int
  • row_from -- int
  • row_to -- int

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

The columns have a range of 0 to 127 and the rows have a range of 0 to 7.

request/oled_128x64_bricklet/<UID>/clear_display

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

request/oled_128x64_bricklet/<UID>/write_line
Request payload:
 
  • line -- int
  • position -- int
  • text -- string

Writes text to a specific line (0 to 7) with a specific position (0 to 25). The text can have a maximum of 26 characters.

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

You can draw to the display with request/oled_128x64_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.

Advanced Functions

request/oled_128x64_bricklet/<UID>/set_display_configuration
Request payload:
 
  • contrast -- int
  • invert -- bool

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.

The default values are contrast 143 and inverting off.

request/oled_128x64_bricklet/<UID>/get_display_configuration
Response payload:
 
  • contrast -- int
  • invert -- bool

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

request/oled_128x64_bricklet/<UID>/get_identity
Response payload:
 
  • uid -- string
  • connected_uid -- string
  • position -- string
  • hardware_version -- [int,int,int]
  • firmware_version -- [int,int,int]
  • device_identifier -- int (has symbols)
  • _display_name -- 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' or 'd'.

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 128x64's name in a human readable form.