MQTT - Segment Display 4x7 Bricklet

This is the description of the MQTT API bindings for the Segment Display 4x7 Bricklet. General information and technical specifications for the Segment Display 4x7 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).

Simple

Download (example-simple.txt)

1
2
3
4
5
6
7
# Change XYZ to the UID of your Segment Display 4x7 Bricklet

setup:
    # 102 = 0x66 = the segments to show a 4
    # 91  = 0x5b = the segments to show a 2
    # 79  = 0x4f = the segments to show a 3
    publish {"segments": [102, 91, 91, 79], "brightness": 7, "colon": false} to tinkerforge/request/segment_display_4x7_bricklet/XYZ/set_segments # Will display 4223

API

All published payload to an from the MQTT bindings is in the 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/segment_display_4x7_bricklet/<UID>/set_segments
Request payload:
 
  • segments -- [int,int,int,int]
  • brightness -- int
  • colon -- bool

The 7-segment display can be set with bitmaps. Every bit controls one segment:

Bit order of one segment

For example to set a "5" you would want to activate segments 0, 2, 3, 5 and 6. This is represented by the number 0b01101101 = 0x6d = 109.

The brightness can be set between 0 (dark) and 7 (bright). The colon parameter turns the colon of the display on or off.

request/segment_display_4x7_bricklet/<UID>/get_segments
Response payload:
 
  • segments -- [int,int,int,int]
  • brightness -- int
  • colon -- bool

Returns the segment, brightness and color data as set by request/segment_display_4x7_bricklet/<UID>/set_segments.

Advanced Functions

request/segment_display_4x7_bricklet/<UID>/start_counter
Request payload:
 
  • value_from -- int
  • value_to -- int
  • increment -- int
  • length -- int

Starts a counter with the from value that counts to the to value with the each step incremented by increment. The length of the increment is given in ms.

Example: If you set from to 0, to to 100, increment to 1 and length to 1000, a counter that goes from 0 to 100 with one second pause between each increment will be started.

The maximum values for from, to and increment is 9999, the minimum value is -999.

Using a negative increment allows to count backwards.

You can stop the counter at every time by calling request/segment_display_4x7_bricklet/<UID>/set_segments.

request/segment_display_4x7_bricklet/<UID>/get_counter_value
Response payload:
 
  • value -- int

Returns the counter value that is currently shown on the display.

If there is no counter running a 0 will be returned.

request/segment_display_4x7_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 Segment Display 4x7's name in a human readable form.

Callback Configuration Functions

Callbacks

Callbacks can be registered to receive time critical or recurring data from the device. The registration is done with the corresponding .../register/... topic and an optional suffix. This suffix can be used to deregister the callback later.

Note

Using callbacks for recurring events is always preferred compared to using getters. It will use less USB bandwidth and the latency will be a lot better, since there is no round trip time.

register/segment_display_4x7_bricklet/<UID>/counter_finished
Request payload:
 
  • register -- bool

A callback can be registered for this event by publishing to the .../register/segment_display_4x7_bricklet/<UID>/counter_finished[/<SUFFIX>] topic with the payload "true". An added callback can be removed by publishing to the same topic with the payload "false". To support multiple (de)registrations, e.g. for message filtering, an optional suffix can be used.

If the callback is triggered, a message with it's payload is published under the corresponding .../callback/segment_display_4x7_bricklet/<UID>/counter_finished[/<SUFFIX>] topic for each registered suffix.

This callback is triggered when the counter (see request/segment_display_4x7_bricklet/<UID>/start_counter) is finished.