22#define HRV_LOG_SLOTS 24
23#define HRV_LOG_HOURS 24
24#define HRV_LOG_MS_MAX 255
25#define HRV_LOG_NIGHT_GAP_MIN 720
26#define HRV_LOG_NAP_FROM_MIN 720
27#define HRV_LOG_NAP_UNTIL_MIN 1260
28#define HRV_WALK_STEPS_DEFAULT 10
92#define HRV_LOG_ASLEEP 0x80
93#define HRV_LOG_STATE_MASK 0x0F
171bool hrv_log_get(
const HrvLog *log,
int back,
int *ms, uint32_t *at_min, uint8_t *flags);
int hrv_log_night_avg(const HrvLog *log)
The average of the readings taken asleep in the latest night.
Definition hrv_log.c:194
void hrv_log_today(const HrvLog *log, int *low_ms, int *avg_ms, int *high_ms)
Today's resting readings summed up.
Definition hrv_log.c:162
bool hrv_log_counts(HrvState state, HrvCount count)
Whether a burst in one state counts for the main reading.
Definition hrv_log.c:31
#define HRV_LOG_HOURS
Today's readings by the hour from midnight.
Definition hrv_log.h:23
int hrv_log_hour_avg(const HrvLog *log, int hour)
Today's average of the resting readings in one hour.
Definition hrv_log.c:151
bool hrv_log_last(const HrvLog *log, HrvState state, int *ms, uint32_t *at_min)
The latest reading of one kind.
Definition hrv_log.c:204
void hrv_log_reset(HrvLog *log)
Empties the log.
Definition hrv_log.c:11
HrvCount
Which bursts count for the main reading. The first is the one a face gets when it sets none.
Definition hrv_log.h:45
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 ...
Definition hrv_log.c:44
int hrv_log_count(const HrvLog *log)
How many readings the history holds, up to HRV_LOG_SLOTS.
Definition hrv_log.c:118
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.
Definition hrv_log.c:132
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.
Definition hrv_log.c:57
HrvState
What the wearer was doing through a reading's burst.
Definition hrv_log.h:34
#define HRV_LOG_SLOTS
How many of the latest readings the history keeps.
Definition hrv_log.h:22
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.
Definition hrv_log.c:16
@ HRV_COUNT_STILL
Only still bursts count.
Definition hrv_log.h:47
@ HRV_COUNT_NOT_WALKING
Still and busy bursts count, walking ones do not.
Definition hrv_log.h:46
@ HRV_COUNT_ANY
Every burst counts.
Definition hrv_log.h:48
@ HRV_STATE_WALKING
The face's walking step count or more through the burst.
Definition hrv_log.h:37
@ HRV_STATE_STILL
The wrist moved no more than the face's still limit, and no walk.
Definition hrv_log.h:35
@ HRV_STATE_BUSY
The wrist moved more, such as eating or a mouse and keyboard, but no walk.
Definition hrv_log.h:36
One burst, for a readout that shows each burst: what the wearer did and what came of it.
Definition hrv_log.h:59
uint32_t at_sec
When the burst ended, in seconds, or 0 for an empty slot.
Definition hrv_log.h:60
bool counted
Whether it became the main reading.
Definition hrv_log.h:67
int16_t steps
Its steps, or -1 when not known.
Definition hrv_log.h:63
uint8_t state
Its HrvState.
Definition hrv_log.h:64
int16_t ms
Its reading in ms, or -1 when it was dropped or gave none.
Definition hrv_log.h:61
int16_t score
Its movement score, or -1 when there was none.
Definition hrv_log.h:62
uint8_t gaps
How many gaps it heard after the settle.
Definition hrv_log.h:66
uint8_t kept
How many beat to beat differences went into its reading.
Definition hrv_log.h:65
The readings kept, in the shape that goes to flash. Start it with hrv_log_reset.
Definition hrv_log.h:77
uint32_t state_at_min[HRV_STATE_COUNT]
When the latest reading of each kind was taken, or 0 for none.
Definition hrv_log.h:79
uint32_t night_last_min
When the last reading taken asleep came, or 0 for none.
Definition hrv_log.h:80
int32_t today
The day the hourly totals belong to.
Definition hrv_log.h:81
uint16_t hour_sum[HRV_LOG_HOURS]
Today's resting readings added up by the hour.
Definition hrv_log.h:82
uint8_t night_count
How many readings went into the night's total.
Definition hrv_log.h:88
uint16_t night_sum
The readings taken asleep this night, added up.
Definition hrv_log.h:83
uint32_t at_min[HRV_LOG_SLOTS]
When each kept reading was taken, in minutes, or 0 for an empty slot.
Definition hrv_log.h:78
uint8_t state_ms[HRV_STATE_COUNT]
The latest reading of each kind in ms.
Definition hrv_log.h:87
uint8_t hour_count[HRV_LOG_HOURS]
How many readings went into each hour's total.
Definition hrv_log.h:86
uint8_t flags[HRV_LOG_SLOTS]
Each kept reading's HrvState, plus HRV_LOG_ASLEEP.
Definition hrv_log.h:85
uint8_t head
The slot the next reading goes in.
Definition hrv_log.h:89
uint8_t ms[HRV_LOG_SLOTS]
Each kept reading in ms.
Definition hrv_log.h:84