Loading...
Searching...
No Matches
health_store.h File Reference

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

#include <pebble.h>
#include "health/hrv_motion.h"
#include "health/hrv_log.h"
#include "health/hr_day.h"

Go to the source code of this file.

Data Structures

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

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.

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.

Functions

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.

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.

Detailed Description

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.