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. More...
#include "io/stores/calendar_store.h"#include <time.h>#include "io/appmessage/appmessage.h"#include "io/stores/store_cadence.h"#include "io/stores/store_persist.h"#include "io/stores/store_fetch.h"#include "io/stores/system_store.h"Data Structures | |
| struct | CalendarPersist |
| The trimmed snapshot saved to flash. Holds only the first few events, not the whole strip. More... | |
| struct | [struct].s_state |
Macros | |
| #define | CALENDAR_FIRST_POLL_MS 1100 |
| Delay before the first fetch after launch, in ms. | |
| #define | CALENDAR_PERSIST_SLOTS 4 |
| How many events the saved snapshot keeps. | |
Functions | |
| static void | reset_state (void) |
| Clear the agenda back to empty. | |
| static void | persist_save (void) |
| Stash a trimmed snapshot so a relaunch can restore it. Only a live face writes. | |
| static void | apply_seed (const CalendarSeed *seed) |
| Prefill the store from a seed, for dev builds and screenshots. | |
| static void | on_calendar_strip (const uint8_t *buf, uint16_t len) |
| Calendar channel. Takes the agenda the reader unpacked and puts it away. | |
| static void | cadence_poll (void) |
| The store's turn on the face's cadence: poll when the deadline has come round. | |
| void | calendar_store_subscribe (void(*cb)(void)) |
| Hand it the function to call when the agenda changes (the screen redraw). | |
| 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. | |
| 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. | |
Variables | |
| static struct | s_state |
| The agenda the store holds right now. | |
| static void(*) | s_cb (void) |
| Called whenever the agenda changes, so the face can redraw. | |
| static StoreFetch | s_fetch |
| The interval, the catch-up fetch, and when the next poll is due. | |
| static uint32_t | s_persist_key |
| The persist slot the face handed us for the saved strip. | |
| static uint32_t | s_saved_sum |
| Sum of the reading last written, so a reply that changes nothing is not written again. | |
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.
| #define CALENDAR_FIRST_POLL_MS 1100 |
Delay before the first fetch after launch, in ms.
It fires from the event loop so appmessage is open by then, and lands a touch after the weather and stock first fetches so they are not fighting over the outbox at boot. The recurring poll then runs at the configured interval.
| #define CALENDAR_PERSIST_SLOTS 4 |
How many events the saved snapshot keeps.
The full strip of 6 events is too big to persist. It blows past the 256 byte persist key ceiling and the save just fails. A relaunch saves the first few events plus the sync time instead, which is enough to paint the agenda straight away before the first poll after launch refreshes the full strip.
|
static |
Prefill the store from a seed, for dev builds and screenshots.
s_cb is still NULL at the point init calls this, so no redraw fires here.
| seed | The prefill to apply. |
|
static |
Calendar channel. Takes the agenda the reader unpacked and puts it away.
A message that does not read clean leaves the last good agenda where it is, so a bad one can never blank the panel.
| buf | The raw wire bytes. |
| len | How many bytes there are. |