Loading...
Searching...
No Matches
system_store.h
Go to the documentation of this file.
1
16#pragma once
17#include <pebble.h>
18
23
24// every store that can listen for the link, by the request key that builds it in. each is 1 when the
25// face declares the key and 0 when it does not, so a new listening store adds its key here and to
26// the sum below. defined() only works inside #if, which is why each key gets a block of its own
27#if defined(HAS_MESSAGE_KEY_PHONE_REQUEST)
28#define SYSTEM_STORE_LISTENS_PHONE 1
29#else
30#define SYSTEM_STORE_LISTENS_PHONE 0
31#endif
32#if defined(HAS_MESSAGE_KEY_MUSIC_REQUEST)
33#define SYSTEM_STORE_LISTENS_MUSIC 1
34#else
35#define SYSTEM_STORE_LISTENS_MUSIC 0
36#endif
37#if defined(HAS_MESSAGE_KEY_WEATHER_REQUEST)
38#define SYSTEM_STORE_LISTENS_WEATHER 1
39#else
40#define SYSTEM_STORE_LISTENS_WEATHER 0
41#endif
42#if defined(HAS_MESSAGE_KEY_STOCK_REQUEST)
43#define SYSTEM_STORE_LISTENS_STOCK 1
44#else
45#define SYSTEM_STORE_LISTENS_STOCK 0
46#endif
47#if defined(HAS_MESSAGE_KEY_CALENDAR_REQUEST)
48#define SYSTEM_STORE_LISTENS_CALENDAR 1
49#else
50#define SYSTEM_STORE_LISTENS_CALENDAR 0
51#endif
52
54#define SYSTEM_STORE_LINK_LISTENER_COUNT \
55 (SYSTEM_STORE_LISTENS_PHONE + SYSTEM_STORE_LISTENS_MUSIC + SYSTEM_STORE_LISTENS_WEATHER + \
56 SYSTEM_STORE_LISTENS_STOCK + SYSTEM_STORE_LISTENS_CALENDAR)
57
59#define SYSTEM_STORE_LINK_LISTENER_SLOTS (SYSTEM_STORE_LINK_LISTENER_COUNT + 1)
60
61// the link listener list is built only for a face with a store that listens. any other face builds
62// the store without it, so its link handling runs as it always has
63#if SYSTEM_STORE_LINK_LISTENER_COUNT > 0
64#define SYSTEM_STORE_LINK_LISTENERS 1
65#endif
66
73typedef void (*BtVibePolicy)(bool connected);
74
78typedef struct
79{
80 bool live;
83
87typedef struct
88{
89 int battery;
90 bool charging;
91 bool bluetooth;
92 time_t next_alarm;
94
101void system_store_init(SystemConfig cfg, const SystemSeed *seed);
102
104void system_store_deinit(void);
105
107void system_store_subscribe(void (*cb)(void));
108
119void system_store_on_reconnect(void (*cb)(void));
120
121#if defined(SYSTEM_STORE_LINK_LISTENERS)
133void system_store_add_link_listener(void (*listener)(void));
134
143void system_store_remove_link_listener(void (*listener)(void));
144#endif
145
147int system_store_battery(void);
148
150bool system_store_charging(void);
151
153bool system_store_bluetooth(void);
154
164bool system_store_next_alarm(time_t *out);
165
int system_store_battery(void)
How full the battery is from 0 to 100.
Definition system_store.c:181
bool system_store_bluetooth(void)
True when the phone link is up.
Definition system_store.c:183
bool system_store_next_alarm(time_t *out)
When the wearer's next enabled alarm fires.
Definition system_store.c:185
void system_store_deinit(void)
Stop tracking the battery + connection services.
Definition system_store.c:175
bool system_store_charging(void)
True while the watch is plugged in.
Definition system_store.c:182
void(*) BtVibePolicy(bool connected)
Called on a real bluetooth transition (a change, not the first reading), so the face can buzz however...
Definition system_store.h:73
void system_store_init(SystemConfig cfg, const SystemSeed *seed)
Start the store with its rules. Pass seed = NULL for normal use.
Definition system_store.c:137
void system_store_on_reconnect(void(*cb)(void))
Hand it the function to call when the phone app link comes back after a drop.
Definition system_store.c:116
void system_store_subscribe(void(*cb)(void))
Hand it the function to call when something changes (the screen redraw).
Definition system_store.c:111
The rules a face hands the store.
Definition system_store.h:79
bool live
True subscribes the services and false just keeps the fake data for screenshots.
Definition system_store.h:80
BtVibePolicy vibe
Buzz policy for a bluetooth change, or NULL for silent.
Definition system_store.h:81
Optional prefill, or pinned state when live = false.
Definition system_store.h:88
int battery
Battery level from 0 to 100.
Definition system_store.h:89
bool charging
True when plugged in.
Definition system_store.h:90
bool bluetooth
True when the phone link is up.
Definition system_store.h:91
time_t next_alarm
When the next alarm fires, or 0 for none.
Definition system_store.h:92