Loads, saves, and syncs a face's settings from its field table. More...
Files | |
| file | src/c/pebble/system/settings/setting_values.h |
| Named values for the multi-choice settings. | |
| file | src/c/pebble/system/settings/settings.c |
| The persist API implementation. | |
| file | src/c/pebble/system/settings/settings.h |
| The persist API. A per-face SettingField table drives versioned load and save, sanitizing, the typed reads, and the AppMessage round trip, so the shared code never names or hardcodes a single field. | |
| file | src/c/pebble/system/settings/settings_catalog.h |
| The shared catalog of known settings. A KNOWN_* macro per setting bakes in its neutral wire key, encoding, bounds, default, and side effects. | |
Data Structures | |
| struct | SettingField |
| Blueprint for a single setting. More... | |
| struct | SettingsSchema |
| A face's persistence identity. More... | |
| struct | SettingsInbound |
| Carries what an inbound settings message changed, so the caller can react. More... | |
Macros | |
| #define | SETTINGS_BLOB_SIZE(blob) |
| The size of a settings struct, for a schema's blob_size, and a build that stops when the struct is too big to save. | |
| #define | KNOWN_TEMPERATURE_UNIT(off) |
| Setting definition for Temperature Unit (Celsius or Fahrenheit). | |
| #define | KNOWN_DATE_FORMAT(off, dflt) |
| Setting definition for Date Format. | |
| #define | KNOWN_THEME(off, count) |
| Setting definition for Theme. | |
| #define | KNOWN_HEADER_FONT(off, count) |
| Setting definition for Header Font, an index into the face's own header font table. | |
| #define | KNOWN_STEPS_MODE(off, count) |
| Setting definition for Steps Mode. | |
| #define | KNOWN_DISTANCE_UNIT(off, count) |
| Setting definition for Distance Unit. | |
| #define | KNOWN_TIME_FORMAT(off, count) |
| Setting definition for Time Format. | |
| #define | KNOWN_BLUETOOTH_ICON(off) |
| Setting definition for Bluetooth Icon. | |
| #define | KNOWN_QUIET_TIME_ICON(off) |
| Setting definition for the Quiet Time Icon. | |
| #define | KNOWN_BLUETOOTH_VIBE_CONNECT(off, count) |
| Setting definition for Bluetooth Vibe Connect. | |
| #define | KNOWN_BLUETOOTH_VIBE_DISCONNECT(off, count) |
| Setting definition for Bluetooth Vibe Disconnect. | |
| #define | KNOWN_HOURLY_VIBE(off, count) |
| Setting definition for the Hourly Vibration (a VibeChoice fired at the top of each hour). | |
| #define | KNOWN_BATTERY_DISPLAY(off, count) |
| Setting definition for Battery Display (icon + percent / icon / percent). | |
Typedefs | |
| typedef struct SettingsSchema | SettingsSchema |
| A face's persistence identity. | |
Functions | |
| void | settings_init (const SettingsSchema *schema) |
| Load a face's settings from their saved blobs, applying defaults first. | |
| bool | settings_was_fresh (void) |
| Whether the watch booted with no saved settings, because storage was wiped by a fresh install or an update. Lets the phone know it should push its own config back rather than trust the watch's defaults. | |
| void | settings_save (void) |
| Persist the active face's structs under their keys (the whole chain). | |
| void | settings_mark_restored (void) |
| Clears settings_was_fresh once a save or restore from the settings page has been saved. | |
| uint8_t | settings_u8 (SettingId id) |
| Read a known uint8/bool setting by id. | |
| const char * | settings_str (SettingId id) |
| Read a known string setting by id. | |
| void | settings_set_u8 (SettingId id, uint8_t value) |
| Write a known uint8 or enum setting by id. In memory only, does not persist. | |
| uint8_t | settings_enum_count (SettingId id) |
| How many values an enum setting allows (its sanitize ceiling). | |
| uint32_t | settings_serialized_size_max (void) |
| The most outbox bytes every field of the active face could ever take once written. | |
| bool | settings_serialize (DictionaryIterator *iter) |
| Write every field of the active face into an outbox iterator. | |
| SettingsInbound | settings_apply_inbox (DictionaryIterator *iter) |
| Apply any settings present in an inbox message to the active face. | |
Loads, saves, and syncs a face's settings from its field table.
A face hands it a field table, and it handles persist and the phone sync without naming any single setting itself.
| #define KNOWN_BATTERY_DISPLAY | ( | off, | |
| count ) |
Setting definition for Battery Display (icon + percent / icon / percent).
| off | Offset into the face's settings struct. |
| count | The number of enum values. |
| #define KNOWN_BLUETOOTH_ICON | ( | off | ) |
Setting definition for Bluetooth Icon.
| off | Offset into the face's settings struct. |
| #define KNOWN_BLUETOOTH_VIBE_CONNECT | ( | off, | |
| count ) |
Setting definition for Bluetooth Vibe Connect.
| off | Offset into the face's settings struct. |
| count | The number of enum values. |
| #define KNOWN_BLUETOOTH_VIBE_DISCONNECT | ( | off, | |
| count ) |
Setting definition for Bluetooth Vibe Disconnect.
| off | Offset into the face's settings struct. |
| count | The number of enum values. |
| #define KNOWN_DATE_FORMAT | ( | off, | |
| dflt ) |
Setting definition for Date Format.
| off | Offset into the face's settings struct. |
| dflt | The default format string. |
| #define KNOWN_DISTANCE_UNIT | ( | off, | |
| count ) |
Setting definition for Distance Unit.
| off | Offset into the face's settings struct. |
| count | The number of enum values. |
| #define KNOWN_HEADER_FONT | ( | off, | |
| count ) |
Setting definition for Header Font, an index into the face's own header font table.
| off | Offset into the face's settings struct. |
| count | How many fonts the face's table holds. |
| #define KNOWN_HOURLY_VIBE | ( | off, | |
| count ) |
Setting definition for the Hourly Vibration (a VibeChoice fired at the top of each hour).
| off | Offset into the face's settings struct. |
| count | The number of enum values. |
| #define KNOWN_QUIET_TIME_ICON | ( | off | ) |
Setting definition for the Quiet Time Icon.
| off | Offset into the face's settings struct. |
| #define KNOWN_STEPS_MODE | ( | off, | |
| count ) |
Setting definition for Steps Mode.
| off | Offset into the face's settings struct. |
| count | The number of enum values. |
| #define KNOWN_TEMPERATURE_UNIT | ( | off | ) |
Setting definition for Temperature Unit (Celsius or Fahrenheit).
Every face wires this the same way, so it takes no count: there are two units and there is never going to be a third. Changing it converts the weather already on the watch and asks for fresh weather in the new unit.
| off | Offset into the face's settings struct. |
| #define KNOWN_THEME | ( | off, | |
| count ) |
Setting definition for Theme.
| off | Offset into the face's settings struct. |
| count | The number of enum values. |
| #define KNOWN_TIME_FORMAT | ( | off, | |
| count ) |
Setting definition for Time Format.
| off | Offset into the face's settings struct. |
| count | The number of enum values. |
| #define SETTINGS_BLOB_SIZE | ( | blob | ) |
The size of a settings struct, for a schema's blob_size, and a build that stops when the struct is too big to save.
One persist key holds at most 256 bytes, and the watch saves only the first 256 bytes of a longer write. The fields past that would come back as their defaults on every launch. settings_init and settings_save log it at runtime, and this stops the build instead, so a face with more than 256 bytes of settings moves some into a companion schema.
| blob | The settings struct itself, not a pointer to it. |
| typedef struct SettingsSchema SettingsSchema |
A face's persistence identity.
Its storage key, current schema version, frozen v1 blob size, the face struct to load into (its first byte must be the uint8_t version), that struct's size, the field table that drives defaults/sanitize/serialization, and an optional migration hook to rescue pre-versioned data.
A face can persist more than one struct by chaining schemas through companion: each schema points to the next and the last one is NULL. settings_init walks the chain so load, save, serialize, and inbox decode all cover every schema. Each link owns its own key, version, and blob, so a domain (e.g. weather or a colour table) can sit in its own key instead of bloating the main one. The typed reads (settings_u8/str) index the whole chain and remember each field's owning schema, so a shared field (id < SETTING_COUNT) can live in any link.
| enum BatteryDisplay |
| enum DistanceUnit |
| enum SettingId |
Identity of a known (shared) setting, used for typed reads and indexing.
Face-only settings sit in the same field table but carry an id of SETTING_COUNT or greater, so they are serialized yet never indexed for a shared read.
| Enumerator | |
|---|---|
| SETTING_TEMPERATURE_UNIT | Celsius or Fahrenheit. |
| SETTING_DATE_FORMAT | The date line's format string. |
| SETTING_THEME | Which theme is active. |
| SETTING_STEPS_MODE | Steps, miles, or km on the steps readout. |
| SETTING_DISTANCE_UNIT | Km or miles on the standalone Distance panel. |
| SETTING_TIME_FORMAT | Which TimeFormat the clock uses. |
| SETTING_BLUETOOTH_ICON | Whether the bluetooth icon shows. |
| SETTING_QUIET_TIME_ICON | Whether the Quiet Time mark shows. |
| SETTING_BLUETOOTH_VIBE_CONNECT | Vibe pattern to fire when the phone connects. |
| SETTING_BLUETOOTH_VIBE_DISCONNECT | Vibe pattern to fire when the phone drops. |
| SETTING_HOURLY_VIBE | Vibe pattern to fire on the hour. |
| SETTING_BATTERY_DISPLAY | What the battery readout shows. |
| SETTING_HEADER_FONT | Which font the panel header labels use, as an index into the face's header font table. |
| SETTING_COUNT | How many known settings there are. |
| enum SettingType |
How a setting encodes on the wire and how the sanitize pass clamps it.
| enum StepsMode |
| enum TimeFormat |
SETTING_TIME_FORMAT choices.
| enum VibeChoice |
| SettingsInbound settings_apply_inbox | ( | DictionaryIterator * | iter | ) |
Apply any settings present in an inbox message to the active face.
Decodes only. The caller persists and reacts based on the returned flags.
A field already holding what the message carries is left alone and flags nothing. The config page sends the whole page on every save, so the flags say what moved rather than what turned up.
| iter | The dictionary iterator to decode from. |
| uint8_t settings_enum_count | ( | SettingId | id | ) |
How many values an enum setting allows (its sanitize ceiling).
Lets a walk step through every option of an enum (e.g. every theme) without hand-counting.
| id | The known enum setting. |
| void settings_init | ( | const SettingsSchema * | schema | ) |
Load a face's settings from their saved blobs, applying defaults first.
Walks the companion chain so every schema in it is loaded. A saved blob is read only when its size and version fit the schema, or when the schema's migrate hook takes it, and every field read back is cleaned. A blob that fits neither is dropped and the schema stays on its defaults. A schema over the 256 bytes one persist key holds is logged as an error, since it can never be saved whole.
| schema | The head schema defining the face's settings. |
| void settings_mark_restored | ( | void | ) |
Clears settings_was_fresh once a save or restore from the settings page has been saved.
Only that message counts. Anything else the phone sends while the watch is fresh stays in memory, so the phone still sees a fresh watch and pushes its whole config back.
| void settings_save | ( | void | ) |
Persist the active face's structs under their keys (the whole chain).
A struct that does not reach flash whole is logged as an error and not tried again.
| bool settings_serialize | ( | DictionaryIterator * | iter | ) |
Write every field of the active face into an outbox iterator.
Stops at the first field that does not fit. The transport opens its outbox at settings_serialized_size_max, so the whole snapshot fits.
| iter | The dictionary iterator to encode into. |
| uint32_t settings_serialized_size_max | ( | void | ) |
The most outbox bytes every field of the active face could ever take once written.
Counts each string as filling its whole buffer, so no later settings change can outgrow it. The transport sizes its outbox from this when it opens.
| void settings_set_u8 | ( | SettingId | id, |
| uint8_t | value ) |
Write a known uint8 or enum setting by id. In memory only, does not persist.
The write-side mirror of settings_u8. Does nothing if the active face isn't subscribed to the id. Used by the dev theme walk to force a theme without touching persistence.
| id | The known setting to write. |
| value | The value to store. |
| const char * settings_str | ( | SettingId | id | ) |
Read a known string setting by id.
| id | The known setting to read. |
| uint8_t settings_u8 | ( | SettingId | id | ) |
Read a known uint8/bool setting by id.
| id | The known setting to read. |
| bool settings_was_fresh | ( | void | ) |
Whether the watch booted with no saved settings, because storage was wiped by a fresh install or an update. Lets the phone know it should push its own config back rather than trust the watch's defaults.