openHAB - DMX Bricklet

Warning

The openHAB bindings are still in beta, but the development was stopped.

This is the description of the openHAB API bindings for the DMX Bricklet. General information and technical specifications for the DMX Bricklet are summarized in its hardware description.

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

Examples

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

Master

Download (ExampleMaster.rules)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
// For this example configure your DMX Bricklet to Master Mode in Paper UI.

rule "send"
when
    System started // Replace with trigger of your choice
then
    // Change XYZ to the UID of your DMX Bricklet
    val dmxActions = getActions("tinkerforge", "tinkerforge:brickletdmx:XYZ")
    // Write DMX frame with 3 channels
    dmxActions.brickletDMXWriteFrame(newArrayList(255, 128, 0))
end

Slave

Download (ExampleSlave.rules)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
// For this example configure your DMX Bricklet to Slave Mode in Paper UI.

import java.util.Arrays

rule "receive"
when
    // Change XYZ to the UID of your DMX Bricklet
    Channel "tinkerforge:brickletdmx:XYZ:BrickletDMXFrameAvailable" triggered
then
    // Change XYZ to the UID of your DMX Bricklet
    val dmxActions = getActions("tinkerforge", "tinkerforge:brickletdmx:XYZ")
    val frame = dmxActions.brickletDMXReadFrame()

    logInfo("Example", "Frame Number:" + frame.get("frameNumber"))
    logInfo("Example", "Frame:" + Arrays.toString(frame.get("frame") as int[]))
end

Thing

UID:
  • tinkerforge:brickletdmx:[UID]
Required firmware version:
  • 2.0.0
Firmware update supported:
  • yes
Channels:
Actions:
Parameters:
  • DMX Mode – Type: Choice, Default: Master
  • Sets the DMX mode to either master or slave.
  • Options: Master, Slave

  • Communication LED – Type: Choice, Default: Show Communication
  • By default the LED shows communication traffic, it flickers once for every 10 received data packets. You can also turn the LED permanently on/off or show a heartbeat. If the Bricklet is in bootloader mode, the LED is off.
  • Options: Off, On, Show Heartbeat, Show Communication

  • Error LED Configuration – Type: Choice, Default: Show Error
  • By default the error LED turns on if there is any error (see Frame Error Count Channel). If you call this function with the Show-Error option again, the LED will turn off until the next error occurs. You can also turn the LED permanently on/off or show a heartbeat. If the Bricklet is in bootloader mode, the LED is off.
  • Options: Off, On, Show Heartbeat, Show Error

  • Frame Duration – Type: integer, Default: -1, Min: -1, Max: 65535
  • The duration of a frame. Example: If you want to achieve 20 frames per second, you should set the frame duration to 50ms (50ms * 20 = 1 second). If you always want to send a frame as fast as possible you can set this value to 0. To disable the frame started channel set this value to -1. This setting is only used in master mode.

  • Status LED Configuration – Type: Choice, Default: Show Status
  • The status LED configuration. By default the LED shows communication traffic between Brick and Bricklet, it flickers once for every 10 received data packets. You can also turn the LED permanently on/off or show a heartbeat. If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
  • Options: Off, On, Show Heartbeat, Show Status

Channels

Frame Started

This channel is triggered directly after a new frame render is started. You should send the data for the next frame directly after this listener was triggered.

Type:
  • Trigger (system.trigger)
UID:
  • tinkerforge:brickletdmx:[UID]:BrickletDMXFrameStarted
Read only:
  • No
Predicate:
  • This channel will only be available if DMX Mode is Master.
Frame Available

This channel is triggered in slave mode when a new frame was received from the DMX master and it can be read out. You have to read the frame before the master has written the next frame using the readFrame action.

Type:
  • Trigger (system.trigger)
UID:
  • tinkerforge:brickletdmx:[UID]:BrickletDMXFrameAvailable
Read only:
  • No
Predicate:
  • This channel will only be available if DMX Mode is Slave.
Overrun Error Count

The number of occurred overrun errors

Type:
  • Number:Dimensionless
UID:
  • tinkerforge:brickletdmx:[UID]:BrickletDMXOverrunErrorCount
Read only:
  • Yes
Framing Error Count

The number of occurred framing errors

Type:
  • Number:Dimensionless
UID:
  • tinkerforge:brickletdmx:[UID]:BrickletDMXFramingErrorCount
Read only:
  • Yes
Clear Error LED

Clears the error LED.

Type:
  • Commands (String)
UID:
  • tinkerforge:brickletdmx:[UID]:BrickletDMXClearErrorLED
Read only:
  • No
Predicate:
  • This channel will only be available if Error LED Configuration is Show Error.
Commands:
  • Accepts any string

Actions

Actions can be used in rules by creating an action object. All actions return a Map<String, Object>. Returned values can be accessed by name, sometimes the type deduction needs some hints, as shown below:

val actions = getActions("tinkerforge", "tinkerforge:brickletdmx:[UID]")
val hwVersion = actions.brickletDMXGetIdentity().get("hardwareVersion") as short[]
logInfo("Example", "Hardware version: " + hwVersion.get(0) + "." + hwVersion.get(1) + "." + hwVersion.get(2))

Basic Actions

brickletDMXWriteFrame(int[] frame)
Parameters:
  • frame – Type: int[], Length: variable, Range: [0 to 255]

Writes a DMX frame. The maximum frame size is 512 byte. Each byte represents one channel.

The next frame can be written after the Frame Started channel was called. The frame is double buffered, so a new frame can be written as soon as the writing of the prior frame starts.

The data will be transfered when the next frame duration ends, see the thing configuration.

Generic approach:

  • Set the frame duration to a value that represents the number of frames per second you want to achieve.
  • Set channels for first frame.
  • Wait for the Frame Started channel.
  • Set channels for next frame.
  • Wait for the Frame Started channel.
  • and so on.

This approach ensures that you can set new DMX data with a fixed frame rate.

This function can only be called in master mode.

brickletDMXGetDMXMode()
Return Map:
  • dmxMode – Type: int, Range: See constants, Default: 0

Returns the DMX mode, as set by the thing configuration.

The following constants are available for this function:

For dmxMode:

  • val DMX_MODE_MASTER = 0
  • val DMX_MODE_SLAVE = 1
brickletDMXReadFrame()
Return Map:
  • frame – Type: int[], Length: variable, Range: [0 to 255]
  • frameNumber – Type: long, Range: [0 to 232 - 1]

Returns the last frame that was written by the DMX master. The size of the array is equivalent to the number of channels in the frame. Each byte represents one channel.

The next frame is available after the Frame Available channel was called.

Generic approach:

The frame number starts at 0 and it is increased by one with each received frame.

This function can only be called in slave mode.

brickletDMXGetFrameDuration()
Return Map:
  • frameDuration – Type: int, Unit: 1 ms, Range: [0 to 216 - 1], Default: 100

Returns the frame duration as set by the thing configuration.

Advanced Actions

brickletDMXGetFrameErrorCount()
Return Map:
  • overrunErrorCount – Type: long, Range: [0 to 232 - 1]
  • framingErrorCount – Type: long, Range: [0 to 232 - 1]

Returns the current number of overrun and framing errors.

brickletDMXGetCommunicationLEDConfig()
Return Map:
  • config – Type: int, Range: See constants, Default: 3

Returns the configuration as set by the thing configuration

The following constants are available for this function:

For config:

  • val COMMUNICATION_LED_CONFIG_OFF = 0
  • val COMMUNICATION_LED_CONFIG_ON = 1
  • val COMMUNICATION_LED_CONFIG_SHOW_HEARTBEAT = 2
  • val COMMUNICATION_LED_CONFIG_SHOW_COMMUNICATION = 3
brickletDMXGetErrorLEDConfig()
Return Map:
  • config – Type: int, Range: See constants, Default: 3

Returns the configuration as set by Clear Error LED.

The following constants are available for this function:

For config:

  • val ERROR_LED_CONFIG_OFF = 0
  • val ERROR_LED_CONFIG_ON = 1
  • val ERROR_LED_CONFIG_SHOW_HEARTBEAT = 2
  • val ERROR_LED_CONFIG_SHOW_ERROR = 3
brickletDMXGetChipTemperature()
Return Map:
  • temperature – Type: int, Unit: 1 °C, Range: [-215 to 215 - 1]

Returns the temperature as measured inside the microcontroller. The value returned is not the ambient temperature!

The temperature is only proportional to the real temperature and it has bad accuracy. Practically it is only useful as an indicator for temperature changes.

brickletDMXGetStatusLEDConfig()
Return Map:
  • config – Type: int, Range: See constants, Default: 3

Returns the configuration as set by the thing configuration

The following constants are available for this function:

For config:

  • val STATUS_LED_CONFIG_OFF = 0
  • val STATUS_LED_CONFIG_ON = 1
  • val STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2
  • val STATUS_LED_CONFIG_SHOW_STATUS = 3
brickletDMXGetSPITFPErrorCount()
Return Map:
  • errorCountAckChecksum – Type: long, Range: [0 to 232 - 1]
  • errorCountMessageChecksum – Type: long, Range: [0 to 232 - 1]
  • errorCountFrame – Type: long, Range: [0 to 232 - 1]
  • errorCountOverflow – Type: long, Range: [0 to 232 - 1]

Returns the error count for the communication between Brick and Bricklet.

The errors are divided into

  • ACK checksum errors,
  • message checksum errors,
  • framing errors and
  • overflow errors.

The errors counts are for errors that occur on the Bricklet side. All Bricks have a similar function that returns the errors on the Brick side.

brickletDMXReset()

Calling this function will reset the Bricklet. All configurations will be lost.

After a reset you have to create new device objects, calling functions on the existing ones will result in undefined behavior!

brickletDMXGetIdentity()
Return Map:
  • uid – Type: String, Length: up to 8
  • connectedUid – Type: String, Length: up to 8
  • position – Type: char, Range: ['a' to 'h', 'z']
  • hardwareVersion – Type: short[], Length: 3
    • 0: major – Type: short, Range: [0 to 255]
    • 1: minor – Type: short, Range: [0 to 255]
    • 2: revision – Type: short, Range: [0 to 255]
  • firmwareVersion – Type: short[], Length: 3
    • 0: major – Type: short, Range: [0 to 255]
    • 1: minor – Type: short, Range: [0 to 255]
    • 2: revision – Type: short, Range: [0 to 255]
  • deviceIdentifier – Type: int, Range: [0 to 216 - 1]

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

Internal Actions

brickletDMXReadUID()
Return Map:
  • uid – Type: long, Range: [0 to 232 - 1]

Returns the current UID as an integer. Encode as Base58 to get the usual string version.