LightPresetsModule
Source:
LightPresetsModule.h
LightPresetsModule¶
src/light/drivers/LightPresetsModule.h:39Inherits:
MoonModule,ListSource
The reusable light-preset library, a Drivers submodule owning NAMED channel-role wirings, each editable in its own row and referenced by many drivers.
A driver stores a preset's STABLE id and resolves it here into its own Correction, so a wiring is built once and reordering other presets disturbs no reference.
A curated set of real fixtures is seeded read-only on first boot. A user adds custom named wirings alongside them. The render loop never reads this module.
Public Methods¶
virtual inline ModuleRole role() const override
: Role for type identification (no RTTI needed).
virtual inline bool userEditable() const override
: Not user-editable: every driver resolves its preset through this one boot-wired library.
inline uint32_t defaultId() const
: The first preset's id: a safe default for a fresh driver or a dangling reference.
inline uint8_t presetCount() const
: How many presets the library holds, for a driver building its preset selector.
inline const char * nameAt(uint8_t i) const
: The name of preset row i, for a driver building its selector.
inline uint32_t idAt(uint8_t i) const
: The stable id of preset row i, which is what a driver stores.
inline uint8_t indexOfId(uint32_t id) const
: The row currently holding id, for rendering a selector at its referenced preset.
inline bool presetHasSynthChannel(uint32_t id) const
: Whether the preset carries a channel the white mode would synthesise.
inline bool deriveCorrection(uint32_t id, uint8_t brightness, Correction & out) const
: Resolve a preset id into a driver's flat Correction; false leaves out untouched.
inline LightPresetsModule()
: Claim the singleton seat at construction, before any driver builds its selector.
virtual inline void setup() override
: Seed the curated built-ins when the set is empty.
virtual inline void prepare() override
: Re-claim the singleton seat, which is a no-op while we already hold it.
virtual inline void release() override
: Vacate the singleton seat, then release the base.
virtual inline void defineControls() override
: Bind the presets list, which the editable-list primitive renders.
virtual inline uint8_t listRowCount() const override
: How many preset rows the list holds.
virtual inline void writeListRow(JsonSink & sink, uint8_t row) const override
: Write one row, which is also the persisted form, so it carries the full wiring.
virtual inline void writeListOptionSets(JsonSink & sink) const override
: Emit the shared channel-role option set every row's selectors reference.
virtual inline void writeListRowDetail(JsonSink & sink, uint8_t row) const override
: Write one row's editable fields: the name, the channel count, and a role per channel.
virtual inline bool isEditableList() const override
: The list is editable, so the UI offers add, delete and reorder.
virtual inline bool addListRow(uint32_t & outId) override
: Add a preset, returning its new stable id.
virtual inline bool deleteListRow(uint32_t id) override
: Delete a preset, refusing a locked built-in.
virtual inline bool moveListRow(uint32_t id, uint8_t to) override
: Move a custom preset, which may not cross into the locked built-in block.
virtual inline bool setListRowField(uint32_t id, const char * field, const char * valueJson) override
: Edit one field of a preset: its name, its channel count, or one channel's role.
virtual inline bool restoreList(const char * json, const char * key) override
: Restore the presets and the role pool, so custom wirings survive a reboot.
Public Static Attributes¶
constexpr uint8_t kMaxPresets = 32
: How many preset rows a device can hold.
Public Static Methods¶
static inline LightPresetsModule * active()
: The boot library, which a driver resolves its preset reference through.
More info¶
What a preset is¶
A channel-role layout: role r at channel i says channel i of a light carries role r. The color roles cover the strip orders, and the fixture roles cover pan, tilt and the rest.
Storage is uncapped¶
A preset is exactly as wide as its fixture. Role bytes live in one dynamic pool, each preset a slice, so a moving head declares as many channels as it has. The pool is touched on the cold path only, leaving it free to reallocate.
The editable-list primitive¶
The first consumer of EditableListSource. The whole add, delete, reorder and edit surface is reused rather than rebuilt. The per-row fields are the name, the channel count, and one role picker per channel.
