Turns the beat gaps the watch reports into heart rate variability, as RMSSD in ms. More...
#include <stdbool.h>#include <stdint.h>Go to the source code of this file.
Data Structures | |
| struct | HrvRun |
| One run of beats being added up. Start it with hrv_run_reset. More... | |
Functions | |
| void | hrv_run_reset (HrvRun *run) |
| Empties a run, so the next gap starts it. | |
| int | hrv_run_push (HrvRun *run, uint16_t ppi_ms, uint32_t now_sec) |
| Adds one gap from the watch. | |
| 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_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_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. | |
Turns the beat gaps the watch reports into heart rate variability, as RMSSD in ms.
The watch hands over one gap between two heartbeats at a time. One gap is just the heart rate said another way, so the number worth showing is how much each gap differs from the one before it, taken over a run of clean beats. That is RMSSD, the square root of the mean of the squared differences. Plain C with no SDK, so its specs run on a PC.
Apps never see the sensor's own quality grade, so the rules for which beats count are here. A gap outside a heart rate of 30 to 200 is dropped, and so is one that jumps too far from the one before, which is what a missed or doubled beat looks like. A dropped gap also breaks the chain, so the next difference is only taken between the two good gaps after it, which really are neighbours.