#pragma once // DMX bridge (linux host build): the bridge address "dmx:" names a "dmx_bridge" record. Each of its fixtures // is a led-driver of its own, a led-fixture process (fixture-driver/) with the fixture's MAC: frames the // controller sends to that MAC (or broadcasts) go to the process, and what the process sends comes back as frames // from that MAC, so the fixture registers, joins groups and plays presets like any driver. 40 times a second the // bridge turns every fixture's pixels into its DMX channels (from the fixture's definition), and sends each // universe's 512 channels to the universe's outputs: Art-Net, sACN, or a USB-DMX adapter (Enttec DMX USB Pro or // Open DMX). // // The record: // {name, universes: [{id, name, number, // outputs: [{type: artnet|sacn|dmx_serial, host, port, universe, serial_port, dmx_mode, enabled}], // fixtures: [{id, name, mac, definition, address}]}]} // and a definition ("dmx_definition"): {name, channels: [names], defaults: {name: value}}. // Channel names pick what each slot gets: Red/Green/Blue/White[ n] the fixture's pixel n (numbered groups in // order; White takes the part of the colour common to red, green and blue), Dimmer (or Intensity, Master Dimmer, // Center Brightness) 255, Strobe (or Shutter, Center Strobe) 0, open. Any other slot holds its default. #include #include #include #define BRIDGE_DMX_PREFIX "dmx:" #define DMX_REFRESH_HZ 40 typedef struct bridge_dmx bridge_dmx_t; typedef void (*bridge_dmx_rx_t)(const uint8_t *src_mac, const uint8_t *data, int len); // Start the bridge of record id: its fixtures and outputs come up in the bridge's own thread, so this does not // take the store lock. NULL when out of memory. bridge_dmx_t *bridge_dmx_open(const char *id, bridge_dmx_rx_t rx); // Stop the fixtures and outputs, and free the bridge void bridge_dmx_close(bridge_dmx_t *b); // A frame for dst (broadcast: every fixture). Lost when the fixture is not running, as on air. void bridge_dmx_send(bridge_dmx_t *b, const uint8_t dst[6], const void *data, size_t len); // {"linked", "name", "universes", "fixtures", "running", "hz", "frames", "packets", "errors", "last_error"} void bridge_dmx_status(bridge_dmx_t *b, char *out, size_t n); // The record changed (or was deleted): the running bridge of that id reads it again. Fixtures whose MAC, name and // pixel count are the same keep running. void bridge_dmx_reload(const char *id); // Is mac a fixture of a running DMX bridge? Its address ("dmx:") in addr when it is. bool bridge_dmx_owns_mac(const uint8_t mac[6], char *addr, size_t n);