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. More...
#include "io/stores/health_store.h"#include "io/stores/health_store_parts.h"#include "io/stores/store_sum.h"#include "math/scale.h"#include "health/step_hours.h"#include <string.h>#include <time.h>Data Structures | |
| struct | [struct].s_hours |
Functions | |
| static void | add_record_steps (int hour, const HealthMinuteData *record, void *context) |
| Adds a record's steps to its hour's total, for the hourly step read. | |
| static void | read_step_hourly (void) |
| Fill the per-hour step buckets from midnight up to the current hour. | |
| static void | steps_first_read (void *data) |
| The first read of the hourly buckets, once the face is up. | |
| static void | step_history_start (const HealthConfig *cfg, const HealthSeed *seed) |
| Empties the buckets, then takes the seed, or queues the first read for a live store. | |
| static void | step_history_steps (int steps) |
| Brings the buckets up to date after the store read the day's step count. | |
| static uint32_t | step_history_sum (void) |
| The buckets summed, so the store can tell when they moved. | |
| 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. | |
Variables | |
| static struct | s_hours |
| Today's steps by the hour and how many of the hours are real. | |
| static bool | s_pending |
| True between a live start and the first bucket read, which is held back until the face has painted. | |
| static bool | s_no_timer |
| True when the start got no timer, so the gate drops after the store's own launch read. | |
| static int | s_steps |
| Today's step count as the store last read it, or -1 for none. | |
| const HealthPart | health_part_step_history |
| Today's steps by the hour. Name it as HEALTH_STEP_HISTORY. | |
Settled step hours | |
Finished hours can never gain another step, so they are read once and kept. These live out here because a start clears the buckets, and stale beliefs about them would strand the cleared ones. | |
| static time_t | s_cached_day |
| The day the kept hours belong to. | |
| static int | s_settled_hours |
| How many finished hours are already read and kept. | |
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.
|
static |
Fill the per-hour step buckets from midnight up to the current hour.
step_hours records how many buckets are real so the chart can tell a quiet hour from one that has not happened yet.
An hour is read as it rolls over and once more the minute after, then never again. The hour in progress is today's total less the settled ones, which is free. Each real read blocks on a scan of the watch's whole minute log, so they stay off the minute path.
|
static |
Empties the buckets, then takes the seed, or queues the first read for a live store.
| cfg | The store's rules. |
| seed | The store's seed, or NULL. |
|
static |
Brings the buckets up to date after the store read the day's step count.
The store only reads the count once a minute at most, so this runs at that pace too. The first read of all is owed to the launch timer, which runs once the face is on screen.
| steps | Today's step count, or -1 for none. |
|
static |
The buckets summed, so the store can tell when they moved.
|
static |
The first read of the hourly buckets, once the face is up.
Launching is the one time the buckets have a whole day to catch up on, which is several blocking scans even batched. Doing that inside init leaves the old screen frozen until it finishes.
| data | The timer context (unused). |