go-api-bindings: github.com/Tinkerforge/go-api-bindings/dmx_bricklet Index | Files

package dmx_bricklet

import "github.com/Tinkerforge/go-api-bindings/dmx_bricklet"

DMX master and slave.

See also the documentation here: https://www.tinkerforge.com/en/doc/Software/Bricklets/DMX_Bricklet_Go.html.

Index

Package Files

dmx_bricklet.go

Constants

const DeviceDisplayName = "DMX Bricklet"
const DeviceIdentifier = 285

type BootloaderMode Uses

type BootloaderMode = uint8
const (
    BootloaderModeBootloader                    BootloaderMode = 0
    BootloaderModeFirmware                      BootloaderMode = 1
    BootloaderModeBootloaderWaitForReboot       BootloaderMode = 2
    BootloaderModeFirmwareWaitForReboot         BootloaderMode = 3
    BootloaderModeFirmwareWaitForEraseAndReboot BootloaderMode = 4
)

type BootloaderStatus Uses

type BootloaderStatus = uint8
const (
    BootloaderStatusOK                        BootloaderStatus = 0
    BootloaderStatusInvalidMode               BootloaderStatus = 1
    BootloaderStatusNoChange                  BootloaderStatus = 2
    BootloaderStatusEntryFunctionNotPresent   BootloaderStatus = 3
    BootloaderStatusDeviceIdentifierIncorrect BootloaderStatus = 4
    BootloaderStatusCRCMismatch               BootloaderStatus = 5
)

type CommunicationLEDConfig Uses

type CommunicationLEDConfig = uint8
const (
    CommunicationLEDConfigOff               CommunicationLEDConfig = 0
    CommunicationLEDConfigOn                CommunicationLEDConfig = 1
    CommunicationLEDConfigShowHeartbeat     CommunicationLEDConfig = 2
    CommunicationLEDConfigShowCommunication CommunicationLEDConfig = 3
)

type DMXBricklet Uses

type DMXBricklet struct {
    // contains filtered or unexported fields
}

func New Uses

func New(uid string, ipcon *ipconnection.IPConnection) (DMXBricklet, error)

Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ipcon` is connected.

func (*DMXBricklet) DeregisterFrameAvailableCallback Uses

func (device *DMXBricklet) DeregisterFrameAvailableCallback(registrationId uint64)

Remove a registered Frame Available callback.

func (*DMXBricklet) DeregisterFrameCallback Uses

func (device *DMXBricklet) DeregisterFrameCallback(registrationId uint64)

Remove a registered Frame Low Level callback.

func (*DMXBricklet) DeregisterFrameErrorCountCallback Uses

func (device *DMXBricklet) DeregisterFrameErrorCountCallback(registrationId uint64)

Remove a registered Frame Error Count callback.

func (*DMXBricklet) DeregisterFrameLowLevelCallback Uses

func (device *DMXBricklet) DeregisterFrameLowLevelCallback(registrationId uint64)

Remove a registered Frame Low Level callback.

func (*DMXBricklet) DeregisterFrameStartedCallback Uses

func (device *DMXBricklet) DeregisterFrameStartedCallback(registrationId uint64)

Remove a registered Frame Started callback.

func (*DMXBricklet) GetAPIVersion Uses

func (device *DMXBricklet) GetAPIVersion() [3]uint8

Returns the version of the API definition (major, minor, revision) implemented by this API bindings. This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.

func (*DMXBricklet) GetBootloaderMode Uses

func (device *DMXBricklet) GetBootloaderMode() (mode BootloaderMode, err error)

Returns the current bootloader mode, see SetBootloaderMode.

Associated constants:

* BootloaderModeBootloader
* BootloaderModeFirmware
* BootloaderModeBootloaderWaitForReboot
* BootloaderModeFirmwareWaitForReboot
* BootloaderModeFirmwareWaitForEraseAndReboot

func (*DMXBricklet) GetChipTemperature Uses

func (device *DMXBricklet) GetChipTemperature() (temperature int16, err error)

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.

func (*DMXBricklet) GetCommunicationLEDConfig Uses

func (device *DMXBricklet) GetCommunicationLEDConfig() (config CommunicationLEDConfig, err error)

Returns the configuration as set by SetCommunicationLEDConfig

Associated constants:

* CommunicationLEDConfigOff
* CommunicationLEDConfigOn
* CommunicationLEDConfigShowHeartbeat
* CommunicationLEDConfigShowCommunication

func (*DMXBricklet) GetDMXMode Uses

func (device *DMXBricklet) GetDMXMode() (dmxMode DMXMode, err error)

Returns the DMX mode, as set by SetDMXMode.

Associated constants:

* DMXModeMaster
* DMXModeSlave

func (*DMXBricklet) GetErrorLEDConfig Uses

func (device *DMXBricklet) GetErrorLEDConfig() (config ErrorLEDConfig, err error)

Returns the configuration as set by SetErrorLEDConfig.

Associated constants:

* ErrorLEDConfigOff
* ErrorLEDConfigOn
* ErrorLEDConfigShowHeartbeat
* ErrorLEDConfigShowError

func (*DMXBricklet) GetFrameCallbackConfig Uses

func (device *DMXBricklet) GetFrameCallbackConfig() (frameStartedCallbackEnabled bool, frameAvailableCallbackEnabled bool, frameCallbackEnabled bool, frameErrorCountCallbackEnabled bool, err error)

Returns the frame callback config as set by SetFrameCallbackConfig.

func (*DMXBricklet) GetFrameDuration Uses

func (device *DMXBricklet) GetFrameDuration() (frameDuration uint16, err error)

Returns the frame duration as set by SetFrameDuration.

func (*DMXBricklet) GetFrameErrorCount Uses

func (device *DMXBricklet) GetFrameErrorCount() (overrunErrorCount uint32, framingErrorCount uint32, err error)

Returns the current number of overrun and framing errors.

func (*DMXBricklet) GetIdentity Uses

func (device *DMXBricklet) GetIdentity() (uid string, connectedUid string, position rune, hardwareVersion [3]uint8, firmwareVersion [3]uint8, deviceIdentifier uint16, err error)

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). The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet connected to an `Isolator Bricklet <isolator_bricklet>` is always as position 'z'.

The device identifier numbers can be found `here <device_identifier>`. |device_identifier_constant|

func (*DMXBricklet) GetResponseExpected Uses

func (device *DMXBricklet) GetResponseExpected(functionID Function) (bool, error)

Returns the response expected flag for the function specified by the function ID parameter. It is true if the function is expected to send a response, false otherwise.

For getter functions this is enabled by default and cannot be disabled, because those functions will always send a response. For callback configuration functions it is enabled by default too, but can be disabled by SetResponseExpected. For setter functions it is disabled by default and can be enabled.

Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is sent and errors are silently ignored, because they cannot be detected.

See SetResponseExpected for the list of function ID constants available for this function.

func (*DMXBricklet) GetSPITFPErrorCount Uses

func (device *DMXBricklet) GetSPITFPErrorCount() (errorCountAckChecksum uint32, errorCountMessageChecksum uint32, errorCountFrame uint32, errorCountOverflow uint32, err error)

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.

func (*DMXBricklet) GetStatusLEDConfig Uses

func (device *DMXBricklet) GetStatusLEDConfig() (config StatusLEDConfig, err error)

Returns the configuration as set by SetStatusLEDConfig

Associated constants:

* StatusLEDConfigOff
* StatusLEDConfigOn
* StatusLEDConfigShowHeartbeat
* StatusLEDConfigShowStatus

func (*DMXBricklet) ReadFrame Uses

func (device *DMXBricklet) ReadFrame() (frame []uint8, frameNumber uint32, err error)

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 RegisterFrameAvailableCallback callback was called.

Generic approach:

* Call ReadFrame to get first frame. * Wait for the RegisterFrameAvailableCallback callback. * Call ReadFrame to get second frame. * Wait for the RegisterFrameAvailableCallback callback. * and so on.

Instead of polling this function you can also use the RegisterFrameCallback callback. You can enable it with SetFrameCallbackConfig.

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.

func (*DMXBricklet) ReadFrameLowLevel Uses

func (device *DMXBricklet) ReadFrameLowLevel() (frameLength uint16, frameChunkOffset uint16, frameChunkData [56]uint8, frameNumber uint32, err error)

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 RegisterFrameAvailableCallback callback was called.

Generic approach:

* Call ReadFrame to get first frame. * Wait for the RegisterFrameAvailableCallback callback. * Call ReadFrame to get second frame. * Wait for the RegisterFrameAvailableCallback callback. * and so on.

Instead of polling this function you can also use the RegisterFrameCallback callback. You can enable it with SetFrameCallbackConfig.

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.

func (*DMXBricklet) ReadUID Uses

func (device *DMXBricklet) ReadUID() (uid uint32, err error)

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

func (*DMXBricklet) RegisterFrameAvailableCallback Uses

func (device *DMXBricklet) RegisterFrameAvailableCallback(fn func(uint32)) uint64

This callback 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, see ReadFrame for more details.

The parameter is the frame number, it is increased by one with each received frame.

This callback can be enabled via SetFrameCallbackConfig.

This callback can only be triggered in slave mode.

func (*DMXBricklet) RegisterFrameCallback Uses

func (device *DMXBricklet) RegisterFrameCallback(fn func(uint32, []uint8)) uint64

This callback is called as soon as a new frame is available (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.

This callback can be enabled via SetFrameCallbackConfig.

This callback can only be triggered in slave mode.

Note

If reconstructing the value fails, the callback is triggered with nil for frame.

func (*DMXBricklet) RegisterFrameErrorCountCallback Uses

func (device *DMXBricklet) RegisterFrameErrorCountCallback(fn func(uint32, uint32)) uint64

This callback is called if a new error occurs. It returns the current overrun and framing error count.

func (*DMXBricklet) RegisterFrameLowLevelCallback Uses

func (device *DMXBricklet) RegisterFrameLowLevelCallback(fn func(uint16, uint16, [56]uint8, uint32)) uint64

See RegisterFrameCallback

func (*DMXBricklet) RegisterFrameStartedCallback Uses

func (device *DMXBricklet) RegisterFrameStartedCallback(fn func()) uint64

This callback is triggered as soon as a new frame write is started. You should send the data for the next frame directly after this callback was triggered.

For an explanation of the general approach see WriteFrame.

This callback can be enabled via SetFrameCallbackConfig.

This callback can only be triggered in master mode.

func (*DMXBricklet) Reset Uses

func (device *DMXBricklet) Reset() (err error)

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!

func (*DMXBricklet) SetBootloaderMode Uses

func (device *DMXBricklet) SetBootloaderMode(mode BootloaderMode) (status BootloaderStatus, err error)

Sets the bootloader mode and returns the status after the requested mode change was instigated.

You can change from bootloader mode to firmware mode and vice versa. A change from bootloader mode to firmware mode will only take place if the entry function, device identifier and CRC are present and correct.

This function is used by Brick Viewer during flashing. It should not be necessary to call it in a normal user program.

Associated constants:

* BootloaderModeBootloader
* BootloaderModeFirmware
* BootloaderModeBootloaderWaitForReboot
* BootloaderModeFirmwareWaitForReboot
* BootloaderModeFirmwareWaitForEraseAndReboot
* BootloaderStatusOK
* BootloaderStatusInvalidMode
* BootloaderStatusNoChange
* BootloaderStatusEntryFunctionNotPresent
* BootloaderStatusDeviceIdentifierIncorrect
* BootloaderStatusCRCMismatch

func (*DMXBricklet) SetCommunicationLEDConfig Uses

func (device *DMXBricklet) SetCommunicationLEDConfig(config CommunicationLEDConfig) (err error)

Sets the communication LED configuration. 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.

Associated constants:

* CommunicationLEDConfigOff
* CommunicationLEDConfigOn
* CommunicationLEDConfigShowHeartbeat
* CommunicationLEDConfigShowCommunication

func (*DMXBricklet) SetDMXMode Uses

func (device *DMXBricklet) SetDMXMode(dmxMode DMXMode) (err error)

Sets the DMX mode to either master or slave.

Calling this function sets frame number to 0.

Associated constants:

* DMXModeMaster
* DMXModeSlave

func (*DMXBricklet) SetErrorLEDConfig Uses

func (device *DMXBricklet) SetErrorLEDConfig(config ErrorLEDConfig) (err error)

Sets the error LED configuration.

By default the error LED turns on if there is any error (see RegisterFrameErrorCountCallback callback). 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.

Associated constants:

* ErrorLEDConfigOff
* ErrorLEDConfigOn
* ErrorLEDConfigShowHeartbeat
* ErrorLEDConfigShowError

func (*DMXBricklet) SetFrameCallbackConfig Uses

func (device *DMXBricklet) SetFrameCallbackConfig(frameStartedCallbackEnabled bool, frameAvailableCallbackEnabled bool, frameCallbackEnabled bool, frameErrorCountCallbackEnabled bool) (err error)

Enables/Disables the different callbacks. By default the RegisterFrameStartedCallback callback and RegisterFrameAvailableCallback callback are enabled while the RegisterFrameCallback callback and RegisterFrameErrorCountCallback callback are disabled.

If you want to use the RegisterFrameCallback callback you can enable it and disable the cb:`Frame Available` callback at the same time. It becomes redundant in this case.

func (*DMXBricklet) SetFrameDuration Uses

func (device *DMXBricklet) SetFrameDuration(frameDuration uint16) (err error)

Sets 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.

This setting is only used in master mode.

func (*DMXBricklet) SetResponseExpected Uses

func (device *DMXBricklet) SetResponseExpected(functionID Function, responseExpected bool) error

Changes the response expected flag of the function specified by the function ID parameter. This flag can only be changed for setter (default value: false) and callback configuration functions (default value: true). For getter functions it is always enabled.

Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is sent and errors are silently ignored, because they cannot be detected.

func (*DMXBricklet) SetResponseExpectedAll Uses

func (device *DMXBricklet) SetResponseExpectedAll(responseExpected bool)

Changes the response expected flag for all setter and callback configuration functions of this device at once.

func (*DMXBricklet) SetStatusLEDConfig Uses

func (device *DMXBricklet) SetStatusLEDConfig(config StatusLEDConfig) (err error)

Sets 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.

Associated constants:

* StatusLEDConfigOff
* StatusLEDConfigOn
* StatusLEDConfigShowHeartbeat
* StatusLEDConfigShowStatus

func (*DMXBricklet) SetWriteFirmwarePointer Uses

func (device *DMXBricklet) SetWriteFirmwarePointer(pointer uint32) (err error)

Sets the firmware pointer for WriteFirmware. The pointer has to be increased by chunks of size 64. The data is written to flash every 4 chunks (which equals to one page of size 256).

This function is used by Brick Viewer during flashing. It should not be necessary to call it in a normal user program.

func (*DMXBricklet) WriteFirmware Uses

func (device *DMXBricklet) WriteFirmware(data [64]uint8) (status uint8, err error)

Writes 64 Bytes of firmware at the position as written by SetWriteFirmwarePointer before. The firmware is written to flash every 4 chunks.

You can only write firmware in bootloader mode.

This function is used by Brick Viewer during flashing. It should not be necessary to call it in a normal user program.

func (*DMXBricklet) WriteFrame Uses

func (device *DMXBricklet) WriteFrame(frame []uint8) (err error)

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

The next frame can be written after the RegisterFrameStartedCallback callback 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 SetFrameDuration.

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 RegisterFrameStartedCallback callback. * Set channels for next frame. * Wait for the RegisterFrameStartedCallback callback. * 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.

func (*DMXBricklet) WriteFrameLowLevel Uses

func (device *DMXBricklet) WriteFrameLowLevel(frameLength uint16, frameChunkOffset uint16, frameChunkData [60]uint8) (err error)

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

The next frame can be written after the RegisterFrameStartedCallback callback 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 SetFrameDuration.

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 RegisterFrameStartedCallback callback. * Set channels for next frame. * Wait for the RegisterFrameStartedCallback callback. * 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.

func (*DMXBricklet) WriteUID Uses

func (device *DMXBricklet) WriteUID(uid uint32) (err error)

Writes a new UID into flash. If you want to set a new UID you have to decode the Base58 encoded UID string into an integer first.

We recommend that you use Brick Viewer to change the UID.

type DMXMode Uses

type DMXMode = uint8
const (
    DMXModeMaster DMXMode = 0
    DMXModeSlave  DMXMode = 1
)

type ErrorLEDConfig Uses

type ErrorLEDConfig = uint8
const (
    ErrorLEDConfigOff           ErrorLEDConfig = 0
    ErrorLEDConfigOn            ErrorLEDConfig = 1
    ErrorLEDConfigShowHeartbeat ErrorLEDConfig = 2
    ErrorLEDConfigShowError     ErrorLEDConfig = 3
)

type Function Uses

type Function = uint8
const (
    FunctionSetDMXMode                Function = 1
    FunctionGetDMXMode                Function = 2
    FunctionWriteFrameLowLevel        Function = 3
    FunctionReadFrameLowLevel         Function = 4
    FunctionSetFrameDuration          Function = 5
    FunctionGetFrameDuration          Function = 6
    FunctionGetFrameErrorCount        Function = 7
    FunctionSetCommunicationLEDConfig Function = 8
    FunctionGetCommunicationLEDConfig Function = 9
    FunctionSetErrorLEDConfig         Function = 10
    FunctionGetErrorLEDConfig         Function = 11
    FunctionSetFrameCallbackConfig    Function = 12
    FunctionGetFrameCallbackConfig    Function = 13
    FunctionGetSPITFPErrorCount       Function = 234
    FunctionSetBootloaderMode         Function = 235
    FunctionGetBootloaderMode         Function = 236
    FunctionSetWriteFirmwarePointer   Function = 237
    FunctionWriteFirmware             Function = 238
    FunctionSetStatusLEDConfig        Function = 239
    FunctionGetStatusLEDConfig        Function = 240
    FunctionGetChipTemperature        Function = 242
    FunctionReset                     Function = 243
    FunctionWriteUID                  Function = 248
    FunctionReadUID                   Function = 249
    FunctionGetIdentity               Function = 255
    FunctionCallbackFrameStarted      Function = 14
    FunctionCallbackFrameAvailable    Function = 15
    FunctionCallbackFrameLowLevel     Function = 16
    FunctionCallbackFrameErrorCount   Function = 17
)

type StatusLEDConfig Uses

type StatusLEDConfig = uint8
const (
    StatusLEDConfigOff           StatusLEDConfig = 0
    StatusLEDConfigOn            StatusLEDConfig = 1
    StatusLEDConfigShowHeartbeat StatusLEDConfig = 2
    StatusLEDConfigShowStatus    StatusLEDConfig = 3
)

Package dmx_bricklet imports 5 packages (graph). Updated 2020-05-28. Refresh now. Tools for package owners.