#pragma once // Art-Net and sACN (E1.31) packets: one universe of DMX data each. Shared by the pixel outputs' test // (outputs.c) and the DMX bridge (bridge_dmx.c). #include #include #include #include "cJSON.h" #define DMX_CHANNELS 512 #define ARTNET_PORT 6454 #define SACN_PORT 5568 #define DMX_PACKET_MAX (126 + DMX_CHANNELS) // the larger of the two // ArtDmx for universe uni (15-bit port-address) with sequence seq: n bytes of data (at most 512, padded to an // even length of at least 2). Returns the packet's length. size_t dmx_artnet_packet(uint8_t *pkt, uint8_t seq, int uni, const uint8_t *data, size_t n); // sACN data packet for universe uni (1-63999) from the source cid / name, priority 100, start code 0: n bytes of // data (at most 512). Returns the packet's length. size_t dmx_sacn_packet(uint8_t *pkt, const uint8_t cid[16], const char *source, uint8_t seq, int uni, const uint8_t *data, size_t n); // The multicast group of an sACN universe: 239.255.., host order uint32_t dmx_sacn_group(int uni); // What a fixture's slot gets, from its channel name in the definition (see bridge_dmx.h) enum { DMX_ROLE_FIXED, DMX_ROLE_RED, DMX_ROLE_GREEN, DMX_ROLE_BLUE, DMX_ROLE_WHITE, DMX_ROLE_DIMMER, DMX_ROLE_STROBE }; #define DMX_PIXELS_MAX 64 typedef struct { uint8_t role; uint8_t pixel; // RED..WHITE: the pixel group, 0 first uint8_t value; // FIXED: the default } dmx_slot_t; // Map a "dmx_definition" record ({channels: [names], defaults: {name: value}}) into slots (up to max). // Returns the channel count (0 when the record has none), with the pixel groups (at least 1) in *pixels and // whether any pixel has a white slot in *white. int dmx_def_map(const cJSON *def, dmx_slot_t *slots, int max, int *pixels, bool *white);