Loads, saves, and syncs a face's settings from its field table. More...
Files | |
| file | src/c/pebble/system/settings/plugin_source.h |
| The struct the framework keeps the weather, calendar, and stock source choices in, for a face built with a plugin define, and the checks that decide which of them it keeps. | |
| 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. | |
| file | src/c/pebble/system/settings/settings_chain.h |
| The walk over a face's settings schemas, and the checks a launch makes over them. | |
Data Structures | |
| struct | PluginSourceSettings |
| The saved choices, version byte first. More... | |
| 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 | PLUGIN_SOURCE_KEEPS_WEATHER 0 |
| 1 when the watch keeps the weather source choice, for a face with PLUGIN_WEATHER and WEATHER_PROVIDER | |
| #define | PLUGIN_SOURCE_KEEPS_CALENDAR 0 |
| 1 when the watch keeps the calendar source choice, for a face with PLUGIN_CALENDAR and CALENDAR_SOURCE | |
| #define | PLUGIN_SOURCE_KEEPS_STOCK 0 |
| 1 when the watch keeps the stock source choice, for a face with PLUGIN_STOCKS and STOCK_PROVIDER | |
| #define | PLUGIN_SOURCE_KEEPS_ANY (PLUGIN_SOURCE_KEEPS_WEATHER || PLUGIN_SOURCE_KEEPS_CALENDAR || PLUGIN_SOURCE_KEEPS_STOCK) |
| The watch keeps at least one source choice, so the framework's schema joins the chain. | |
| #define | PLUGIN_SOURCE_WEATHER_LEN 12 |
| The size of the weather source buffer. weatherapi is the longest value the settings page saves, and its 10 characters plus its end leave one byte spare. | |
| #define | PLUGIN_SOURCE_CALENDAR_LEN 8 |
| The size of the calendar source buffer. plugin is the longest value the settings page saves, and its 6 characters plus its end leave one byte spare. | |
| #define | PLUGIN_SOURCE_STOCK_LEN 14 |
| The size of the stock source buffer. alphavantage is the longest value the settings page saves, and its 12 characters plus its end leave one byte spare. | |
| #define | PLUGIN_SOURCE_VERSION 2 |
| The schema's version, raised by one with each appended field. | |
| #define | PLUGIN_SOURCE_FIRST_SIZE 21 |
| The struct's size in its first release, which never changes. | |
| #define | PLUGIN_SOURCE_WEATHER_FIELD |
| The field the framework keeps the weather source in, with a comma after it, or nothing when the watch keeps no weather choice. | |
| #define | PLUGIN_SOURCE_CALENDAR_FIELD |
| The field the framework keeps the calendar source in, with a comma after it, or nothing when the watch keeps no calendar choice. It works as the weather one does. | |
| #define | PLUGIN_SOURCE_STOCK_FIELD |
| The field the framework keeps the stock source in, with a comma after it, or nothing when the watch keeps no stock choice. It works as the weather one does. | |
| #define | PLUGIN_SOURCE_FIELDS PLUGIN_SOURCE_WEATHER_FIELD PLUGIN_SOURCE_CALENDAR_FIELD PLUGIN_SOURCE_STOCK_FIELD |
| The framework schema's whole field table, for inside its braces. | |
| #define | SETTINGS_PLUGIN_SOURCE_KEY 249 |
| The persist key the framework keeps the weather, calendar, and stock source choices on, so a face leaves it free. | |
| #define | SETTINGS_BLOB_SIZE(blob) |
| The size of a settings struct, and a build that stops when the struct is too big to save. SETTINGS_BLOB uses it for a schema's blob_size. | |
| #define | SETTINGS_BLOB(settings, first) |
| Sets a schema's settings struct, its size, and the size it first shipped at, for a schema's initializer. | |
| #define | SETTINGS_FIRST_SIZE_(first, settings) |
| The first size for SETTINGS_BLOB, and a build that stops when it is written as more than one token, or is 0 or past the struct's size. | |
| #define | SETTINGS_COUNT(key) |
| How many choices the settings page offers on a message key, worked out by the build. | |
| #define | SETTINGS_COUNT_CHECKED(key, table_count) |
| The page's count on a message key, checked against the size of the face's own table. | |
| #define | SETTINGS_TEXT_FIELD(blob, member, bytes) |
| A text entry's offset and size, with a build stop when the member is not that size. | |
| #define | SETTINGS_DEFAULT(key) |
| The default the settings page opens with on a message key, worked out by the build. | |
| #define | KNOWN_TEMPERATURE_UNIT(off) |
| Setting definition for Temperature Unit (Celsius or Fahrenheit). | |
| #define | KNOWN_DATE_FORMAT(blob, member) |
| Setting definition for Date Format. | |
| #define | KNOWN_THEME(off, table_count) |
| Setting definition for Theme. | |
| #define | KNOWN_STEPS_MODE(off) |
| Setting definition for Steps Mode. | |
| #define | KNOWN_DISTANCE_UNIT(off) |
| Setting definition for Distance Unit. | |
| #define | KNOWN_TIME_FORMAT(off) |
| 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) |
| Setting definition for Bluetooth Vibe Connect. | |
| #define | KNOWN_BLUETOOTH_VIBE_DISCONNECT(off) |
| Setting definition for Bluetooth Vibe Disconnect. | |
| #define | KNOWN_HOURLY_VIBE(off) |
| Setting definition for the Hourly Vibration (a VibeChoice fired at the top of each hour). | |
| #define | KNOWN_BATTERY_DISPLAY(off) |
| Setting definition for Battery Display (icon + percent / icon / percent). | |
| #define | KNOWN_WIND_UNIT(off) |
| Setting definition for Wind Unit, the WindUnit a wind speed reads out in. | |
| #define | KNOWN_GOAL_STEPS(off) |
| Setting definition for the Step Goal, an index into goals_steps. | |
| #define | KNOWN_GOAL_DISTANCE(off) |
| Setting definition for the Distance Goal, an index into goals_distance_m. | |
| #define | KNOWN_GOAL_CALORIES(off) |
| Setting definition for the Calorie Goal, an index into goals_calories. | |
| #define | KNOWN_GOAL_ACTIVE(off) |
| Setting definition for the Activity Goal, an index into goals_active_min. | |
| #define | KNOWN_GOAL_SLEEP(off) |
| Setting definition for the Sleep Goal, an index into goals_sleep_min. | |
| #define | KNOWN_GOAL_HR(off) |
| Setting definition for the Heart Rate Limit, an index into goals_hr_limit. | |
| #define | KNOWN_GOAL_VIBE(blob, member) |
| Setting definition for the Goal Met Vibration, the pick vibe_goal plays. | |
| #define | KNOWN_GOAL_VIBE_CUSTOM(blob, member) |
| Setting definition for the Custom Vibration Pattern, which vibe_goal plays when the pick is Custom. | |
| #define | SETTINGS_CHAIN_EACH(schema, head, tail) |
| Walks the face's schemas and then the framework's, for a for loop's header. | |
Typedefs | |
| typedef struct SettingsSchema | SettingsSchema |
| A face's persistence identity. | |
Functions | |
| static bool | plugin_source_write_needed (const PluginSourceSettings *now, const PluginSourceSettings *on_flash, bool on_flash_known) |
| Whether a save has to write the choices to flash. | |
| 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. | |
| static const SettingsSchema * | settings_chain_first (const SettingsSchema *head, const SettingsSchema *tail) |
| Where the walk starts. | |
| static const SettingsSchema * | settings_chain_next (const SettingsSchema *schema, const SettingsSchema *tail) |
| The schema after this one in the walk. | |
| static bool | settings_chain_has_field (const SettingsSchema *head, const uint32_t *message_key) |
| Whether a schema in the face's own chain has a field on a message key. | |
| static bool | settings_chain_has_key (const SettingsSchema *head, uint32_t key) |
| Whether a schema in the face's own chain is saved under a persist key. | |
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 | ) |
Setting definition for Battery Display (icon + percent / icon / percent).
| off | Offset into the face's settings struct. |
| #define KNOWN_BLUETOOTH_ICON | ( | off | ) |
Setting definition for Bluetooth Icon.
| off | Offset into the face's settings struct. |
| #define KNOWN_BLUETOOTH_VIBE_CONNECT | ( | off | ) |
Setting definition for Bluetooth Vibe Connect.
| off | Offset into the face's settings struct. |
| #define KNOWN_BLUETOOTH_VIBE_DISCONNECT | ( | off | ) |
Setting definition for Bluetooth Vibe Disconnect.
| off | Offset into the face's settings struct. |
| #define KNOWN_DATE_FORMAT | ( | blob, | |
| member ) |
Setting definition for Date Format.
The default is the one the settings page opens with, from SETTINGS_DEFAULT, so a fresh watch shows the date the page says it does. paf build stops on a page default whose UTF-8 does not fit the 16 bytes with its end. It reads the size from KNOWN_FIELDS in tools/pkjs/settings-page.ts, which a spec checks against this file.
It takes the struct and the member rather than an offset, so the build stops on a member that is not exactly 16 bytes. A shorter one would have the date format written past its end.
| blob | The face's settings struct. |
| member | The char[16] member that holds the date format. |
| #define KNOWN_DISTANCE_UNIT | ( | off | ) |
Setting definition for Distance Unit.
| off | Offset into the face's settings struct. |
| #define KNOWN_GOAL_ACTIVE | ( | off | ) |
Setting definition for the Activity Goal, an index into goals_active_min.
| off | Offset into the face's settings struct. |
| #define KNOWN_GOAL_CALORIES | ( | off | ) |
Setting definition for the Calorie Goal, an index into goals_calories.
| off | Offset into the face's settings struct. |
| #define KNOWN_GOAL_DISTANCE | ( | off | ) |
Setting definition for the Distance Goal, an index into goals_distance_m.
| off | Offset into the face's settings struct. |
| #define KNOWN_GOAL_HR | ( | off | ) |
Setting definition for the Heart Rate Limit, an index into goals_hr_limit.
The page only has the Heart Rate Limit row when the face asks for it with heartRate, so a face that places this without the row stops the build with SETTINGS_COUNT_HEALTH_GOAL_HR undeclared.
| off | Offset into the face's settings struct. |
| #define KNOWN_GOAL_SLEEP | ( | off | ) |
Setting definition for the Sleep Goal, an index into goals_sleep_min.
| off | Offset into the face's settings struct. |
| #define KNOWN_GOAL_STEPS | ( | off | ) |
Setting definition for the Step Goal, an index into goals_steps.
The goal tables are the framework's, in health/goals.h, and the page's rows are the ones goal-rows.ts builds. The count is the page's, from SETTINGS_COUNT, and the build stops when it differs from the table, so a choice the page offers always has a goal behind it. Read it with goals_steps(settings_u8(SETTING_GOAL_STEPS)). The other goal entries work the same way.
| off | Offset into the face's settings struct. |
| #define KNOWN_GOAL_VIBE | ( | blob, | |
| member ) |
Setting definition for the Goal Met Vibration, the pick vibe_goal plays.
The pick is text, empty for None, a letter for a plain pulse or the wearer's own pattern, or a comma list of milliseconds, as goal_vibe_pattern.h reads it. It keeps 64 bytes, room for the longest option the page offers and its end, and goal-rows.spec.ts checks every option fits. A face keeps this and KNOWN_GOAL_VIBE_CUSTOM in a schema of their own when its main struct has no room for them.
It takes the struct and the member rather than an offset, so the build stops on a member that is not exactly 64 bytes. A shorter one would have the pick written past its end.
| blob | The face's settings struct. |
| member | The char[64] member that holds the pick. |
| #define KNOWN_GOAL_VIBE_CUSTOM | ( | blob, | |
| member ) |
Setting definition for the Custom Vibration Pattern, which vibe_goal plays when the pick is Custom.
It keeps 122 bytes, room for the 120 characters the page's box takes and the end of the text. Only a face that offers Custom, with custom on its goal alert rows, has the box and places this.
Like KNOWN_GOAL_VIBE, it takes the struct and the member, so the build stops on a member that is not exactly 122 bytes.
| blob | The face's settings struct. |
| member | The char[122] member that holds the pattern. |
| #define KNOWN_HOURLY_VIBE | ( | off | ) |
Setting definition for the Hourly Vibration (a VibeChoice fired at the top of each hour).
| off | Offset into the face's settings struct. |
| #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 | ) |
Setting definition for Steps Mode.
| off | Offset into the face's settings struct. |
| #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, | |
| table_count ) |
Setting definition for Theme.
The count is how many themes the settings page offers, from SETTINGS_COUNT. The face passes how many its own theme table holds, and the build stops when the two differ, so a theme added to the page and not to the C, or to the C and not the page, never reaches a watch.
| off | Offset into the face's settings struct. |
| table_count | How many themes the face's own table holds, such as its THEME_COUNT. |
| #define KNOWN_TIME_FORMAT | ( | off | ) |
Setting definition for Time Format.
| off | Offset into the face's settings struct. |
| #define KNOWN_WIND_UNIT | ( | off | ) |
Setting definition for Wind Unit, the WindUnit a wind speed reads out in.
Kilometres per hour, then miles per hour, knots, and metres per second, the order the settings page's row lists them. The default is the one the page opens with, from SETTINGS_DEFAULT, and kilometres per hour on a page with no wind unit row. Read it with settings_u8(SETTING_WIND_UNIT) and hand it to wind_from_kmh and wind_unit_label.
| off | Offset into the face's settings struct. |
| #define PLUGIN_SOURCE_WEATHER_FIELD |
The field the framework keeps the weather source in, with a comma after it, or nothing when the watch keeps no weather choice.
It is a face-only text field, so it has no typed read. Its default is the one the build wrote from the face's providers list, which is the settings page's own default. So a watch that never got a save sends back the choice the phone would make anyway.
| #define SETTINGS_BLOB | ( | settings, | |
| first ) |
Sets a schema's settings struct, its size, and the size it first shipped at, for a schema's initializer.
It fills in .blob, .blob_size, and .first_size. The first size is the struct's size in bytes in the first release that saved it, and it never changes after that release. A saved blob smaller than it cannot be this schema's. One from the first size up to today's size reads in, and every field appended since keeps its default. The struct's sizeof rises with each appended field and would turn away every older save, so the first size has to be written as the number itself, or a macro that is one. The build stops on sizeof, SETTINGS_BLOB_SIZE, a sum, brackets, or a cast written in place, and on a first size of 0 or one bigger than the struct. A constant worked out from sizeof somewhere else, such as an enum, still gets through.
| settings | The settings struct itself, not a pointer to it or its type. |
| first | The struct's size in bytes in its first release, such as 25. |
| #define SETTINGS_BLOB_SIZE | ( | blob | ) |
The size of a settings struct, and a build that stops when the struct is too big to save. SETTINGS_BLOB uses it for a schema's blob_size.
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. This stops the build instead, so a face with more than 256 bytes of settings moves some into a companion schema. settings_init logs an error at launch for a schema whose blob_size was filled in without it.
| blob | The settings struct itself, not a pointer to it. |
| #define SETTINGS_CHAIN_EACH | ( | schema, | |
| head, | |||
| tail ) |
Walks the face's schemas and then the framework's, for a for loop's header.
| schema | The name the loop's schema goes by. |
| head | The face's first schema, or NULL for a face with no settings of its own. |
| tail | The framework's schema, or NULL when it keeps none. |
| #define SETTINGS_COUNT | ( | key | ) |
How many choices the settings page offers on a message key, worked out by the build.
paf build reads the face's settings page and writes a count for every select, radio group, and theme picker whose values are all whole numbers from 0 to 254. The count is the highest value plus one, so a value retired from the middle of a list stays reserved. A key with no such control on the page has no count, and naming it here stops the build with SETTINGS_COUNT_<key> undeclared.
A face's own choice field takes its count the same way, as in .enum_count = SETTINGS_COUNT(APPEARANCE_NIGHT_THEME).
| key | The message key without its MESSAGE_KEY_ prefix, such as APPEARANCE_THEME. |
| #define SETTINGS_COUNT_CHECKED | ( | key, | |
| table_count ) |
The page's count on a message key, checked against the size of the face's own table.
The page lists the choices the wearer can pick, and the face's C draws them from a table of its own, such as a theme enum. A choice on the page the table lacks draws nothing, and one in the table the page lacks can never be picked, so the build stops when the two counts differ. The message names the page's count and the table's. The count is the page's, the same as SETTINGS_COUNT.
| key | The message key without its MESSAGE_KEY_ prefix, such as APPEARANCE_THEME. |
| table_count | How many entries the face's own table holds, such as its THEME_COUNT. |
| #define SETTINGS_DEFAULT | ( | key | ) |
The default the settings page opens with on a message key, worked out by the build.
paf build writes one for every control on the page that opens on a value the watch can hold, as the phone reads it: a toggle as 1 or 0, a choice or a whole number as its number, a colour as 0xRRGGBB, and text as a string. A control with no default of its own gives what Clay opens it on. A key a KNOWN_* entry keeps takes that entry's type, and the build stops on a page default that does not fit it. A key with no default on the page has none, and naming it here stops the build with SETTINGS_DEFAULT_<key> undeclared. The KNOWN_* entries fall back to the framework's own default for a key the page does not show.
A face's own field takes its default the same way, as in .default_num = SETTINGS_DEFAULT(APPEARANCE_NIGHT_THEME) or .default_str = SETTINGS_DEFAULT(LAYOUT).
| key | The message key without its MESSAGE_KEY_ prefix, such as CLOCK_DATE_FORMAT. |
| #define SETTINGS_FIRST_SIZE_ | ( | first, | |
| settings ) |
The first size for SETTINGS_BLOB, and a build that stops when it is written as more than one token, or is 0 or past the struct's size.
SETTINGS_BLOB hands the first size on to this away from any ##, so a macro holding a number has become that number by the time it lands here.
| first | The struct's size in bytes in its first release. |
| settings | The settings struct itself. |
| #define SETTINGS_PLUGIN_SOURCE_KEY 249 |
The persist key the framework keeps the weather, calendar, and stock source choices on, so a face leaves it free.
Only a face built with PLUGIN_WEATHER, PLUGIN_CALENDAR, or PLUGIN_STOCKS that offers the choice writes it. Every face leaves it free anyway, for its settings and its stores, since turning a define on in a later release would otherwise land the choice on top of whatever the face kept there. settings_init catches a settings schema on it but cannot see a store's key.
| #define SETTINGS_TEXT_FIELD | ( | blob, | |
| member, | |||
| bytes ) |
A text entry's offset and size, with a build stop when the member is not that size.
A text entry writes a fixed number of bytes, so a member any shorter would have the text written over whatever follows it. The size is named once, so the check and the bytes written always agree.
| blob | The face's settings struct. |
| member | The member that holds the text. |
| bytes | How many bytes the entry writes. |
| typedef struct SettingsSchema SettingsSchema |
A face's persistence identity.
Its storage key, current schema version, the face struct to load into (its first byte must be the uint8_t version), that struct's size and the size it first shipped at, the field table that drives defaults/sanitize/serialization, and an optional migration hook to rescue pre-versioned data. SETTINGS_BLOB fills in the struct and both sizes.
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. A face built with a plugin define also gets the framework's own schema, on SETTINGS_PLUGIN_SOURCE_KEY. It is never linked onto the face's chain. The walk in settings_chain.h visits it after the face's last schema.
| 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 a distance readout, separate from the steps readout's STEPS_MODE. |
| 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_WIND_UNIT | Which WindUnit a wind speed reads out in. |
| SETTING_GOAL_STEPS | The step goal, as an index into goals_steps. |
| SETTING_GOAL_DISTANCE | The distance goal, as an index into goals_distance_m. |
| SETTING_GOAL_CALORIES | The calorie goal, as an index into goals_calories. |
| SETTING_GOAL_ACTIVE | The active minutes goal, as an index into goals_active_min. |
| SETTING_GOAL_SLEEP | The sleep goal, as an index into goals_sleep_min. |
| SETTING_GOAL_HR | The heart rate limit, as an index into goals_hr_limit. |
| SETTING_GOAL_VIBE | The Goal Met Vibration pick, which vibe_goal plays. |
| SETTING_GOAL_VIBE_CUSTOM | The wearer's own goal pattern, played when the pick is Custom. |
| 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 |
|
inlinestatic |
Whether a save has to write the choices to flash.
settings_save writes every schema on every save, and the choices only change when the wearer picks another source. So the write is skipped while the choices match what flash holds. With nothing known to be on flash it always writes, even when the choices are still the defaults. Skipping that write would leave the key empty, and the watch would count as fresh on every launch.
| now | The choices as they are now. |
| on_flash | The choices as they were last loaded or written. |
| on_flash_known | Whether on_flash is really what flash holds. False when the key was empty at launch, or was dropped for a blob the watch could not read. |
| 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.
A toggle or a choice is taken whether it came as an int or as text holding only digits, through tuple_number_or. A colour is taken as an int only, since colour text could be hex. Anything else leaves the field as it was.
| iter | The dictionary iterator to decode from. |
|
inlinestatic |
Where the walk starts.
| head | The face's first schema, or NULL for a face with no settings of its own. |
| tail | The framework's schema, or NULL when it keeps none. |
|
inlinestatic |
Whether a schema in the face's own chain has a field on a message key.
Only the face's chain is walked, not the framework's schema.
| head | The face's first schema, or NULL. |
| message_key | The MESSAGE_KEY_* to look for, by address. |
|
inlinestatic |
Whether a schema in the face's own chain is saved under a persist key.
Only the face's chain is walked, not the framework's schema.
| head | The face's first schema, or NULL. |
| key | The persist key to look for. |
|
inlinestatic |
The schema after this one in the walk.
That is the face's own companion. After the face's last schema it is the framework's, and the walk ends there.
| schema | The schema the walk is on. |
| tail | The framework's schema, or NULL when it keeps none. |
| 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. SETTINGS_BLOB stops the build for one, so the log catches a schema written without it.
A face built with PLUGIN_WEATHER, PLUGIN_CALENDAR, or PLUGIN_STOCKS that declares the kind's select key also gets the framework's schema for the source choice, walked after its own and saved under SETTINGS_PLUGIN_SOURCE_KEY. The choice is only kept once this has run, so a face with no settings of its own still has to call it, as settings_init(NULL), or a reset of the Pebble app drops the wearer's pick. The pick only reaches the phone in the settings reply, so the build adds SETTINGS_REQUEST and SETTINGS_FRESH to such a face's keys. Call it before appmessage_open, which sizes the outbox from the settings reply. Called after, every settings reply goes out empty and a reinstall restores nothing. A face schema on SETTINGS_PLUGIN_SOURCE_KEY is logged as an error and the framework's schema is left out. A face field on a select key the framework keeps is logged too.
| schema | The head schema defining the face's settings, or NULL for a face with none. |
| 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.