Weather, health, calendar, stocks, and the other readings a face shows. More...
Files | |
| file | src/c/pebble/io/stores/calendar_store.c |
| The active calendar store: holds the agenda, owns the appmessage calendar channel, and asks the phone for more whenever its turn on the face's cadence finds a poll due. | |
| file | src/c/pebble/io/stores/calendar_store.h |
| Active calendar store. It owns the appmessage calendar channel and its place on the shared cadence, so a face just hands it the rules (live / poll interval), optionally seeds it, then reads the events and subscribes for repaints. The phone data flows straight in and nobody wires it. | |
| file | src/c/pebble/io/stores/health_hr_day.c |
| The health store's heart rate day: today's heart rate by the hour, filled from the watch's minute log at launch and from each reading after. A face turns it on with HEALTH_HR_DAY, and one that never names it carries none of this. | |
| file | src/c/pebble/io/stores/health_hr_history.c |
| The health store's heart rate graph: the last hour of heart rate, a reading a minute, saved to flash so a relaunch shows it straight away. A face turns it on with HEALTH_HR_HISTORY, and one that never names it carries none of this. | |
| file | src/c/pebble/io/stores/health_hrv.c |
| The heart rate variability half of the health store. | |
| file | src/c/pebble/io/stores/health_hrv.h |
| The heart rate variability half of the health store. It asks the watch for beat gaps now and then, holds the sensor on while a burst is measured, and keeps the latest reading. | |
| file | src/c/pebble/io/stores/health_step_history.c |
| The health store's hourly steps: today's steps by the hour for a bar chart. A face turns it on with HEALTH_STEP_HISTORY, and one that never names it carries none of this. | |
| file | src/c/pebble/io/stores/health_store.c |
| The active health store: reads the watch's health service and holds the numbers. It owns the service accessors too so it is the single point of truth for health. | |
| file | src/c/pebble/io/stores/health_store.h |
| Active health store. It subscribes to the watch's health service itself and holds the readings, so a face just hands it the rules, optionally seeds it, then reads the numbers back. | |
| file | src/c/pebble/io/stores/health_store_parts.h |
| What the health store shares with its optional parts, the heart rate graph, the hourly steps, and the heart rate day. A face never includes this. It names a part in its HealthConfig. | |
| file | src/c/pebble/io/stores/location_store.c |
| The active location store: holds the phone's coordinates and owns the appmessage coords channel. | |
| file | src/c/pebble/io/stores/location_store.h |
| Active location store. It owns the appmessage coords channel (the same phone geolocation the weather rides on), so a face hands it the rules, optionally seeds it, then reads lat/lon back. There's no poll timer. Coords arrive alongside weather. | |
| file | src/c/pebble/io/stores/music_store.c |
| The active music store: holds what the phone is playing, owns the appmessage now playing channel, and asks the phone again at launch and whenever the link comes back. | |
| file | src/c/pebble/io/stores/music_store.h |
| Active music store: what the phone is playing, as a Pebble app music plugin reports it. | |
| file | src/c/pebble/io/stores/phone_store.c |
| The active phone store: holds the phone's battery level, owns the appmessage phone battery channel, and asks the phone again at launch and whenever the link comes back. | |
| file | src/c/pebble/io/stores/phone_store.h |
| Active phone store: the phone's own battery, as a Pebble app plugin on the phone reports it. | |
| file | src/c/pebble/io/stores/stock_store.c |
| The active stock store: holds the quotes, owns the appmessage stock channel, and asks the phone for more whenever its turn on the face's cadence finds a poll due. | |
| file | src/c/pebble/io/stores/stock_store.h |
| Active stock store. It owns the appmessage stock channel and its place on the shared cadence, so a face just hands it the rules (live / poll interval), optionally seeds it, then reads the slots and subscribes for repaints. The phone data flows straight in and nobody wires it. | |
| file | src/c/pebble/io/stores/store_cadence.c |
| Holds the list of work the stores want run on the face's cadence. | |
| file | src/c/pebble/io/stores/store_cadence.h |
| The shared cadence the stores hang their periodic work on. | |
| file | src/c/pebble/io/stores/store_fetch.c |
| The fetch timing the polling stores share, in one copy every store links against. | |
| file | src/c/pebble/io/stores/store_fetch.h |
| The fetch timing the polling stores share: the one-shot catch-up, the cadence turn, the ask when the phone comes back, and what an init or a reconfigure does to them. | |
| file | src/c/pebble/io/stores/store_persist.c |
| The save that skips an unchanged reading and the restore that feeds it, in one copy every store links against. | |
| file | src/c/pebble/io/stores/store_persist.h |
| Shared persist save and restore helpers for the stores. | |
| file | src/c/pebble/io/stores/store_poll.c |
| The polling decisions the weather, stock, and calendar stores share. | |
| file | src/c/pebble/io/stores/store_poll.h |
| Wall-clock deadlines for the stores that poll the phone. | |
| file | src/c/pebble/io/stores/store_sum.c |
| The checksum the stores compare before saving, in one copy every store links against. | |
| file | src/c/pebble/io/stores/store_sum.h |
| A checksum of a store's reading, so a reply that brings nothing new costs no flash write. | |
| file | src/c/pebble/io/stores/system_store.c |
| The active system store: holds the battery + bluetooth state and subscribes to the battery and connection services itself. The alarm is read through on demand. | |
| file | src/c/pebble/io/stores/system_store.h |
| Active system store: the watch's own battery, bluetooth and next-alarm state. It subscribes to the battery and connection services itself and buzzes on a bluetooth change through a policy the face installs (so the store never has to know about settings or buzzing). | |
| file | src/c/pebble/io/stores/time_store.c |
| The active time store: holds the current time and owns the tickers that update it. | |
| file | src/c/pebble/io/stores/time_store.h |
| Active time store. It owns the tickers (the minute tick, the swatch .beats AppTimer, and the hour tick) and swaps between them for the current cadence, so a face just hands it the rules and reads the time back. | |
| file | src/c/pebble/io/stores/weather_store.c |
| The active weather store: holds the readings, owns the appmessage weather channels, and asks the phone for more whenever its turn on the face's cadence finds a poll due. | |
| file | src/c/pebble/io/stores/weather_store.h |
| Active weather store. It owns the appmessage weather channels and its place on the shared cadence, so a face just hands it the rules (live / poll interval), optionally seeds it, then reads the values and subscribes for repaints. The phone data flows straight in and nobody wires it. | |
Data Structures | |
| struct | CalendarConfig |
| The rules a face hands the store, built from its own settings so the store names no SETTING_*. More... | |
| struct | CalendarSeed |
| Optional prefill: shown until the first real reading lands, or pinned when live = false. More... | |
| struct | HealthHrvConfig |
| The HRV rules the health store passes on from its own config. More... | |
| struct | HealthPart |
| An optional part of the store, such as the heart rate graph. More... | |
| struct | HealthConfig |
| The rules a face hands the store. More... | |
| struct | HealthSeed |
| Optional prefill, or pinned readings when live = false. A part's seed is only taken when the face named the part in its HealthConfig. More... | |
| struct | LocationConfig |
| The rules a face hands the store. More... | |
| struct | LocationSeed |
| Optional prefill, or pinned coords when live = false. On a live store a seed takes the place of restoring the last real fix, and shows until the phone sends coordinates. A seed is never saved, so the fix on flash stays as it was for the next launch without one. More... | |
| struct | MusicConfig |
| The rules a face hands the store. More... | |
| struct | MusicSeed |
| Optional prefill, or pinned state when live = false. More... | |
| struct | PhoneConfig |
| The rules a face hands the store. More... | |
| struct | PhoneSeed |
| Optional prefill, or pinned state when live = false. More... | |
| struct | StockConfig |
| The rules a face hands the store, built from its own settings so the store names no SETTING_*. More... | |
| struct | StockSeed |
| Optional prefill: shown until the first real reading lands, or pinned when live = false. More... | |
| struct | StoreFetch |
| One store's polling state, its catch-up timer, and how it asks the phone. More... | |
| struct | StorePoll |
| One store's polling: its interval, whether it polls at all, and when it is next due. More... | |
| struct | SystemConfig |
| The rules a face hands the store. More... | |
| struct | SystemSeed |
| Optional prefill, or pinned state when live = false. More... | |
| struct | WeatherConfig |
| The rules a face hands the store, built from its own settings so the store names no SETTING_*. More... | |
| struct | WeatherSeed |
| Optional prefill: shown until the first real reading lands, or pinned when live = false. More... | |
| struct | [struct].s_hours |
| struct | [struct].s_state |
| struct | [struct].s_window |
Macros | |
| #define | HEALTH_HR_SENSOR 0 |
| 1 on a platform where a watch model carries a heart rate sensor, 0 everywhere else. | |
| #define | HEALTH_HR_HISTORY (&health_part_hr_history) |
| Keeps the last hour of heart rate, a reading a minute, and saves it under persist_key. | |
| #define | HEALTH_STEP_HISTORY (&health_part_step_history) |
| Keeps today's steps by the hour. | |
| #define | HEALTH_HR_DAY (&health_part_hr_day) |
| Keeps today's heart rate by the hour with its low, average, and high. | |
| #define | STORE_CADENCE_MAX 8 |
| Room for one entry per store that wants the cadence. | |
| #define | STORE_READING_SIZE(state, stamp) |
| How many leading bytes of a store's blob are the reading, which is everything before its sync time. | |
| #define | SYSTEM_STORE_LISTENS_PHONE 0 |
| the face does not declare PHONE_REQUEST | |
| #define | SYSTEM_STORE_LISTENS_MUSIC 0 |
| the face does not declare MUSIC_REQUEST | |
| #define | SYSTEM_STORE_LISTENS_WEATHER 1 |
| the face declares WEATHER_REQUEST, so that store listens | |
| #define | SYSTEM_STORE_LISTENS_STOCK 0 |
| the face does not declare STOCK_REQUEST | |
| #define | SYSTEM_STORE_LISTENS_CALENDAR 0 |
| the face does not declare CALENDAR_REQUEST | |
| #define | SYSTEM_STORE_LINK_LISTENER_COUNT |
| How many stores this face has that listen for the link. | |
| #define | SYSTEM_STORE_LINK_LISTENER_SLOTS (SYSTEM_STORE_LINK_LISTENER_COUNT + 1) |
| How many slots the list holds, one for each store that listens and one spare for the face's own. | |
| #define | WEATHER_SEED_EMPTY |
Typedefs | |
| typedef struct HealthPart | HealthPart |
| An optional part of the store, such as the heart rate graph. | |
| typedef struct HealthConfig | HealthConfig |
| The rules a face hands the store. | |
| typedef struct HealthSeed | HealthSeed |
| Optional prefill, or pinned readings when live = false. A part's seed is only taken when the face named the part in its HealthConfig. | |
| typedef void(*) | MinuteRecordFn(int hour, const HealthMinuteData *record, void *context) |
| Called for each good record a walk of the minute log finds. | |
| typedef void(*) | BtVibePolicy(bool connected) |
| Called on a real bluetooth transition (a change, not the first reading), so the face can buzz however its own settings say. NULL for a silent link change. | |
Functions | |
| void | calendar_store_init (CalendarConfig cfg, const CalendarSeed *seed) |
| Start the store with its rules. Pass seed = NULL for normal use. | |
| void | calendar_store_reconfigure (CalendarConfig cfg) |
| Re-apply the rules (e.g. the poll interval changed). Moves the next poll to the new interval, and switching the store off here stops it asking the phone. Only init decides whether the store is live, so one init started with live = false stays on its seed whatever cfg says, and one never started ignores the call. | |
| void | calendar_store_subscribe (void(*cb)(void)) |
| Hand it the function to call when the agenda changes (the screen redraw). | |
| const CalendarStrip * | calendar_store_strip (void) |
| The whole agenda strip. count is 0 until a reading lands. | |
| const CalendarEvent * | calendar_store_event (uint8_t index) |
| One event by index, or NULL when the index is past what is filled. | |
| int | calendar_store_age_s (void) |
| How many seconds since the last reading turned up, or -1 if we have none. | |
| void | health_hrv_start (const HealthHrvConfig *cfg, int seed_ms, const HrvLog *seed_log, void(*changed)(void)) |
| Starts HRV with the health store's rules, or starts it again with new ones. | |
| void | health_hrv_set_period (uint16_t period_sec) |
| Changes how often the watch takes a burst. A period of 0 stops the sampling and puts the reading back to none on a live store, and a seeded store keeps its seed. | |
| void | health_hrv_set_rules (uint16_t still_mg, uint16_t walk_steps, uint16_t settle_gaps, HrvCount count, bool keep_all, bool live_redraw) |
| Changes the rules for which bursts count and how they are measured, such as when the wearer changes a setting or places a panel. | |
| void | health_hrv_on_gap (void) |
| Reads one beat gap from the watch. The health store calls it for each HRV event. | |
| void | health_hrv_poll (void) |
| The HRV turn on the face's cadence, which the health store passes on while it is live. | |
| void | health_hrv_stop (void) |
| Stops the sampling, since the watch keeps an app's request going for an hour after it closes. | |
| int | health_hrv_ms (void) |
| The latest reading as RMSSD in ms, or -1 if there is none or it went stale. | |
| bool | health_hrv_sampling (void) |
| Whether the watch took the last request for beat gaps. | |
| bool | health_hrv_measuring (void) |
| Whether a burst is being measured right now, with the sensor held on. | |
| const HrvLog * | health_hrv_log (void) |
| The readings kept for the face's panels. Never NULL. | |
| bool | health_hrv_recent (int back, HrvBurst *out) |
| One of the latest bursts, dropped ones included, newest first. | |
| bool | health_hrv_live (int *score, int *steps, int *held_sec) |
| The burst being held right now. | |
| uint16_t | health_hrv_still_mg (void) |
| The still limit in use, in milli-g a sample. | |
| uint16_t | health_hrv_walk_steps (void) |
| The steps through a burst that make it a walk. | |
| uint16_t | health_hrv_settle_gaps (void) |
| The gaps left out at the start of each burst. | |
| void | health_store_init (HealthConfig cfg, const HealthSeed *seed) |
| Start the store with its rules. Pass seed = NULL for normal use. | |
| void | health_store_subscribe (void(*cb)(void)) |
| Hand it the function to call when the numbers change (the screen redraw). | |
| void | health_store_deinit (void) |
| Stops what the store asked of the watch. Call from the face's deinit. | |
| void | health_store_set_hrv_period (uint16_t period_sec) |
| Changes how often the watch takes a burst of beat gaps, such as when the wearer changes a setting or places a panel. A period of 0 stops the sampling and puts the reading back to none. | |
| void | health_store_set_hrv_rules (uint16_t still_mg, uint16_t walk_steps, uint16_t settle_gaps, HrvCount count, bool keep_all, bool live_redraw) |
| Changes which HRV bursts count and how they are measured, such as when the wearer changes a setting or places a panel. | |
| const uint8_t * | health_store_hr_history (void) |
| The last hour of heart rate readings, one per minute (a 60 slot buffer), for a face that named HEALTH_HR_HISTORY. The little charts read it back out. Empty for a face that did not. | |
| const HrDay * | health_store_hr_day (void) |
| Today's heart rate by the hour, for a face that named HEALTH_HR_DAY. Read each hour and the day's low, average, and high from it with the hr_day.h getters. Empty for a face that did not. | |
| const uint16_t * | health_store_step_hourly (void) |
| Today's steps split into per-hour buckets, one slot per hour from midnight (24 slots), for a face that named HEALTH_STEP_HISTORY. The bar chart reads it back out. Empty for a face that did not. | |
| int | health_store_step_hours (void) |
| How many of the hourly step buckets hold a real value (0 to 24). Steps count 0 as a real reading (a quiet hour), so a chart needs the count rather than a no-data marker. | |
| int | health_store_hr (void) |
| The heart rate in beats per minute, or -1 if we have not got one yet. | |
| bool | health_store_has_hr (void) |
| Whether this watch can give a heart rate at all, for a face that leaves its heart rate slot out rather than showing dashes forever. | |
| int | health_store_steps (void) |
| The steps taken so far today, or -1 if we have not got one yet. | |
| int | health_store_calories (void) |
| The active calories so far today, or -1 if we have not got one yet. | |
| int | health_store_sleep_min (void) |
| The minutes of sleep, or -1 if we have not got one yet. | |
| int | health_store_active_min (void) |
| The active minutes so far today, or -1 if we have not got one yet. | |
| int | health_store_distance_m (void) |
| Today's walked distance in meters, or 0 if we cannot read it. | |
| int | health_store_hrv_ms (void) |
| Heart rate variability as RMSSD in ms, or -1 if we have not got one, it went stale, or the face is built without HEALTH_HRV. | |
| bool | health_store_hrv_sampling (void) |
| Whether the watch took the last request for beat gaps. | |
| bool | health_store_hrv_measuring (void) |
| Whether a burst of beat gaps is being measured right now, with the sensor held on. | |
| const HrvLog * | health_store_hrv_log (void) |
| The HRV readings kept for the panels: the latest few with what the wearer was doing, today by the hour, last night's average, and the latest of each kind. | |
| bool | health_store_hrv_recent (int back, HrvBurst *out) |
| One of the latest HRV bursts, for a readout that shows each burst, dropped ones included, newest first. Kept in memory only, so a face starts each launch with none. | |
| bool | health_store_hrv_live (int *score, int *steps, int *held_sec) |
| The HRV burst being held right now, for a panel that shows it as it happens. | |
| uint16_t | health_store_hrv_still_mg (void) |
| The still limit in use, in milli-g a sample, so a panel shows the same number as the setting. | |
| uint16_t | health_store_hrv_walk_steps (void) |
| The steps through a burst that make it a walk, so a panel shows the same number as the setting. | |
| uint16_t | health_store_hrv_settle_gaps (void) |
| The gaps left out at the start of each burst, after the hold to HRV_SETTLE_GAPS_MAX, so a panel shows the count in use rather than the one asked for. | |
| void | health_store_redraw (void) |
| Asks the face to redraw, for a part whose own timer changed what it holds. | |
| time_t | health_hour_start (const struct tm *today, int hour) |
| When a local hour of today starts. | |
| bool | health_metric_available (HealthMetric metric, time_t start, time_t end) |
| Whether the watch actually has a reading for a metric over a time span. | |
| HealthMinuteData * | health_scratch_take (int records) |
| Allocate scratch room for a minute-history read, off the heap for the length of the read rather than sitting in the app's fixed footprint. | |
| bool | health_walk_minute_log (const struct tm *local, int first_hour, int end_hour, time_t until, MinuteRecordFn each, void *context) |
| Walks the watch's minute log over today's hours and hands each good record, with the hour it falls in, to the each callback. | |
| void | location_store_init (LocationConfig cfg, const LocationSeed *seed) |
| Start the store with its rules. Pass seed = NULL for normal use. | |
| void | location_store_subscribe (void(*cb)(void)) |
| Hand it the function to call when the coordinates change (the screen redraw). | |
| const char * | location_store_lat (void) |
| The latitude string, or empty if we have not got one yet. | |
| const char * | location_store_lon (void) |
| The longitude string, or empty if we have not got one yet. | |
| void | music_store_init (MusicConfig cfg, const MusicSeed *seed) |
| Start the store with its rules. Pass seed = NULL for normal use. | |
| void | music_store_subscribe (void(*cb)(void)) |
| Hand it the function to call when the track changes (the screen redraw). | |
| const char * | music_store_title (void) |
| The song's title, or an empty string for none. | |
| const char * | music_store_artist (void) |
| Who it is by, or an empty string for none. | |
| bool | music_store_playing (void) |
| True while the track plays, and false while it is paused or nothing is playing. | |
| bool | music_store_has_track (void) |
| Whether there is a track to show, paused or playing. | |
| const GBitmap * | music_store_artwork (void) |
| The track's album art, as a 4-bit palettized bitmap. | |
| void | music_store_deinit (void) |
| Frees the album art the store holds. Call it from the face's deinit. | |
| bool | music_store_no_plugin (void) |
| Whether the phone said no plugin on it serves now playing. | |
| void | phone_store_init (PhoneConfig cfg, const PhoneSeed *seed) |
| Start the store with its rules. Pass seed = NULL for normal use. | |
| void | phone_store_subscribe (void(*cb)(void)) |
| Hand it the function to call when the level changes (the screen redraw). | |
| int | phone_store_battery (void) |
| The phone's battery level. | |
| bool | phone_store_no_plugin (void) |
| Whether the phone said no plugin on it serves the battery. | |
| void | stock_store_init (StockConfig cfg, const StockSeed *seed) |
| Start the store with its rules. Pass seed = NULL for normal use. | |
| void | stock_store_reconfigure (StockConfig cfg) |
| Re-apply the rules (e.g. the poll interval changed). Moves the next poll to the new interval, and switching the store off here stops it asking the phone. Only init decides whether the store is live, so one init started with live = false stays on its seed whatever cfg says, and one never started ignores the call. | |
| void | stock_store_subscribe (void(*cb)(void)) |
| Hand it the function to call when a quote changes (the screen redraw). | |
| const StockStrip * | stock_store_strip (void) |
| The whole watchlist strip. count is 0 until a reading lands. | |
| const StockSlot * | stock_store_slot (uint8_t index) |
| One slot by index, or NULL when the index is past what is filled. | |
| int | stock_store_age_s (void) |
| How many seconds since the last reading turned up, or -1 if we have none. | |
| void | store_cadence_register (void(*cb)(void)) |
Ask for cb to run each time the face's cadence comes round. A store calls this from its own init, so no face has to wire it up by hand. | |
| void | store_cadence_fire (void) |
| Run everything registered, in the order it was registered. The time store calls this from its ticker, before it tells the face the time moved. | |
| void | store_fetch_fire (void *data) |
| The one-shot fetch's timer callback. Clears the timer and asks the phone. | |
| void | store_fetch_stop (StoreFetch *fetch) |
| Cancel the one-shot fetch, if one is armed. | |
| void | store_fetch_arm (StoreFetch *fetch) |
| Arm the one-shot fetch after first_ms, unless one is already waiting. | |
| void | store_fetch_turn (StoreFetch *fetch, time_t now) |
| The store's turn on the face's cadence. Asks the phone when the deadline has come round. | |
| void | store_fetch_on_link (StoreFetch *fetch, int age_s) |
| What a store's link listener does. When the phone link has just come back, asks the phone if the reading is at least the store's own interval old, or never arrived. A drop does nothing, so the last reading stays on show. | |
| void | store_fetch_start (StoreFetch *fetch, int poll_min, bool live, time_t now) |
| What a store's init does with its polling. Takes the interval, then arms one fetch shortly after launch when polling is on, so the store is not blank while the first deadline is coming. | |
| void | store_fetch_reconfigure (StoreFetch *fetch, int poll_min, bool live, time_t now, bool empty) |
| What a store's reconfigure does with its polling. | |
| static bool | store_restore (uint32_t key, void *state, size_t size, uint8_t tag) |
Restore a saved blob into state, but only when it is this store's own current layout. | |
| static bool | store_save (uint32_t key, void *state, size_t size, uint8_t tag) |
| Save a store's blob with its tag stamped in, so the next restore can recognize it. | |
| bool | store_save_changed (uint32_t key, void *state, size_t size, size_t reading_size, uint8_t tag, uint32_t *saved_sum) |
| Save a store's blob only when its reading is different from what is already on flash. | |
| bool | store_restore_reading (uint32_t key, void *state, size_t size, size_t reading_size, uint8_t tag, uint32_t *saved_sum) |
| Restore a saved blob as store_restore does, and record the sum of the reading it holds. | |
| static time_t | store_poll_next (int poll_min, time_t now) |
| The next wall-clock second a poll of this interval falls due. | |
| static bool | store_poll_due (int poll_min, time_t *next, time_t now) |
Whether next has come round, moving it on to the following deadline when it has. | |
| static bool | store_poll_reconnect_due (int age_s, int poll_min) |
| Whether a reading is worth asking for again now that the phone is back. | |
| bool | store_poll_start (StorePoll *poll, int poll_min, bool live, time_t now) |
| Take a store's interval and whether it is live, as its init does. | |
| bool | store_poll_set (StorePoll *poll, int poll_min, bool live, time_t now) |
| Take a store's interval and whether it is live, as its reconfigure does. | |
| bool | store_poll_turn (StorePoll *poll, time_t now) |
| A store's turn on the face's cadence: whether a poll should go out now. | |
| bool | store_poll_reconnect (const StorePoll *poll, int age_s) |
| A store's catch-up when the phone comes back: whether to ask for its reading again. | |
| uint32_t | store_sum (const void *bytes, size_t size) |
| Sums a run of bytes, so two readings can be compared without keeping both. | |
| void | system_store_init (SystemConfig cfg, const SystemSeed *seed) |
| Start the store with its rules. Pass seed = NULL for normal use. | |
| void | system_store_deinit (void) |
| Stop tracking the battery + connection services. | |
| void | system_store_subscribe (void(*cb)(void)) |
| Hand it the function to call when something changes (the screen redraw). | |
| void | system_store_on_reconnect (void(*cb)(void)) |
| Hand it the function to call when the phone app link comes back after a drop. | |
| int | system_store_battery (void) |
| How full the battery is from 0 to 100. | |
| bool | system_store_charging (void) |
| True while the watch is plugged in. | |
| bool | system_store_bluetooth (void) |
| True when the phone link is up. | |
| bool | system_store_next_alarm (time_t *out) |
| When the wearer's next enabled alarm fires. | |
| void | time_store_init (TimeConfig cfg, const struct tm *seed) |
| Start the store with its rules. Pass seed = NULL to start from the current time. | |
| void | time_store_reconfigure (TimeConfig cfg) |
| Re-apply the rules (e.g. the time format changed). Swaps the ticker to match. Rules that run the same tickers as the ones running do nothing, so a face can call it on every settings save. Only init decides whether the store is live, so one init started with live = false keeps its pinned time whatever cfg says, and one never started ignores it. TimeConfig and the decisions live in clock/time_config.h. | |
| void | time_store_subscribe (void(*cb)(void)) |
| Hand it the function to call when the time changes (the screen redraw). | |
| const struct tm * | time_store_tm (void) |
| The time we hold right now. | |
| void | weather_store_init (WeatherConfig cfg, const WeatherSeed *seed) |
| Start the store with its rules. Pass seed = NULL for normal use. | |
| void | weather_store_reconfigure (WeatherConfig cfg) |
| Re-apply the rules (e.g. the poll interval changed). Moves the next poll to the new interval, and switching the store off here stops it asking the phone. Only init decides whether the store is live, so one init started with live = false stays on its seed whatever cfg says, and one never started ignores the call. | |
| void | weather_store_subscribe (void(*cb)(void)) |
| Hand it the function to call when the weather changes (the screen redraw). | |
| int | weather_store_temp (void) |
| The temperature reading in the user's unit, or WEATHER_NO_TEMP if we have not got one yet. | |
| const char * | weather_store_cond (void) |
| The short word for the sky, or empty if we have not got one yet. | |
| const char * | weather_store_cond_label (void) |
| The sky in words, such as "Partly Cloudy", for a face that declares WEATHER_CONDITION_LABEL. | |
| int | weather_store_humidity (void) |
| The humidity in percent, or -1 if we have not got one yet. | |
| int | weather_store_wind_kmh (void) |
| The wind speed in km/h, or -1 if we have not got one yet. | |
| const char * | weather_store_wind_dir (void) |
| The wind direction like "NW", or empty if we have not got one yet. | |
| int | weather_store_sunrise (void) |
| Sunrise as minutes past midnight, or -1 if we have not got one yet. | |
| int | weather_store_sunset (void) |
| Sunset as minutes past midnight, or -1 if we have not got one yet. | |
| int | weather_store_feels_like (void) |
| How warm it feels, or WEATHER_NO_TEMP if we have not got one yet. | |
| int | weather_store_pressure (void) |
| The sea level pressure in hPa, or -1 if we have not got one yet. | |
| int | weather_store_dew_point (void) |
| The dew point temperature, or WEATHER_NO_TEMP if we have not got one yet. | |
| int | weather_store_uv (void) |
| Today's UV index, or -1 if we have not got one yet or the day it came is over. | |
| int | weather_store_temp_max (void) |
| Today's high, or WEATHER_NO_TEMP if we have not got one yet or the day it came is over. | |
| int | weather_store_temp_min (void) |
| Today's low, or WEATHER_NO_TEMP if we have not got one yet or the day it came is over. | |
| int | weather_store_precip_chance (void) |
| Today's chance of rain in percent, or -1 if we have not got one yet or the day it came is over. | |
| const WeatherHourly * | weather_store_forecast_hourly (void) |
| The hourly forecast strip, starting at the hour now. | |
| const WeatherDaily * | weather_store_forecast_daily (void) |
| The daily forecast strip, starting today. | |
| int | weather_store_age_s (void) |
| How many seconds since the last reading turned up, or -1 if we have none. | |
Variables | |
| const HealthPart | health_part_hr_history |
| The last hour of heart rate. Name it as HEALTH_HR_HISTORY. | |
| const HealthPart | health_part_step_history |
| Today's steps by the hour. Name it as HEALTH_STEP_HISTORY. | |
| const HealthPart | health_part_hr_day |
| Today's heart rate by the hour. Name it as HEALTH_HR_DAY. | |
Weather, health, calendar, stocks, and the other readings a face shows.
Each store keeps its reading fresh and nudges the screen when it changes.
| #define HEALTH_HR_SENSOR 0 |
1 on a platform where a watch model carries a heart rate sensor, 0 everywhere else.
The platform is the only thing that tells. The health service never checks for the sensor itself, so health_service_metric_accessible for the heart rate gives a watch built without one the same answers as a watch with one. In PebbleOS, fw/applib/health_service.c returns NotSupported only for a time range or aggregation it cannot answer, and NoPermission only for the wearer's heart rate setting. The emulator's setting is always on (fw/shell/sdk/prefs.c), so it reports a heart rate as there on gabbro. The boards that build the sensor in, with CONFIG_HRM in their defconfig, are obelix, the Pebble Time 2 on emery, and qemu_emery. Asterix on flint and getafix on gabbro have none.
Diorite is in because the Pebble 2 HR has a sensor. The Pebble 2 SE on the same platform has none, and the health service cannot tell the two apart, so its heart rate slot shows dashes.
A new platform with a sensor joins the list here.
| #define STORE_READING_SIZE | ( | state, | |
| stamp ) |
How many leading bytes of a store's blob are the reading, which is everything before its sync time.
| state | The store's blob. |
| stamp | The name of its sync time field, which has to come after every reading. |
| #define SYSTEM_STORE_LINK_LISTENER_COUNT |
How many stores this face has that listen for the link.
| #define WEATHER_SEED_EMPTY |
A WeatherSeed with every optional reading already set to its no-data value. Spread it and override only what you have, so a partial seed still reads as "--" instead of a bogus 0. Copy it from a named static const, which the linker drops with the dev code in a release build. Written straight into a local, it leaves an unnamed copy in .data that every build keeps.
| typedef void(*) BtVibePolicy(bool connected) |
Called on a real bluetooth transition (a change, not the first reading), so the face can buzz however its own settings say. NULL for a silent link change.
| connected | True when the link just came up, false when it just dropped. |
| typedef struct HealthPart HealthPart |
An optional part of the store, such as the heart rate graph.
A face turns a part on by naming it in its HealthConfig, as HEALTH_HR_HISTORY, HEALTH_STEP_HISTORY, or HEALTH_HR_DAY. The store only calls a part through the pointer the face hands it, so a face that never names one leaves nothing pointing at its code or its data, and the linker drops the lot. A setting the store checked while running could not do that, since the linker cannot see which way it goes. The store skips any hook a part leaves NULL.
| typedef void(*) MinuteRecordFn(int hour, const HealthMinuteData *record, void *context) |
Called for each good record a walk of the minute log finds.
| hour | The hour of today the record falls in. |
| record | The record. |
| context | What the caller handed the walk. |
| const CalendarEvent * calendar_store_event | ( | uint8_t | index | ) |
One event by index, or NULL when the index is past what is filled.
| index | Which event to read (0 based). |
| void calendar_store_init | ( | CalendarConfig | cfg, |
| const CalendarSeed * | seed ) |
Start the store with its rules. Pass seed = NULL for normal use.
| cfg | The rules (live / poll interval). |
| seed | Optional prefill, or NULL. |
| void calendar_store_reconfigure | ( | CalendarConfig | cfg | ) |
Re-apply the rules (e.g. the poll interval changed). Moves the next poll to the new interval, and switching the store off here stops it asking the phone. Only init decides whether the store is live, so one init started with live = false stays on its seed whatever cfg says, and one never started ignores the call.
| cfg | The new rules. |
| time_t health_hour_start | ( | const struct tm * | today, |
| int | hour ) |
When a local hour of today starts.
Counted on the wall clock rather than as hours since midnight, because on the days the clocks change the two part ways by an hour. An hour past the end of the day rolls onto the next midnight, and the hour a spring change skips starts where the one after it does.
| today | Today's local time, broken apart. |
| hour | The hour of the day, 0 to 24. |
| bool health_hrv_live | ( | int * | score, |
| int * | steps, | ||
| int * | held_sec ) |
The burst being held right now.
| [out] | score | Its movement score so far, or -1 before there is one. |
| [out] | steps | Its steps so far, or -1 when not known. |
| [out] | held_sec | How long it has been held. |
| bool health_hrv_recent | ( | int | back, |
| HrvBurst * | out ) |
One of the latest bursts, dropped ones included, newest first.
| back | 0 for the newest. | |
| [out] | out | The burst. |
| void health_hrv_set_period | ( | uint16_t | period_sec | ) |
Changes how often the watch takes a burst. A period of 0 stops the sampling and puts the reading back to none on a live store, and a seeded store keeps its seed.
| period_sec | How often in seconds, or 0 for not at all. |
| void health_hrv_set_rules | ( | uint16_t | still_mg, |
| uint16_t | walk_steps, | ||
| uint16_t | settle_gaps, | ||
| HrvCount | count, | ||
| bool | keep_all, | ||
| bool | live_redraw ) |
Changes the rules for which bursts count and how they are measured, such as when the wearer changes a setting or places a panel.
| still_mg | The most the wrist may move for a burst to be still, or 0 for HRV_MOTION_STILL_DEFAULT. |
| walk_steps | The steps through a burst that make it a walk, or 0 for HRV_WALK_STEPS_DEFAULT. |
| settle_gaps | Gaps left out at the start of a burst, or 0 for HRV_SETTLE_GAPS. Held to HRV_SETTLE_GAPS_MAX, and a burst already settling keeps the count it started with. |
| count | Which bursts count for the main reading. |
| keep_all | Measure a burst that cannot count rather than drop it. |
| live_redraw | Redraw the face once a second while a burst is held. |
| void health_hrv_start | ( | const HealthHrvConfig * | cfg, |
| int | seed_ms, | ||
| const HrvLog * | seed_log, | ||
| void(* | changed )(void) ) |
Starts HRV with the health store's rules, or starts it again with new ones.
Started again live on a live store, only the period and the movement rules change, and the burst being added up, the reading shown, and the log are kept. Started with live false, any request an earlier start made is stopped and the seed is shown instead.
| cfg | The rules. |
| seed_ms | A reading to start with, or 0 or less for none. |
| seed_log | A log to start with for screenshots, or NULL to restore the saved one. |
| changed | Called whenever the reading or the log changes, so the face can redraw. |
| bool health_metric_available | ( | HealthMetric | metric, |
| time_t | start, | ||
| time_t | end ) |
Whether the watch actually has a reading for a metric over a time span.
| metric | The health metric to check. |
| start | Start of the span to check. |
| end | End of the span to check. |
| HealthMinuteData * health_scratch_take | ( | int | records | ) |
Allocate scratch room for a minute-history read, off the heap for the length of the read rather than sitting in the app's fixed footprint.
What a Pebble app runs out of first is its image, and the heap does not count towards that.
| records | How many minute records to make room for. |
| void health_store_deinit | ( | void | ) |
Stops what the store asked of the watch. Call from the face's deinit.
The watch keeps an app's request for heart rate variability going for an hour after the app closes, so a face with HRV that leaves this out has the sensor sampling for that hour whenever the wearer opens an app from it. Without HRV it does nothing.
| bool health_store_has_hr | ( | void | ) |
Whether this watch can give a heart rate at all, for a face that leaves its heart rate slot out rather than showing dashes forever.
It answers HEALTH_HR_SENSOR, which goes by the platform, since the health service cannot say whether a sensor is there (see HEALTH_HR_SENSOR). A watch off the wrist, one that has not taken its first reading yet, and one with heart rate turned off in Health all answer true, since the sensor is there and the slot fills once it reads.
The answer never changes on a given watch, so a face can ask once, such as when it lays out its screen. It works before the store is started and in a seeded build alike.
| const HrDay * health_store_hr_day | ( | void | ) |
Today's heart rate by the hour, for a face that named HEALTH_HR_DAY. Read each hour and the day's low, average, and high from it with the hr_day.h getters. Empty for a face that did not.
| bool health_store_hrv_live | ( | int * | score, |
| int * | steps, | ||
| int * | held_sec ) |
The HRV burst being held right now, for a panel that shows it as it happens.
| [out] | score | Its movement score so far, or -1 before there is one. |
| [out] | steps | Its steps so far, or -1 when not known. |
| [out] | held_sec | How long it has been held. |
| const HrvLog * health_store_hrv_log | ( | void | ) |
The HRV readings kept for the panels: the latest few with what the wearer was doing, today by the hour, last night's average, and the latest of each kind.
Read it with the hrv_log functions in health/hrv_log.h. A face built without HEALTH_HRV gets an empty log, so a panel that reads it still draws.
| bool health_store_hrv_measuring | ( | void | ) |
Whether a burst of beat gaps is being measured right now, with the sensor held on.
| int health_store_hrv_ms | ( | void | ) |
Heart rate variability as RMSSD in ms, or -1 if we have not got one, it went stale, or the face is built without HEALTH_HRV.
Only a watch whose sensor reports beat gaps gives readings, which today is the Pebble Time 2.
| bool health_store_hrv_recent | ( | int | back, |
| HrvBurst * | out ) |
One of the latest HRV bursts, for a readout that shows each burst, dropped ones included, newest first. Kept in memory only, so a face starts each launch with none.
| back | 0 for the newest. | |
| [out] | out | The burst. |
| bool health_store_hrv_sampling | ( | void | ) |
Whether the watch took the last request for beat gaps.
False on a watch without the sensor, with heart rate turned off in the watch's Health settings, with a period of 0, or in a face built without HEALTH_HRV.
| uint16_t health_store_hrv_settle_gaps | ( | void | ) |
The gaps left out at the start of each burst, after the hold to HRV_SETTLE_GAPS_MAX, so a panel shows the count in use rather than the one asked for.
| uint16_t health_store_hrv_still_mg | ( | void | ) |
The still limit in use, in milli-g a sample, so a panel shows the same number as the setting.
| uint16_t health_store_hrv_walk_steps | ( | void | ) |
The steps through a burst that make it a walk, so a panel shows the same number as the setting.
| void health_store_init | ( | HealthConfig | cfg, |
| const HealthSeed * | seed ) |
Start the store with its rules. Pass seed = NULL for normal use.
| cfg | The rules (live). |
| seed | Optional prefill, or NULL. |
| void health_store_set_hrv_period | ( | uint16_t | period_sec | ) |
Changes how often the watch takes a burst of beat gaps, such as when the wearer changes a setting or places a panel. A period of 0 stops the sampling and puts the reading back to none.
| period_sec | How often in seconds, or 0 for no HRV. |
| void health_store_set_hrv_rules | ( | uint16_t | still_mg, |
| uint16_t | walk_steps, | ||
| uint16_t | settle_gaps, | ||
| HrvCount | count, | ||
| bool | keep_all, | ||
| bool | live_redraw ) |
Changes which HRV bursts count and how they are measured, such as when the wearer changes a setting or places a panel.
| still_mg | The most the wrist may move for a burst to be still, or 0 for HRV_MOTION_STILL_DEFAULT. |
| walk_steps | The steps through a burst that make it a walk, or 0 for HRV_WALK_STEPS_DEFAULT. |
| settle_gaps | Gaps left out at the start of each burst while the sensor settles, or 0 for HRV_SETTLE_GAPS. It is held to 1 to HRV_SETTLE_GAPS_MAX, and a burst already settling keeps the count it started with, so a new count applies from the next burst. |
| count | Which bursts count for the main reading. |
| keep_all | Measure a burst that cannot count rather than drop it. Holds the sensor on for up to 90 seconds more each. |
| live_redraw | Redraw once a second while a burst is held. |
| void health_store_subscribe | ( | void(* | cb )(void) | ) |
Hand it the function to call when the numbers change (the screen redraw).
| cb | The function to call, or NULL for none. |
| bool health_walk_minute_log | ( | const struct tm * | local, |
| int | first_hour, | ||
| int | end_hour, | ||
| time_t | until, | ||
| MinuteRecordFn | each, | ||
| void * | context ) |
Walks the watch's minute log over today's hours and hands each good record, with the hour it falls in, to the each callback.
The records come into a buffer borrowed from the heap, so the hours go STEP_CATCHUP_HOURS (six) at a time to keep that buffer a few KB. Each read blocks on a scan of the watch's whole minute log, and costs the same whatever window it asks for, so a batch that size takes a day in four reads. Each hour is the wall clock's own, so on a clock change day a record lands in the hour the chart labels.
| local | Today's local time, broken apart. |
| first_hour | The first hour to read. |
| end_hour | The hour to stop before. |
| until | The time to stop at, for a walk that ends partway through its last hour. One that ends on an hour passes that hour's start. |
| each | Called for each good record. |
| context | Handed to each. |
| void location_store_init | ( | LocationConfig | cfg, |
| const LocationSeed * | seed ) |
Start the store with its rules. Pass seed = NULL for normal use.
| cfg | The rules (live / persist_key). |
| seed | Optional prefill, or NULL. |
| const GBitmap * music_store_artwork | ( | void | ) |
The track's album art, as a 4-bit palettized bitmap.
The store owns it. It stays valid until the store calls the face back with a change, so a face reads it again on every redraw rather than keeping it.
| bool music_store_has_track | ( | void | ) |
Whether there is a track to show, paused or playing.
| void music_store_init | ( | MusicConfig | cfg, |
| const MusicSeed * | seed ) |
Start the store with its rules. Pass seed = NULL for normal use.
A live store listens for the phone link through the system store, so the face starts that one live too.
| cfg | The rules. |
| seed | Optional prefill, or NULL. |
| bool music_store_no_plugin | ( | void | ) |
Whether the phone said no plugin on it serves now playing.
It holds from the phone's word until a track or a clear arrives or the phone drops.
| int phone_store_battery | ( | void | ) |
The phone's battery level.
| void phone_store_init | ( | PhoneConfig | cfg, |
| const PhoneSeed * | seed ) |
Start the store with its rules. Pass seed = NULL for normal use.
A live store listens for the phone link through the system store, so the face starts that one live too.
| cfg | The rules. |
| seed | Optional prefill, or NULL. |
| bool phone_store_no_plugin | ( | void | ) |
Whether the phone said no plugin on it serves the battery.
It holds from the phone's word until a level arrives or the phone drops. The phone sends it while plugins are off in the Pebble app, while the Pebble app is from before plugins, or while it lists no Phone plugin.
| void stock_store_init | ( | StockConfig | cfg, |
| const StockSeed * | seed ) |
Start the store with its rules. Pass seed = NULL for normal use.
| cfg | The rules (live / poll interval). |
| seed | Optional prefill, or NULL. |
| void stock_store_reconfigure | ( | StockConfig | cfg | ) |
Re-apply the rules (e.g. the poll interval changed). Moves the next poll to the new interval, and switching the store off here stops it asking the phone. Only init decides whether the store is live, so one init started with live = false stays on its seed whatever cfg says, and one never started ignores the call.
| cfg | The new rules. |
| const StockSlot * stock_store_slot | ( | uint8_t | index | ) |
One slot by index, or NULL when the index is past what is filled.
| index | Which slot to read (0 based). |
| void store_cadence_register | ( | void(* | cb )(void) | ) |
Ask for cb to run each time the face's cadence comes round. A store calls this from its own init, so no face has to wire it up by hand.
The cadence is whichever ticker the face runs: the minute tick, or the .beats timer in its place. A face with neither never fires this, so put periodic work here, not work something depends on. Registering the same function twice does nothing.
| cb | The work to run. NULL is ignored. |
| void store_fetch_arm | ( | StoreFetch * | fetch | ) |
Arm the one-shot fetch after first_ms, unless one is already waiting.
| fetch | The store's fetch state. |
| void store_fetch_fire | ( | void * | data | ) |
The one-shot fetch's timer callback. Clears the timer and asks the phone.
| data | The StoreFetch the timer was armed for. |
| void store_fetch_on_link | ( | StoreFetch * | fetch, |
| int | age_s ) |
What a store's link listener does. When the phone link has just come back, asks the phone if the reading is at least the store's own interval old, or never arrived. A drop does nothing, so the last reading stays on show.
The phone side may have been closed the whole time the link was down, so a reading can go stale with nothing on the watch to notice. A store that is not live never asks, so a seeded store keeps its fixture. The deadline is left where it was.
| fetch | The store's fetch state. |
| age_s | Seconds since the reading arrived, or below 0 when it never has. |
| void store_fetch_reconfigure | ( | StoreFetch * | fetch, |
| int | poll_min, | ||
| bool | live, | ||
| time_t | now, | ||
| bool | empty ) |
What a store's reconfigure does with its polling.
Switching the store off clears the live flag, which stops the cadence turn too, and drops any fetch still waiting. A store that init started with live false stays off whatever live says, so a settings save never starts a store seeded for screenshots fetching over its fixture. A store whose init never ran ignores the reconfigure altogether.
A store that keeps polling keeps its launch fetch, since a settings push that lands in the first second would otherwise cancel it and leave a restored reading stale until the next deadline.
An empty store has nothing to draw, so it catches up right away. One that already holds data waits for its deadline, so a save that only touched colours does not fetch on the spot and spend a metered provider's quota. That deadline is a wall-clock boundary, so a save can bring it nearer but never past the interval's rate.
| fetch | The store's fetch state. |
| poll_min | Minutes between polls. 0 or less means no polling. |
| live | True on a live face. A store init started not live stays not live. |
| now | The current wall-clock time. |
| empty | True when the store holds nothing to show yet. |
| void store_fetch_start | ( | StoreFetch * | fetch, |
| int | poll_min, | ||
| bool | live, | ||
| time_t | now ) |
What a store's init does with its polling. Takes the interval, then arms one fetch shortly after launch when polling is on, so the store is not blank while the first deadline is coming.
| fetch | The store's fetch state. |
| poll_min | Minutes between polls. 0 or less means no polling. |
| live | True on a live face. |
| now | The current wall-clock time. |
| void store_fetch_stop | ( | StoreFetch * | fetch | ) |
Cancel the one-shot fetch, if one is armed.
| fetch | The store's fetch state. |
| void store_fetch_turn | ( | StoreFetch * | fetch, |
| time_t | now ) |
The store's turn on the face's cadence. Asks the phone when the deadline has come round.
| fetch | The store's fetch state. |
| now | The current wall-clock time. |
|
inlinestatic |
Whether next has come round, moving it on to the following deadline when it has.
A clock that jumps forward just fires once and carries on. One that jumps back would strand the deadline more than an interval ahead, so that case is pulled back in.
| poll_min | Minutes between polls. 0 or less means polling is off and this is never due. | |
| [in,out] | next | The store's deadline, read and updated in place. |
| now | The current wall-clock time. |
|
inlinestatic |
The next wall-clock second a poll of this interval falls due.
Counted from the epoch rather than from launch, so two watches started minutes apart poll at the same moments and a relaunch does not shift the phase.
| poll_min | Minutes between polls. Must be above 0. |
| now | The current wall-clock time. |
| bool store_poll_reconnect | ( | const StorePoll * | poll, |
| int | age_s ) |
A store's catch-up when the phone comes back: whether to ask for its reading again.
Only a live store asks, so a store seeded for screenshots keeps its fixture through a reconnect. The age and the interval decide the rest, the same as store_poll_reconnect_due. The deadline is left alone, so a catch-up never pushes the next recurring poll further away.
| poll | The store's polling state. |
| age_s | Seconds since the reading arrived, or below 0 when it never has. |
|
inlinestatic |
Whether a reading is worth asking for again now that the phone is back.
The phone's side may have been closed the whole time it was away, so a face catches up a reading that went stale meanwhile. Only a reading that never arrived, or one at least its own interval old, is asked for, so bluetooth dropping in and out cannot fetch faster than the normal polling. Polling turned off is left alone, the same as its store.
| age_s | Seconds since the reading arrived, or below 0 when it never has. |
| poll_min | Minutes between polls. 0 or less means polling is off. |
| bool store_poll_set | ( | StorePoll * | poll, |
| int | poll_min, | ||
| bool | live, | ||
| time_t | now ) |
Take a store's interval and whether it is live, as its reconfigure does.
Both are always recorded. A store that store_poll_start pinned stays not live whatever live says, so a settings save in a build seeded for screenshots never starts it fetching over its fixture. A live store can still be switched off here and back on again. The deadline only moves when polling is on, and then to the next interval boundary, so a save can bring a poll nearer but never make one come faster than the interval allows.
| [in,out] | poll | The store's polling state. |
| poll_min | Minutes between polls. 0 or less turns polling off. | |
| live | Whether the store should be live. | |
| now | The current wall-clock time. |
| bool store_poll_start | ( | StorePoll * | poll, |
| int | poll_min, | ||
| bool | live, | ||
| time_t | now ) |
Take a store's interval and whether it is live, as its init does.
Init is the one place that decides whether the store is live at all. A store it starts with live false is pinned, and stays not live through every reconfigure, as store_poll_set covers. A store whose init calls store_poll_set instead is never pinned, so a reconfigure can turn it live.
The pin only covers asking the phone. A store that also takes pushes or listens for the link registers its handler and its listener only when init starts it live. An init that starts it with live false clears the handler and removes the listener, so a store started live and then pinned takes no push over its seed.
| [in,out] | poll | The store's polling state. |
| poll_min | Minutes between polls. 0 or less turns polling off. | |
| live | Whether the store is live. | |
| now | The current wall-clock time. |
| bool store_poll_turn | ( | StorePoll * | poll, |
| time_t | now ) |
A store's turn on the face's cadence: whether a poll should go out now.
| [in,out] | poll | The store's polling state. The deadline moves on when a poll is due. |
| now | The current wall-clock time. |
|
inlinestatic |
Restore a saved blob into state, but only when it is this store's own current layout.
Checks the size and then the tag byte. Nothing is written into state unless both match, so the defaults the caller applied before calling survive a rejected blob.
| key | The persist slot the face handed the store. | |
| [out] | state | The struct to fill. Its first field must be the uint8_t tag. |
| size | sizeof that struct. | |
| tag | The store's STORE_TAG_* value. |
| bool store_restore_reading | ( | uint32_t | key, |
| void * | state, | ||
| size_t | size, | ||
| size_t | reading_size, | ||
| uint8_t | tag, | ||
| uint32_t * | saved_sum ) |
Restore a saved blob as store_restore does, and record the sum of the reading it holds.
The sum is what store_save_changed compares against, so a first reply bringing the same reading after a relaunch is not written again.
| key | The persist slot the face handed the store. | |
| [out] | state | The struct to fill. Its first field must be the uint8_t tag. |
| size | sizeof that struct. | |
| reading_size | How many leading bytes are the reading, from STORE_READING_SIZE. | |
| tag | The store's STORE_TAG_* value. | |
| [out] | saved_sum | The sum of the restored reading, or 0 when nothing was restored. |
|
inlinestatic |
Save a store's blob with its tag stamped in, so the next restore can recognize it.
| key | The persist slot the face handed the store. | |
| [in,out] | state | The struct to write, with its tag stamped in on the way. Its first field must be the uint8_t tag. |
| size | sizeof that struct. | |
| tag | The store's STORE_TAG_* value. |
| bool store_save_changed | ( | uint32_t | key, |
| void * | state, | ||
| size_t | size, | ||
| size_t | reading_size, | ||
| uint8_t | tag, | ||
| uint32_t * | saved_sum ) |
Save a store's blob only when its reading is different from what is already on flash.
Only the first reading_size bytes are compared, so a reply that brings the same reading with a new sync time writes nothing. The flash copy then keeps the sync time of the last real change, and a relaunch reads the reading as older than it is. The catch-up poll after a reconnect fires a little sooner for it, which costs one request at most.
| key | The persist slot the face handed the store. | |
| [in,out] | state | The struct to write, with its tag stamped in on the way. Its first field must be the uint8_t tag. |
| size | sizeof that struct. | |
| reading_size | How many leading bytes are the reading, from STORE_READING_SIZE. Pass the whole size for a blob with no sync time. | |
| tag | The store's STORE_TAG_* value. | |
| [in,out] | saved_sum | The sum of the reading last written, which the store keeps. It moves on only when a write lands. |
| uint32_t store_sum | ( | const void * | bytes, |
| size_t | size ) |
Sums a run of bytes, so two readings can be compared without keeping both.
FNV-1a, which mixes each byte in turn. A plain byte total would miss two values swapping places, and a reading that only reordered its forecast would never be saved.
| bytes | The bytes to sum. |
| size | How many there are. |
| void system_store_init | ( | SystemConfig | cfg, |
| const SystemSeed * | seed ) |
Start the store with its rules. Pass seed = NULL for normal use.
| cfg | The rules (live / vibe policy). |
| seed | Optional prefill, or NULL. |
| bool system_store_next_alarm | ( | time_t * | out | ) |
When the wearer's next enabled alarm fires.
Read through to the alarm service on every call, since there is nothing to subscribe to. A platform without the alarm API always reads as no alarm.
| [out] | out | Set to the alarm's UTC time, or 0 when there is none. Never NULL. |
| void system_store_on_reconnect | ( | void(* | cb )(void) | ) |
Hand it the function to call when the phone app link comes back after a drop.
The weather, stock, and calendar stores already ask for a reading that went stale while the phone was away, so this is only for a face's own extra work. A callback that asks for one of those readings too sends nothing extra. It runs in the same moment as the store's own ask, and the outbox turns away a request whose kind is already out.
| cb | The function to call, or NULL for none. |
| void time_store_init | ( | TimeConfig | cfg, |
| const struct tm * | seed ) |
Start the store with its rules. Pass seed = NULL to start from the current time.
| cfg | The rules (live / cadence). |
| seed | Optional time to pin (dev/screenshots), or NULL for the current time. |
| void time_store_reconfigure | ( | TimeConfig | cfg | ) |
Re-apply the rules (e.g. the time format changed). Swaps the ticker to match. Rules that run the same tickers as the ones running do nothing, so a face can call it on every settings save. Only init decides whether the store is live, so one init started with live = false keeps its pinned time whatever cfg says, and one never started ignores it. TimeConfig and the decisions live in clock/time_config.h.
| cfg | The new rules. |
| const char * weather_store_cond_label | ( | void | ) |
The sky in words, such as "Partly Cloudy", for a face that declares WEATHER_CONDITION_LABEL.
| const WeatherDaily * weather_store_forecast_daily | ( | void | ) |
The daily forecast strip, starting today.
Days before today come off the front as it is read, and base_weekday moves with them.
| const WeatherHourly * weather_store_forecast_hourly | ( | void | ) |
The hourly forecast strip, starting at the hour now.
A strip can outlive the fetch that brought it, when only the forecast half of a later fetch fails. Columns whose hour is over come off the front as it is read, and base_hour moves with them, so a column is never labelled with an hour already gone.
| void weather_store_init | ( | WeatherConfig | cfg, |
| const WeatherSeed * | seed ) |
Start the store with its rules. Pass seed = NULL for normal use.
| cfg | The rules (live / poll interval). |
| seed | Optional prefill, or NULL. |
| void weather_store_reconfigure | ( | WeatherConfig | cfg | ) |
Re-apply the rules (e.g. the poll interval changed). Moves the next poll to the new interval, and switching the store off here stops it asking the phone. Only init decides whether the store is live, so one init started with live = false stays on its seed whatever cfg says, and one never started ignores the call.
| cfg | The new rules. |