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.
The example code below is Public Domain (CC0 1.0).
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
|
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/...
.
request/
segment_display_4x7_bricklet/
<UID>/
set_segments
¶Request: |
|
---|---|
Response: |
|
The 7-segment display can be set with bitmaps. Every bit controls 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
¶Request: |
|
---|---|
Response: |
|
Returns the segment, brightness and color data as set by
request/segment_display_4x7_bricklet/<UID>/set_segments
.
request/
segment_display_4x7_bricklet/
<UID>/
start_counter
¶Request: |
|
---|---|
Response: |
|
Starts a counter with the from value that counts to the to value with the each step incremented by increment. length is the pause between each increment.
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.
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
¶Request: |
|
---|---|
Response: |
|
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
¶Request: |
|
---|---|
Response: |
|
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 Segment Display 4x7's name in a human readable form.
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
¶Register Request: |
|
---|---|
Callback Response: |
|
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.