Kleidos API Search

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.

See also
Settings View Model, Settings Screen & Service, Wi-Fi Admin Portal

Files

file src/settings/label_variant.h
Responsive label selection: pick the longest length-variant that fits.
file src/settings/settings_model.h
Capability-driven, renderer-agnostic settings option model.
file src/settings/settings_value_types.h
The value vocabulary every settings surface shares: value shapes, apply outcomes and the stepper descriptor.

Classes

struct kleidos::settings::LabelVariants
One label's ordered length variants (longest first). More about kleidos::settings::LabelVariants
struct kleidos::settings::LabelFit
Result of resolving a label to a fitting variant. More about kleidos::settings::LabelFit
struct kleidos::settings::ValueBacking
What backs a value/action option (NVS key or an ActionId). More about kleidos::settings::ValueBacking
struct kleidos::settings::SettingsCapabilities
The settings-relevant capabilities of one device. More about kleidos::settings::SettingsCapabilities
struct kleidos::settings::LabelTiers
A label's ordered responsive tiers (full -> medium -> short). More about kleidos::settings::LabelTiers
struct kleidos::settings::SettingsOption
One settings option — pure data, no drawing and no live state. More about kleidos::settings::SettingsOption
struct kleidos::settings::SettingsGroupEntry
One top-level group entry (id + its responsive header label). More about kleidos::settings::SettingsGroupEntry
struct kleidos::settings::DependencyReader
Reads whether the option a row depends on is on right now. More about kleidos::settings::DependencyReader
struct kleidos::settings::StepperSpec
Numeric editor descriptor for a stepper-backed settings option. More about kleidos::settings::StepperSpec

Enumerations

enum class kleidos::settings::SettingsGroup : uint8_t { kleidos::settings::SettingsGroup::DisplayAppearance, kleidos::settings::SettingsGroup::TimeClock, kleidos::settings::SettingsGroup::InteractionInput, kleidos::settings::SettingsGroup::SecurityPrivacy, kleidos::settings::SettingsGroup::Connectivity, kleidos::settings::SettingsGroup::DataBackup, kleidos::settings::SettingsGroup::PowerBattery, kleidos::settings::SettingsGroup::DeviceInfo, kleidos::settings::SettingsGroup::About, kleidos::settings::SettingsGroup::Count }
Top-level settings group. The order is the menu order on every board. More about kleidos::settings::SettingsGroup
enum class kleidos::settings::SettingsSubGroup : uint8_t { kleidos::settings::SettingsSubGroup::None , kleidos::settings::SettingsSubGroup::DeviceInfoAdvanced }
Optional sub-grouping within a group. More about kleidos::settings::SettingsSubGroup
enum class kleidos::settings::SettingsControl : uint8_t { kleidos::settings::SettingsControl::Toggle, kleidos::settings::SettingsControl::Stepper, kleidos::settings::SettingsControl::Picker, kleidos::settings::SettingsControl::Action, kleidos::settings::SettingsControl::Info, kleidos::settings::SettingsControl::Wizard, kleidos::settings::SettingsControl::TextEntry }
How an option is presented and manipulated. More about kleidos::settings::SettingsControl
enum class kleidos::settings::ValueKind : uint8_t { kleidos::settings::ValueKind::None, kleidos::settings::ValueKind::Toggle, kleidos::settings::ValueKind::Step, kleidos::settings::ValueKind::Enum, kleidos::settings::ValueKind::ReadOnly, kleidos::settings::ValueKind::Action }
How a value-bearing option is backed and read (the accessor hint). More about kleidos::settings::ValueKind
enum class kleidos::settings::ActionId : uint8_t
FSM action dispatched when an action/wizard/info option is activated. More about kleidos::settings::ActionId
enum class kleidos::settings::SettingsGate : uint8_t { kleidos::settings::SettingsGate::Common, kleidos::settings::SettingsGate::Backlight, kleidos::settings::SettingsGate::Epaper, kleidos::settings::SettingsGate::Imu, kleidos::settings::SettingsGate::Speaker, kleidos::settings::SettingsGate::SdCard, kleidos::settings::SettingsGate::Gps, kleidos::settings::SettingsGate::KeyboardBacklight, kleidos::settings::SettingsGate::DialPin, kleidos::settings::SettingsGate::NumericPin, kleidos::settings::SettingsGate::OtaCapable, kleidos::settings::SettingsGate::SecureCapable }
Which capability a row requires to appear. More about kleidos::settings::SettingsGate
enum class kleidos::settings::OptionId : uint8_t
Stable identity of every settings option (also the table index space). More about kleidos::settings::OptionId
enum class kleidos::settings::ValueType : uint8_t { kleidos::settings::ValueType::None , kleidos::settings::ValueType::Bool , kleidos::settings::ValueType::Int , kleidos::settings::ValueType::Enum }
How an option's int32_t value should be read by a client. More about kleidos::settings::ValueType
enum class kleidos::settings::ApplyOutcome : uint8_t { kleidos::settings::ApplyOutcome::Stored , kleidos::settings::ApplyOutcome::NotStored , kleidos::settings::ApplyOutcome::NotDelivered }
What a cross-core apply request established. More about kleidos::settings::ApplyOutcome

Functions

template<typename MeasureFn>
LabelFitkleidos::settings::pickLabelVariant (const LabelVariants &label, MeasureFn &&measure, int16_t maxWidth)
Pick the longest variant whose measured width fits a budget.
constexpr boolkleidos::settings::gateAllows (SettingsGate gate, const SettingsCapabilities &caps)
Resolve a gate against a device's capabilities.
template<typename Resolve>
LabelVariantskleidos::settings::buildLabelVariants (const LabelTiers &tiers, Resolve &&resolve, const char **scratch, std::size_t scratchCap)
Build kleidos::settings::LabelVariants from a LabelTiers for one language.
constexpr boolkleidos::settings::isOffered (const SettingsOption &opt, const SettingsCapabilities &caps)
Whether an option is offered on a device (its gate resolves true).
boolkleidos::settings::isListed (const SettingsOption &opt, const SettingsCapabilities &caps, const DependencyReader &deps={})
Whether an option is listed right now: offered on this device, and its SettingsOption::dependsOn parent (if any) is on.
constexpr boolkleidos::settings::isDeviceOnly (OptionId id)
Whether an option is changed on the device alone: the admin portal neither lists nor writes it.
constexpr boolkleidos::settings::needsUnlockSecret (OptionId id)
Whether the admin portal may change an option only with proof of the unlock secret.
constexpr boolkleidos::settings::isDestructive (const SettingsOption &opt)
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_tkleidos::settings::offeredOptionCount (const SettingsCapabilities &caps)
Count the options offered on a device.
constexpr boolkleidos::settings::groupIsShown (SettingsGroup group, const SettingsCapabilities &caps)
Whether a group has at least one offered option on a device.
constexpr const SettingsOption *kleidos::settings::findOption (OptionId id)
Look up an option by id (linear scan over the fixed table).
constexpr ValueTypekleidos::settings::valueTypeOf (OptionId id)
The value shape of id.

Variables

constexpr i18n::StringIdkleidos::settings::kNoLabel
Sentinel meaning "no label id" for an absent variant tier.
constexpr int8_tkleidos::settings::kWhenParentOn
SettingsOption::dependsOnValue for "listed while the parent is on".
constexpr SettingsGroupEntrykleidos::settings::kSettingsGroups []
The nine group headers in menu order, each with full/short tiers.
constexpr std::size_tkleidos::settings::kSettingsGroupCount
Number of top-level groups in kSettingsGroups.
constexpr SettingsOptionkleidos::settings::kSettingsOptions []
Every settings option Kleidos can offer, renderer- and device-agnostic.
constexpr std::size_tkleidos::settings::kSettingsOptionCount
Number of options in kSettingsOptions.

Back to the top

Enumeration Type Documentation

ActionId #

enum class kleidos::settings::ActionId : uint8_t

FSM action dispatched when an action/wizard/info option is activated.

Renderer-agnostic ids; both renderers map them to the same handlers. Value options (toggle/stepper/picker) use None and carry an NVS key instead.

ApplyOutcome #

enum class kleidos::settings::ApplyOutcome : uint8_t

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.

Enumerator
Stored 

Applied on the UI core and written; it survives a reboot.

NotStored 

Applied live; the persisting write did not land.

NotDelivered 

Never applied: no such value, queue full, or no answer in time.

OptionId #

enum class kleidos::settings::OptionId : uint8_t

Stable identity of every settings option (also the table index space).

OptionId::None is the sentinel used by SettingsOption::dependsOn. OptionId::Count is the enumerator count.

SettingsControl #

enum class kleidos::settings::SettingsControl : uint8_t

How an option is presented and manipulated.

Enumerator
Toggle 

Boolean on/off (DST, audio feedback, shake-to-lock, theme).

Stepper 

Bounded numeric with a step (brightness, timers, sweep speed).

Picker 

Single-select from a fixed set (timezone, language, HID layout).

Action 

One-shot command (sync, wipe, admin portal, SD export).

Info 

Read-only panel or value (battery, device info, lockout policy).

Wizard 

Multi-step flow (set clock, change PIN).

TextEntry 

Free text (BLE device name).

SettingsGate #

enum class kleidos::settings::SettingsGate : uint8_t

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::Common rows appear everywhere; the rest resolve against a SettingsCapabilities.

Enumerator
Common 

Every board.

Backlight 

Backlit TFT boards (all except the e-paper CoreInk).

Epaper 

Electrophoretic panel (the CoreInk): refresh mode + polarity.

Imu 

A motion sensor: shake-to-lock and its sensitivity.

Speaker 

A speaker or buzzer the firmware drives: audio feedback.

SdCard 

A microSD slot: the whole Data & Backup group.

Gps 

A GPS receiver: GPS time sync and re-detect.

KeyboardBacklight 

A keyboard with its own light: its level.

DialPin 

Boards whose unlock is the dial: the arc's sweep speed.

NumericPin 

Boards whose unlock secret is a numeric PIN (dial or touch keypad).

OtaCapable 

8 MB of flash and two app slots (not the three 4 MB boards).

SecureCapable 

Can run the hardened build (the same boards as OTA).

SettingsGroup #

enum class kleidos::settings::SettingsGroup : uint8_t

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.

Enumerator
DisplayAppearance 

Display & Appearance: brightness, screen-off, refresh mode, theme.

TimeClock 

Time & Clock: set clock, timezone, DST, 2FA codes, NTP/GPS sync, Wi-Fi networks.

InteractionInput 

Interaction & Input: language, HID layout, audio, shake, PIN dial.

SecurityPrivacy 

Security & Privacy: change the secret, auto-lock, wipes and resets, info.

Connectivity 

Connectivity: BLE hosts and name, admin portal, firmware update.

DataBackup 

Data & Backup: SD export/import, CSV import, keyfile, format.

PowerBattery 

Power & Battery: sleep now, deep-sleep timer, battery info.

DeviceInfo 

Device Info: curated device info and an Advanced sub-page.

About 

About: product and firmware identity, credits.

Count 

Number of groups.

SettingsSubGroup #

enum class kleidos::settings::SettingsSubGroup : uint8_t

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.

Enumerator
None 

Flat row directly under its group.

DeviceInfoAdvanced 

Deep-diagnostics sub-page (heap/silicon/fuses/uptime).

ValueKind #

enum class kleidos::settings::ValueKind : uint8_t

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/hardware). A renderer binds ValueBacking::nvsKey to the real getter/setter for value kinds, and ValueBacking::action to the FSM dispatch for actions/wizards/info.

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 #

enum class kleidos::settings::ValueType : uint8_t

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::None marks the rows that carry no value at all (actions, wizards, info panels) — they are never accepted by applyOptionValue.

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.

Back to the top

Function Documentation

buildLabelVariants() #

template<typename Resolve>
LabelVariants kleidos::settings::buildLabelVariants(const LabelTiers & tiers, Resolve && resolve, const char ** scratch, std::size_t scratchCap)

Build kleidos::settings::LabelVariants from a LabelTiers for one language.

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
NameMeaning
ResolveCallable const char*(i18n::StringId).
Parameters
NameDirectionMeaning
tiersinThe option's ordered label tiers.
resolveinString-id -> text resolver for the active language.
scratchoutCaller storage for the collected pointers (>= 3 slots).
scratchCapinCapacity of scratch (must be >= 3).
Returns
An ordered longest-first variant view over scratch.

findOption() #

const SettingsOption * kleidos::settings::findOption(OptionId id)
constexpr

Look up an option by id (linear scan over the fixed table).

Parameters
NameDirectionMeaning
idinThe option id to find.
Returns
Pointer to the option, or nullptr if id is None/Count/unknown.

gateAllows() #

bool kleidos::settings::gateAllows(SettingsGate gate, const SettingsCapabilities & caps)
constexpr

Resolve a gate against a device's capabilities.

Parameters
NameDirectionMeaning
gateinThe option's capability gate.
capsinThe target device's capability set.
Return values
ValueMeaning
trueThe option is offered on this device.
falseThe device lacks the capability; the row is absent (not greyed).

groupIsShown() #

bool kleidos::settings::groupIsShown(SettingsGroup group, const SettingsCapabilities & caps)
constexpr

Whether a group has at least one offered option on a device.

A group with no offered rows is not shown.

Parameters
NameDirectionMeaning
groupinThe group to test.
capsinThe target device capabilities.
Return values
ValueMeaning
trueif the group should appear on this device.

isDestructive() #

bool kleidos::settings::isDestructive(const SettingsOption & opt)
constexpr

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
NameDirectionMeaning
optinThe option to test.
Return values
ValueMeaning
truefor a destructive action.

isDeviceOnly() #

bool kleidos::settings::isDeviceOnly(OptionId id)
constexpr

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
NameDirectionMeaning
idinThe option to test.
Return values
ValueMeaning
truefor a device-only option.

isListed() #

bool kleidos::settings::isListed(const SettingsOption & opt, const SettingsCapabilities & caps, const DependencyReader & deps = {})
inline

Whether an option is listed right now: offered on this device, and its SettingsOption::dependsOn parent (if any) is on.

Parameters
NameDirectionMeaning
optinThe option to test.
capsinThe target device capabilities.
depsinWhat answers whether a parent is on; the default lists every offered row.
Return values
ValueMeaning
trueif the row is listed now.

isOffered() #

bool kleidos::settings::isOffered(const SettingsOption & opt, const SettingsCapabilities & caps)
constexpr

Whether an option is offered on a device (its gate resolves true).

Parameters
NameDirectionMeaning
optinThe option to test.
capsinThe target device capabilities.
Return values
ValueMeaning
trueif the row should be listed on this device.

needsUnlockSecret() #

bool kleidos::settings::needsUnlockSecret(OptionId id)
constexpr

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
NameDirectionMeaning
idinThe option to test.
Return values
ValueMeaning
truefor an option the portal changes only behind the secret.

offeredOptionCount() #

std::size_t kleidos::settings::offeredOptionCount(const SettingsCapabilities & caps)
constexpr

Count the options offered on a device.

Parameters
NameDirectionMeaning
capsinThe target device capabilities.
Returns
Number of rows the device lists across all groups.

pickLabelVariant() #

template<typename MeasureFn>
LabelFit kleidos::settings::pickLabelVariant(const LabelVariants & label, MeasureFn && measure, int16_t maxWidth)

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::fits false so the caller can fall back to a two-line row. 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
NameMeaning
MeasureFnCallable returning a pixel width for a NUL-terminated string.
Parameters
NameDirectionMeaning
labelinOrdered variant forms (longest first).
measureinWidth measurement functor for the label's atlas rung.
maxWidthinUsable label width in pixels (row minus chrome).
Returns
The chosen variant, its width, its tier index, and whether it fit.

valueTypeOf() #

ValueType kleidos::settings::valueTypeOf(OptionId id)
nodiscardconstexpr

The value shape of id.

Parameters
NameDirectionMeaning
idinOption to classify.
Returns
The option's value type, or ValueType::None when it has no value.

Back to the top

Variable Documentation

kNoLabel #

i18n::StringId kleidos::settings::kNoLabel
inlineconstexpr

Sentinel meaning "no label id" for an absent variant tier.

i18n::StringId::COUNT is never a real string, so it flags a collapsed (blank) medium/short tier.

Back to the top