In development. It changes without notice.
Topic
Settings Model
The options a device has, once for every surface that shows them: their groups, their values and the words for each.
The device's settings screen and the portal read the same model. An option says which boards have it, what kind of value it holds, and how it steps; a label has a long, a medium and a short form, and the one that fits is used.
Files | |
| file | src/ |
| Responsive label selection: pick the longest length-variant that fits. | |
| file | src/ |
| Capability-driven, renderer-agnostic settings option model. | |
| file | src/ |
| The value vocabulary every settings surface shares: value shapes, apply outcomes and the stepper descriptor. | |
Functions | |
| template<typename MeasureFn> | |
| LabelFit | kleidos:: |
| Pick the longest variant whose measured width fits a budget. | |
| constexpr bool | kleidos:: |
| Resolve a gate against a device's capabilities. | |
| template<typename Resolve> | |
| LabelVariants | kleidos:: |
| Build kleidos:: | |
| constexpr bool | kleidos:: |
| Whether an option is offered on a device (its gate resolves true). | |
| bool | kleidos:: |
| Whether an option is listed right now: offered on this device, and its SettingsOption:: | |
| constexpr bool | kleidos:: |
| Whether an option is changed on the device alone: the admin portal neither lists nor writes it. | |
| constexpr bool | kleidos:: |
| Whether the admin portal may change an option only with proof of the unlock secret. | |
| constexpr bool | kleidos:: |
| Whether an option destroys data: the three orthogonal wipes and the SD card format. Every renderer marks these rows (a warning icon and label) so they never look like a harmless row. | |
| constexpr std::size_t | kleidos:: |
| Count the options offered on a device. | |
| constexpr bool | kleidos:: |
| Whether a group has at least one offered option on a device. | |
| constexpr const SettingsOption * | kleidos:: |
| Look up an option by id (linear scan over the fixed table). | |
| constexpr ValueType | kleidos:: |
The value shape of id. | |
Variables | |
| constexpr i18n:: | kleidos:: |
| Sentinel meaning "no label id" for an absent variant tier. | |
| constexpr int8_t | kleidos:: |
| SettingsOption:: | |
| constexpr SettingsGroupEntry | kleidos:: |
| The nine group headers in menu order, each with full/short tiers. | |
| constexpr std::size_t | kleidos:: |
| Number of top-level groups in kSettingsGroups. | |
| constexpr SettingsOption | kleidos:: |
| Every settings option Kleidos can offer, renderer- and device-agnostic. | |
| constexpr std::size_t | kleidos:: |
| Number of options in kSettingsOptions. | |
Enumeration Type Documentation
ActionId #
FSM action dispatched when an action/
Renderer-agnostic ids; both renderers map them to the same handlers. Value options (toggle/None and carry an NVS key instead.
ApplyOutcome #
What a cross-core apply request established.
The portal answers each of these differently, and the difference is the whole point: NotDelivered is the only one where the device is unchanged and "nothing was changed" is a true thing to say. NotStored means the device is already running the new value and only the next boot disagrees — telling the owner "nothing was changed" there leaves the page showing the old value for a setting the device has already adopted.
OptionId #
Stable identity of every settings option (also the table index space).
OptionId:: is the sentinel used by SettingsOption::OptionId:: is the enumerator count.
SettingsControl #
How an option is presented and manipulated.
SettingsGate #
Which capability a row requires to appear.
A gate never greys a row out — a board lacking the capability simply does not list it. SettingsGate::
SettingsGroup #
Top-level settings group. The order is the menu order on every board.
Identical across every device: a user who learns the menu on one board finds the same groups, in the same places, on any other. A group with no offered options on a given device (all its rows gated out) is simply not shown.
SettingsSubGroup #
Optional sub-grouping within a group.
Most options are flat (None). DeviceInfoAdvanced marks the on-demand deep diagnostics sub-page that hangs off the curated Device Info group.
ValueKind #
How a value-bearing option is backed and read (the accessor hint).
The model carries the shape of the backing, not a live accessor (that would couple it to storage/
| Enumerator | |
|---|---|
| None | No backing (pure navigation into a sub-list). |
| Toggle | Bool NVS value. |
| Step | Integer NVS value edited by a stepper. |
| Enum | Enum-index NVS value chosen by a picker. |
| ReadOnly | Rendered from a live source; never written. |
| Action | Dispatches an ActionId; no stored value. |
ValueType #
How an option's int32_t value should be read by a client.
The wire shape the portal serializes, and the validation class the apply path enforces. ValueType::
| Enumerator | |
|---|---|
| None | Action / wizard / info row: no value to read or write. |
| Bool | 0 or 1. |
| Int | Bounded number in the option's unit (see stepperSpecFor). |
| Enum | Index into the option's choice list. |
Function Documentation
buildLabelVariants() #
Build kleidos::
Resolves the present tiers (skipping kNoLabel) to text via resolve and writes the pointers into scratch (which must outlive the returned view and hold at least three entries). Kept a template over the resolver so the model stays free of an i18n-pool link dependency and is host-testable with a fake string map.
- Template Parameters
-
Name Meaning Resolve Callable const char*(i18n:: StringId).
- Parameters
-
Name Direction Meaning tiers in The option's ordered label tiers. resolve in String-id -> text resolver for the active language. scratch out Caller storage for the collected pointers (>= 3 slots). scratchCap in Capacity of scratch(must be >= 3).
- Returns
- An ordered longest-first variant view over
scratch.
findOption() #
Look up an option by id (linear scan over the fixed table).
- Parameters
-
Name Direction Meaning id in The option id to find.
- Returns
- Pointer to the option, or nullptr if
idis None/Count/ unknown.
gateAllows() #
Resolve a gate against a device's capabilities.
- Parameters
-
Name Direction Meaning gate in The option's capability gate. caps in The target device's capability set.
- Return values
-
Value Meaning true The option is offered on this device. false The device lacks the capability; the row is absent (not greyed).
groupIsShown() #
Whether a group has at least one offered option on a device.
A group with no offered rows is not shown.
- Parameters
-
Name Direction Meaning group in The group to test. caps in The target device capabilities.
- Return values
-
Value Meaning true if the group should appear on this device.
isDestructive() #
Whether an option destroys data: the three orthogonal wipes and the SD card format. Every renderer marks these rows (a warning icon and label) so they never look like a harmless row.
- Parameters
-
Name Direction Meaning opt in The option to test.
- Return values
-
Value Meaning true for a destructive action.
isDeviceOnly() #
Whether an option is changed on the device alone: the admin portal neither lists nor writes it.
The PIN dial style is saved only after the owner dials a practice code with the new style on the device's own keys; a browser cannot run that proof.
- Parameters
-
Name Direction Meaning id in The option to test.
- Return values
-
Value Meaning true for a device-only option.
isListed() #
Whether an option is listed right now: offered on this device, and its SettingsOption::
- Parameters
-
Name Direction Meaning opt in The option to test. caps in The target device capabilities. deps in What answers whether a parent is on; the default lists every offered row.
- Return values
-
Value Meaning true if the row is listed now.
isOffered() #
Whether an option is offered on a device (its gate resolves true).
- Parameters
-
Name Direction Meaning opt in The option to test. caps in The target device capabilities.
- Return values
-
Value Meaning true if the row should be listed on this device.
needsUnlockSecret() #
Whether the admin portal may change an option only with proof of the unlock secret.
The fixed admin network pins the next session's access-point password, the per-session rotation the portal otherwise relies on. Setting or clearing that pair through /api/ap/credentials takes the secret, so the same change through the settings patch takes it too; a session token alone is not proof that the person clicking owns the vault.
- Parameters
-
Name Direction Meaning id in The option to test.
- Return values
-
Value Meaning true for an option the portal changes only behind the secret.
offeredOptionCount() #
Count the options offered on a device.
- Parameters
-
Name Direction Meaning caps in The target device capabilities.
- Returns
- Number of rows the device lists across all groups.
pickLabelVariant() #
Pick the longest variant whose measured width fits a budget.
Walks label from the longest form to the shortest and returns the first whose measured width is within maxWidth. When none fit, returns the shortest form with LabelFit::measure is any callable Integral(const char*) (e.g. a lambda over a Canvas + font role), so this stays pure and testable without a display.
- Template Parameters
-
Name Meaning MeasureFn Callable returning a pixel width for a NUL-terminated string.
- Parameters
-
Name Direction Meaning label in Ordered variant forms (longest first). measure in Width measurement functor for the label's atlas rung. maxWidth in Usable label width in pixels (row minus chrome).
- Returns
- The chosen variant, its width, its tier index, and whether it fit.
valueTypeOf() #
The value shape of id.
- Parameters
-
Name Direction Meaning id in Option to classify.
- Returns
- The option's value type, or ValueType::
None when it has no value.
Variable Documentation
kNoLabel #
Sentinel meaning "no label id" for an absent variant tier.
i18n:: is never a real string, so it flags a collapsed (blank) medium/short tier.