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

Turns the beat gaps the watch reports into heart rate variability, as RMSSD in ms. More...

#include "health/hrv_run.h"
#include <string.h>

Functions

static uint32_t root_floor (uint32_t value)
 The square root of a whole number, rounded down.
void hrv_run_reset (HrvRun *run)
 Empties a run, so the next gap starts it.
int hrv_run_finish (HrvRun *run)
 Ends a run and empties it. How many differences it held stays in finished_diffs, so a caller can say how much of the burst went into the reading.
bool hrv_run_quiet (const HrvRun *run, uint32_t now_sec)
 Whether a run has gone quiet, so it is finished and waiting to be read.
int hrv_run_push (HrvRun *run, uint16_t ppi_ms, uint32_t now_sec)
 Adds one gap from the watch.
bool hrv_reading_stale (uint32_t measured_at, uint32_t now_sec, uint16_t period_sec)
 Whether a reading is too old to show.
bool hrv_should_ask (bool sampling, uint32_t gap_at, uint32_t asked_at, uint32_t now_sec, uint16_t period_sec)
 Whether to ask the watch for beat gaps again.
bool hrv_hold_over (uint32_t held_since, uint32_t now_sec)
 Whether the sensor has been held on for a burst as long as it may be.
uint8_t hrv_settle_gaps (uint16_t asked)
 How many gaps to leave out at the start of a burst, from the count a face asked for.

Detailed Description

Turns the beat gaps the watch reports into heart rate variability, as RMSSD in ms.

Function Documentation

◆ root_floor()

uint32_t root_floor ( uint32_t value)
static

The square root of a whole number, rounded down.

The watch has no hardware floating point, so this walks the bits instead of calling sqrt.

Parameters
valueThe number to take the root of.
Returns
The largest whole number whose square is no more than value.