hyperion.ng
LedDeviceUdpArtNet.h
1 #pragma once
2 
3 // hyperion includes
4 #include "ProviderUdp.h"
5 
6 #include <QUuid>
7 
16 #define ArtNet_DEFAULT_PORT 5568
17 
18 #define DMX_MAX 512 // 512 usable slots
19 
20 // http://stackoverflow.com/questions/16396013/artnet-packet-structure
21 typedef union
22 {
23  struct {
24  char ID[8]; // "Art-Net"
25  uint16_t OpCode; // See Doc. Table 1 - OpCodes eg. 0x5000 OpOutput / OpDmx
26  uint16_t ProtVer; // 0x0e00 (aka 14)
27  uint8_t Sequence; // monotonic counter
28  uint8_t Physical; // 0x00
29  uint8_t SubUni; // low universe (0-255)
30  uint8_t Net; // high universe (not used)
31  uint16_t Length; // data length (2 - 512)
32  uint8_t Data[ DMX_MAX ]; // universe data
33  } __attribute__((packed));
34 
35  uint8_t raw[ 18 + DMX_MAX ];
36 
38 
43 {
44 public:
50  LedDeviceUdpArtNet(const QJsonObject &deviceConfig);
51 
57  bool init(const QJsonObject &deviceConfig);
58 
60  static LedDevice* construct(const QJsonObject &deviceConfig);
61 
62 
63 private:
70  virtual int write(const std::vector<ColorRgb> &ledValues);
71 
72  void prepare(const unsigned this_universe, const unsigned this_sequence, const unsigned this_dmxChannelCount);
73 
74 
75  artnet_packet_t artnet_packet;
76  uint8_t _artnet_seq = 1;
77  uint8_t _artnet_channelsPerFixture = 3;
78  unsigned _artnet_universe = 1;
79 };
The ProviderUdp implements an abstract base-class for LedDevices using UDP packets.
Definition: ProviderUdp.h:15
Interface (pure virtual base class) for LedDevices.
Definition: LedDevice.h:32
bool init(const QJsonObject &deviceConfig)
Sets configuration.
Definition: LedDeviceUdpArtNet.cpp:13
Definition: LedDeviceUdpArtNet.h:21
Implementation of the LedDevice interface for sending led colors via udp/E1.31 packets.
Definition: LedDeviceUdpArtNet.h:42
static LedDevice * construct(const QJsonObject &deviceConfig)
constructs leddevice
Definition: LedDeviceUdpArtNet.cpp:23
LedDeviceUdpArtNet(const QJsonObject &deviceConfig)
Constructs specific LedDevice.
Definition: LedDeviceUdpArtNet.cpp:7