DMX512

https://en.wikipedia.org/wiki/DMX512

../../../../../../_images/dmx512-decoder.jpg

Written to support DMX lighting controllers for dimmable lights. The model shown is for controlling RGB LED strip lighting.

DMX512 uses the RS485 physical interface, but a different protocol and usually higher baud rates than MODBUS. Nevertheless, it is possible to mix difference device types on the same network.

Requests to other devices will generally appear as garbage so shouldn’t have any bad side-effects.

namespace IO::DMX512
class Device : public IO::RS485::Device
#include <Device.h>

Public Functions

virtual IO::Request *createRequest() override

Create a request object for this device.

Returns

Request* – Caller must destroy or submit the request

inline virtual DevNode::ID nodeIdMax() const override

Get maximum valid Node ID for this device.

inline virtual uint16_t maxNodes() const override

Determine maximum number of nodes supported by the devicce.

Returns

uint16_t – 0 if device doesn’t support nodes

virtual void handleEvent(IO::Request *request, Event event) override

Implementations may override this method to customise event handling.

struct Config
#include <Device.h>

DMX512 Device Configuration.

Public Members

IO::RS485::Device::Config rs485

RS485 config.

uint8_t nodeCount

Number of nodes controlled by this device.

class Factory : public IO::Device::Factory
#include <Device.h>

Public Functions

inline virtual IO::Device *createDevice(IO::Controller &controller, const char *id) const override

Create a new device instance.

Called by DeviceManager::createDevice()

Parameters
  • controller – The owning controller

  • id – Unique identifier for the device

Returns

Device* – The constructed instance

inline virtual const FlashString &controllerClass() const override

Return the expected controller type for this device class, e.g. ‘rs485’.

The Device Manager uses this value to verify that devices are constructed using the correct controller.

inline virtual const FlashString &deviceClass() const override

Return the Device class name, e.g. ‘r421a’.

struct NodeData
#include <Device.h>
class Request : public IO::Request
#include <Request.h>

Public Functions

virtual ErrorCode parseJson(JsonObjectConst json) override

Fill this request from a JSON description.

virtual void getJson(JsonObject json) const override

Get result of a completed request in JSON format.

virtual bool setNode(DevNode node) override

If nodes are supported, implemented this method.

inline virtual bool nodeAdjust(DevNode node, int value) override

If nodes support analogue state (e.g. brightness) the implement this method.

virtual void submit() override

Submit a request.

The request is added to the controller’s queue. If the queue is empty, it starts execution immediately. The result of the request is posted to the callback routine.