Loading...
Searching...
No Matches
system_store.c File Reference

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. More...

Data Structures

struct  [struct].s_state

Functions

static void set_battery (int level, bool charging)
 Save the battery reading and notify.
static void set_bluetooth (bool connected)
 Save the bluetooth state, buzzing the face's policy on a real transition, and notify.
static void on_battery (BatteryChargeState state)
 Battery service handler: unpack the reading and save it.
static void on_connection (bool connected)
 Connection service handler: save the phone link state.
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.
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.
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.

Variables

static struct  s_state
 The battery and bluetooth readings the store holds.
static bool s_bt_initialized
 The first bluetooth reading only seeds. Later changes can buzz.
static bool s_live
 False pins the seeded values so screenshots stay put.
static time_t s_seed_alarm
 The pinned alarm used while not live.
static void(*) s_cb (void)
 Called whenever a reading changes, so the face can redraw.
static BtVibePolicy s_vibe
 What to buzz when the phone connects or drops.
static void(*) s_reconnect (void)
 Fired on a real change from disconnected to connected.

Detailed Description

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.

Function Documentation

◆ on_battery()

void on_battery ( BatteryChargeState state)
static

Battery service handler: unpack the reading and save it.

Parameters
stateThe battery reading the service handed over.

◆ on_connection()

void on_connection ( bool connected)
static

Connection service handler: save the phone link state.

Parameters
connectedTrue when the phone link just came up.

◆ set_battery()

void set_battery ( int level,
bool charging )
static

Save the battery reading and notify.

Parameters
levelBattery level from 0 to 100.
chargingTrue when plugged in.

◆ set_bluetooth()

void set_bluetooth ( bool connected)
static

Save the bluetooth state, buzzing the face's policy on a real transition, and notify.

Parameters
connectedTrue when the phone link is up.