Drivers
Source:
Drivers.h
Drivers¶
src/light/drivers/Drivers.h:45Inherits:
MoonModule
Top-level container for the drivers: the consumer side of the pipeline.
Owns the shared output buffer, composites every enabled layer into it each frame, and holds the global power, brightness and palette each Correction multiplies with.
Prior art: MoonLight's PhysicalLayer, which owns the display buffer and maps virtual channels into it.
Public Attributes¶
uint8_t brightness = 20
: Global brightness, scaling every channel through a 256-entry LUT.
bool on = true
: Master power.
char relayPins = ""
: The GPIOs that switch the LED power supply, comma-separated; empty on most boards.
bool multicore = true
: Run the drivers' encode on the second core, so a frame costs max(render, encode).
uint8_t palette = 0
: The global active color palette, which every palette-driven effect reads live.
char liveNames_ = {}
const char * livePtrs_ = {}
const char * liveTags_ = {}
uint8_t liveCount_ = 0
: How many scripted palettes the last scan found.
char paletteScript_ = {}
: The scripted palette: a .mlp name, and the binding that runs it. Empty means built-in.
MoonLivePalette paletteScriptModule_
: The engine that runs the selected scripted palette, one per Drivers.
uint8_t motionHold = 30
: How long a powered-off rig keeps tracking before its heads go still, in seconds.
uint16_t offSeconds_ = 0
: Seconds the rig has been off, counted on tick1s; stops climbing once the hold expires.
bool movableNow_ = false
: Whether any enabled driver was aimable last check, so the list rebuilds on the transition.
uint8_t lastRelayPins_ = {}
: The pins driven last time, so clearing the list can still release them.
uint8_t lastRelayCount_ = 0
: How many relay pins were driven last time, so a shrinking list can release the rest.
Public Methods¶
virtual inline const char * acceptsChildRoles() const override
: Which child roles the "+ add" picker offers under Drivers.
virtual inline void release() override
: Release the children, then vacate every static seat this container published.
inline ~Drivers() override
: Stop the worker and free the palette script, for a tree torn down without [release()].
inline void quiesceRenderSplit()
: Stop the core-1 worker so a structural tree mutation can free nodes safely.
inline void publishFixtureChannels()
: Where this rig's fixtures keep their motion channels, as LAYER slots.
inline FixtureChannels fixtureChannels()
: Resolve every enabled driver's preset and fold their motion channels into one map.
inline void refreshLivePalettes()
: Discover the .mlp files this device carries and publish their names to the picker.
inline void setEffects(Effects * layers)
: Bind the Effects container; the source Layer re-resolves on every prepareTree.
inline void setLayer(Layer * layer)
: Pin one Layer directly, for a rig built outside an Effects container.
inline uint8_t effectiveBrightness() const
: The brightness the LUT is built from: 0 when powered off, else the set level.
virtual inline void defineControls() override
: Bind the global controls: power, brightness, relays, palette and the multicore split.
virtual inline void onControlChanged(const char * controlName) override
: React to a control change: re-bake the LUTs, resolve a palette, drive the relay.
inline void applyRelay()
: Drive the power relay: closed while on and brightness is above zero, open otherwise.
virtual inline bool affectsPrepare(const char * name) const override
: Which controls route through the prepare sweep rather than the cheap correction tier.
virtual inline void tick1s() override
: Refresh the read-only renderWait KPI once a second, off the hot path.
inline void updateMotionHold()
: Count the rig's time powered off, and park it once the hold expires.
inline void rebuildAllCorrections()
: Re-resolve every driver's correction without re-preparing the tree.
virtual inline void setup() override
: Publish the fixture layout and the scripted palettes, and close the relay for on.
virtual inline void prepare() override
: Size the composition buffer, engage or drop the core-1 split, publish the summary.
virtual inline bool firstOutputRgb(uint8_t out) const override
: The first driven light's RGB, for a consumer that shows one color for the device.
virtual inline void tick() override
: The hot tick, which by default ticks every enabled child and times each.
inline void tickNonDriverChildren()
: Tick the children that are not drivers, which core 1 never touches.
virtual inline void quiesce() override
: Bring core 1 to a stop, tearing the worker down if it will not come back.
inline bool renderSplitActive() const
: True while the render and encode split is engaged, for diagnostics and tests.
inline uint32_t renderWaitPeakUs() const
: The worst core-0 wait at the frame boundary in the current one-second window, in µs.
inline bool quiesceEncodeForTest()
: Test-only: the frame-boundary wait alone; false means it timed out and disengaged.
Public Static Attributes¶
constexpr uint8_t kMotionHoldNever = 0
: 0: keep tracking, the desk behavior
constexpr uint8_t kMaxRelays = 8
: Relays one device can carry; four is the most any board in the catalog wires.
Public Static Methods¶
static inline const LightSummary * latestSummary()
: The live light-pipeline summary, for the domain-neutral core consumers.
static inline Drivers * active()
: Reach the live Drivers (the one that owns the encode worker) to quiesce it around a mutation.
More info¶
The shared output buffer¶
Blend and map write to arbitrary physical positions through a LUT, so the output is readable only once whole. One enabled layer with a 1:1 unshuffled mapping is the exception: drivers read that layer's buffer directly, giving up parallelism.
Two or more enabled layers composite in Effects order, bottom to top. Drivers owns that because only it sees both the stack order and the output buffer.
Per-driver source window¶
A window-aware driver outputs a contiguous slice, so each driver names its own lights. Reordering drivers changes nothing but tick order.
Naming¶
Capital Drivers is this container; lowercase "driver" is one DriverBase child.
