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

The heart rate variability readings kept for a face's panels: the last few with what the wearer was doing, today by the hour, last night's average, and the latest of each kind. More...

#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  HrvBurst
 One burst, for a readout that shows each burst: what the wearer did and what came of it. More...
struct  HrvLog
 The readings kept, in the shape that goes to flash. Start it with hrv_log_reset. More...

Macros

#define HRV_LOG_SLOTS   24
 How many of the latest readings the history keeps.
#define HRV_LOG_HOURS   24
 Today's readings by the hour from midnight.
#define HRV_LOG_MS_MAX   255
 Readings above this are kept as this, which fits one byte.
#define HRV_LOG_NIGHT_GAP_MIN   720
 Twelve hours awake starts a new night.
#define HRV_LOG_NAP_FROM_MIN   720
 From noon, a reading taken asleep is a nap's.
#define HRV_LOG_NAP_UNTIL_MIN   1260
 Until 21:00, a reading taken asleep is a nap's.
#define HRV_WALK_STEPS_DEFAULT   10
 Steps through a burst that make it a walk, when a face sets none.
#define HRV_RECENT   6
 How many of the latest bursts a readout that shows each burst can see.
#define HRV_LOG_ASLEEP   0x80
 Set in a reading's flags when Pebble said the wearer was asleep.
#define HRV_LOG_STATE_MASK   0x0F
 The bits of a reading's flags that hold its HrvState.

Enumerations

enum  HrvState { HRV_STATE_STILL , HRV_STATE_BUSY , HRV_STATE_WALKING , HRV_STATE_COUNT }
 What the wearer was doing through a reading's burst. More...
enum  HrvCount { HRV_COUNT_NOT_WALKING , HRV_COUNT_STILL , HRV_COUNT_ANY }
 Which bursts count for the main reading. The first is the one a face gets when it sets none. More...

Functions

void hrv_log_reset (HrvLog *log)
 Empties the log.
HrvState hrv_log_state_of (int motion_score, int steps, uint16_t still_mg, uint16_t walk_steps)
 Works out what a burst was from its steps and its movement score.
bool hrv_log_counts (HrvState state, HrvCount count)
 Whether a burst in one state counts for the main reading.
void hrv_log_add (HrvLog *log, int ms, uint32_t now_min, int32_t day, int minute_of_day, HrvState state, bool asleep)
 Files one finished reading.
bool hrv_log_roll_day (HrvLog *log, int32_t day)
 Moves the hours on to a new day without a reading, so a day chart drawn after midnight does not show yesterday as today.
int hrv_log_count (const HrvLog *log)
 How many readings the history holds, up to HRV_LOG_SLOTS.
bool hrv_log_get (const HrvLog *log, int back, int *ms, uint32_t *at_min, uint8_t *flags)
 One reading from the history, newest first.
int hrv_log_hour_avg (const HrvLog *log, int hour)
 Today's average of the resting readings in one hour.
void hrv_log_today (const HrvLog *log, int *low_ms, int *avg_ms, int *high_ms)
 Today's resting readings summed up.
int hrv_log_night_avg (const HrvLog *log)
 The average of the readings taken asleep in the latest night.
bool hrv_log_last (const HrvLog *log, HrvState state, int *ms, uint32_t *at_min)
 The latest reading of one kind.

Detailed Description

The heart rate variability readings kept for a face's panels: the last few with what the wearer was doing, today by the hour, last night's average, and the latest of each kind.

The health store files every finished reading here and saves the lot to flash, so a face opened again after an app still has its history. Plain C with no SDK, so its specs run on a PC. The caller passes the time already broken into a day and a minute, so a clock change or a time zone is decided once, where the clock is read.