Skip to content

Control

Source: Control.h

ControlDescriptor

struct ControlDescriptor
src/core/Control.h:227

Public Attributes

void * ptr =

constchar * name =

uintptr_t aux = 0

ControlType type = ControlType::Uint8

int32_t min = 0

int32_t max = 255

bool hidden =

bool readonly =

bool advanced =

bool(* validate =

ControlList

class ControlList
src/core/Control.h:291

The set of controls a MoonModule exposes to the UI — a module's controls_.

Controls bind to a class variable by reference — the descriptor stores a pointer, hot-path code reads the variable directly (zero overhead, no getter/setter). The value lives in the class variable (1–4 bytes); the descriptor is just the metadata UI rendering and persistence need.

Memory footprint: the descriptor stays lean — a variable pointer, a flash name pointer, an aux word (Progress total / Select options), the type enum, the int32 min/max, two UI flag bytes, and an optional validate hook (~48 bytes on a 64-bit host, less on ESP32's 32-bit pointers). Descriptors live in a fixed-capacity per-module array — no per-control heap allocation. A module that overflows the default capacity is probably too complex.

Persistence and dynamic rebuild: control values persist via FilesystemModule, which overlays loaded values through each control's pointer during defineControls(). Calling defineControls() again at runtime (e.g. when a Select changes) clears and rebuilds the set, so only controls relevant to the current mode are shown — this is how conditional hidden flags re-evaluate.

The per-type storage/UI/DMX reference is on ControlType; each addX method below binds one type.

Prior art: MoonLight's addControl binds via reinterpret_cast<uintptr_t>(&variable) with UI types "slider"/"select"/"toggle"/"text"/"display" (https://github.com/ewowi/MoonLight/blob/main/src/MoonBase/Nodes.h#L80).

Public Methods

ControlList() = default : Defaulted constructor.

ControlList(constControlList &) = delete : Deleted constructor.

ControlList(ControlList &&) = delete : Deleted constructor.

inline void addUint8(constchar * name, uint8_t & var, uint8_t min = 0, uint8_t max = 255) : Bind a uint8_t as a 0–255 slider (the preferred default control).

inline void addUint16(constchar * name, uint16_t & var, uint16_t min = 0, uint16_t max = UINT16_MAX) : Bind a uint16_t as a number input.

inline void addInt16(constchar * name, int16_t & var, int16_t min = INT16_MIN, int16_t max = INT16_MAX)

inline void addPin(constchar * name, int8_t & var, int16_t min = -1, int16_t max = MM_MAX_GPIO)

inline void addBool(constchar * name, bool & var)

inline void addText(constchar * name, char * var, uint16_t bufSize = 16, bool()(constchar ) validate = nullptr)

inline void addTextArea(constchar * name, char * var, uint16_t bufSize = 16, bool()(constchar ) validate = nullptr)

inline void addPassword(constchar * name, char * var, uint8_t bufSize = 32)

inline void addReadOnly(constchar * name, char * var, uint8_t bufSize = 32)

inline void addReadOnlyInt(constchar * name, int8_t & var, constchar * unit)

inline void addPalette(constchar * name, uint8_t & var, PaletteOptionsFn optionsFn, uint8_t optionCount)

inline void addSelect(constchar * name, uint8_t & var, constchar *const * options, uint8_t optionCount)

inline void addProgress(constchar * name, uint32_t & var, uint32_t total, bool bytes = true)

inline void addIPv4(constchar * name, uint8_t * var)

inline void addList(constchar * name, ListSource & source)

inline void addButton(constchar * name)

inline void clear()

inline uint8_t count() const

inline const ControlDescriptor & operator[](uint8_t i) const

inline void setHidden(uint8_t i, bool hidden)

inline void setReadOnly(uint8_t i, bool readonly)

inline void setAdvanced(uint8_t i, bool advanced = true)

ListSource

struct ListSource
src/core/Control.h:160

Public Methods

virtual uint8_t listRowCount() const

virtual void writeListRow(JsonSink & sink, uint8_t row) const

virtual inline void writeListRowDetail(JsonSink & sink, uint8_t row) const

virtual inline void writeListOptionSets(JsonSink &) const

virtual inline bool restoreList(constchar , constchar )

virtual inline bool isEditableList() const

virtual inline bool addListRow(uint32_t &)

virtual inline bool deleteListRow(uint32_t)

virtual inline bool moveListRow(uint32_t, uint8_t)

virtual inline bool setListRowField(uint32_t, constchar , constchar )