118#define SETTINGS_PLUGIN_SOURCE_KEY 249
132#define SETTINGS_BLOB_SIZE(blob) \
133 (sizeof(blob) + 0 * sizeof(struct { \
134 _Static_assert(sizeof(blob) <= PERSIST_DATA_MAX_LENGTH, \
135 "settings struct is over 256 bytes, so move some fields into a companion schema"); \
166#define SETTINGS_BLOB(settings, first) \
167 .blob = &(settings), \
168 .blob_size = SETTINGS_BLOB_SIZE(settings), \
169 .first_size = SETTINGS_FIRST_SIZE_(first, settings)
186#define SETTINGS_FIRST_SIZE_(first, settings) \
187 ((first) + 0 * sizeof(struct { \
188 char settings_first_size_##first##_is_a_number; \
189 _Static_assert((first) >= 1 && (first) <= sizeof(settings), \
190 "first size is 0 or bigger than the settings struct, so give the size the struct first shipped with"); \
326#if defined(DEV_MODE) && DEV_MODE
336SettingsInbound settings_apply_inbox_holding(DictionaryIterator *iter,
bool (*held)(uint32_t
key));
SettingsInbound settings_apply_inbox(DictionaryIterator *iter)
Apply any settings present in an inbox message to the active face.
Definition settings.c:659
uint32_t settings_serialized_size_max(void)
The most outbox bytes every field of the active face could ever take once written.
Definition settings.c:582
void settings_mark_restored(void)
Clears settings_was_fresh once a save or restore from the settings page has been saved.
Definition settings.c:504
uint8_t settings_u8(SettingId id)
Read a known uint8/bool setting by id.
Definition settings.c:513
bool settings_was_fresh(void)
Whether the watch booted with no saved settings, because storage was wiped by a fresh install or an u...
Definition settings.c:485
SettingId
Identity of a known (shared) setting, used for typed reads and indexing.
Definition settings.h:24
uint8_t settings_enum_count(SettingId id)
How many values an enum setting allows (its sanitize ceiling).
Definition settings.c:534
bool settings_serialize(DictionaryIterator *iter)
Write every field of the active face into an outbox iterator.
Definition settings.c:598
SettingType
How a setting encodes on the wire and how the sanitize pass clamps it.
Definition settings.h:53
const char * settings_str(SettingId id)
Read a known string setting by id.
Definition settings.c:519
void settings_save(void)
Persist the active face's structs under their keys (the whole chain).
Definition settings.c:490
void settings_init(const SettingsSchema *head)
Load a face's settings from their saved blobs, applying defaults first.
Definition settings.c:451
void settings_set_u8(SettingId id, uint8_t value)
Write a known uint8 or enum setting by id. In memory only, does not persist.
Definition settings.c:525
@ SETTING_GOAL_DISTANCE
The distance goal, as an index into goals_distance_m.
Definition settings.h:39
@ SETTING_GOAL_SLEEP
The sleep goal, as an index into goals_sleep_min.
Definition settings.h:42
@ SETTING_TEMPERATURE_UNIT
Celsius or Fahrenheit.
Definition settings.h:25
@ SETTING_HOURLY_VIBE
Vibe pattern to fire on the hour.
Definition settings.h:35
@ SETTING_BLUETOOTH_VIBE_CONNECT
Vibe pattern to fire when the phone connects.
Definition settings.h:33
@ SETTING_COUNT
How many known settings there are.
Definition settings.h:46
@ SETTING_BATTERY_DISPLAY
What the battery readout shows.
Definition settings.h:36
@ SETTING_WIND_UNIT
Which WindUnit a wind speed reads out in.
Definition settings.h:37
@ SETTING_THEME
Which theme is active.
Definition settings.h:27
@ SETTING_QUIET_TIME_ICON
Whether the Quiet Time mark shows.
Definition settings.h:32
@ SETTING_GOAL_CALORIES
The calorie goal, as an index into goals_calories.
Definition settings.h:40
@ SETTING_TIME_FORMAT
Which TimeFormat the clock uses.
Definition settings.h:30
@ SETTING_BLUETOOTH_VIBE_DISCONNECT
Vibe pattern to fire when the phone drops.
Definition settings.h:34
@ SETTING_GOAL_STEPS
The step goal, as an index into goals_steps.
Definition settings.h:38
@ SETTING_GOAL_ACTIVE
The active minutes goal, as an index into goals_active_min.
Definition settings.h:41
@ SETTING_BLUETOOTH_ICON
Whether the bluetooth icon shows.
Definition settings.h:31
@ SETTING_GOAL_VIBE_CUSTOM
The wearer's own goal pattern, played when the pick is Custom.
Definition settings.h:45
@ SETTING_DISTANCE_UNIT
Km or miles on a distance readout, separate from the steps readout's STEPS_MODE.
Definition settings.h:29
@ SETTING_GOAL_VIBE
The Goal Met Vibration pick, which vibe_goal plays.
Definition settings.h:44
@ SETTING_GOAL_HR
The heart rate limit, as an index into goals_hr_limit.
Definition settings.h:43
@ SETTING_STEPS_MODE
Steps, miles, or km on the steps readout.
Definition settings.h:28
@ SETTING_DATE_FORMAT
The date line's format string.
Definition settings.h:26
@ SETTING_ENUM_U8
A choice, taken as an int or as digits and sent back as text holding the number.
Definition settings.h:55
@ SETTING_COLOR
Sent as a 0xRRGGBB number, stored as one opaque GColor byte.
Definition settings.h:57
@ SETTING_BOOL
0 or 1, taken as an int or as digits and sent back as a byte. default_num holds the default
Definition settings.h:54
@ SETTING_CSTRING
Sent as text, copied into a fixed buffer.
Definition settings.h:56
Blueprint for a single setting.
Definition settings.h:64
uint8_t enum_count
How many values are allowed, so the highest is one less, for SETTING_ENUM_U8 only.
Definition settings.h:70
uint16_t offset
Where this field sits in the owning face's struct.
Definition settings.h:68
const char * default_str
Default on a fresh install for CSTRING.
Definition settings.h:72
uint16_t size
Buffer size, for SETTING_CSTRING only.
Definition settings.h:69
bool affects_weather
A change asks for fresh weather, for the temperature unit.
Definition settings.h:74
bool affects_layout
A change re-renders the clock, for the date and time formats.
Definition settings.h:73
uint32_t default_num
Default on a fresh install for BOOL and ENUM_U8, and the 0xRRGGBB colour for COLOR.
Definition settings.h:71
const uint32_t * message_key
The MESSAGE_KEY_* this field rides on, filled in by the SDK at runtime.
Definition settings.h:66
SettingType type
Drives both the wire encoding and the cleanup pass.
Definition settings.h:67
SettingId id
Known id for typed reads. SETTING_COUNT or higher means face-only.
Definition settings.h:65
Carries what an inbound settings message changed, so the caller can react.
Definition settings.h:197
bool layout_changed
A date or time format changed, so re-render the clock.
Definition settings.h:199
bool weather_changed
The temperature unit changed, so ask for fresh weather.
Definition settings.h:200
bool changed
Any field was updated, so save and repaint.
Definition settings.h:198
A face's persistence identity.
Definition settings.h:97
uint8_t field_count
How many entries are in fields.
Definition settings.h:104
const SettingField * fields
The face's field table.
Definition settings.h:103
const struct SettingsSchema * companion
Next schema in the chain, or NULL.
Definition settings.h:106
uint8_t version
This face's current schema version.
Definition settings.h:99
void * blob
The face's settings struct, version byte first. Set with SETTINGS_BLOB.
Definition settings.h:101
uint16_t blob_size
Size of that struct. Set with SETTINGS_BLOB.
Definition settings.h:102
uint16_t first_size
The struct's size in its first release, the smallest blob accepted. Set with SETTINGS_BLOB.
Definition settings.h:100
uint32_t key
Storage key for this face's blob.
Definition settings.h:98
bool(*) migrate(int stored_size)
Lifts an old blob from before versioning, true if handled. NULL when none.
Definition settings.h:105