Loading...
Searching...
No Matches
hrv_motion.h
Go to the documentation of this file.
1
17#pragma once
18#include <stdbool.h>
19#include <stdint.h>
20
25
26#define HRV_MOTION_STILL_DEFAULT 60
27#define HRV_MOTION_MIN_SAMPLES 20
28
32typedef struct
33{
34 int16_t last_x;
35 int16_t last_y;
36 int16_t last_z;
37 bool primed;
38 uint32_t sum;
39 uint16_t samples;
40} HrvMotion;
41
47void hrv_motion_reset(HrvMotion *motion);
48
57void hrv_motion_push(HrvMotion *motion, int16_t x_mg, int16_t y_mg, int16_t z_mg);
58
65int hrv_motion_score(const HrvMotion *motion);
66
77bool hrv_motion_over(const HrvMotion *motion, uint16_t max_mg);
78
92bool hrv_motion_cannot_pass(const HrvMotion *motion, uint16_t max_mg, uint32_t max_samples);
93
void hrv_motion_push(HrvMotion *motion, int16_t x_mg, int16_t y_mg, int16_t z_mg)
Adds one accelerometer sample.
Definition hrv_motion.c:29
int hrv_motion_score(const HrvMotion *motion)
The average movement per sample so far.
Definition hrv_motion.c:45
void hrv_motion_reset(HrvMotion *motion)
Empties the movement, ready for the next burst.
Definition hrv_motion.c:24
bool hrv_motion_cannot_pass(const HrvMotion *motion, uint16_t max_mg, uint32_t max_samples)
Whether the burst can no longer finish under a limit, however still the wrist stays.
Definition hrv_motion.c:60
bool hrv_motion_over(const HrvMotion *motion, uint16_t max_mg)
Whether the wrist has moved more than a limit through the burst so far.
Definition hrv_motion.c:55
The movement seen over one burst. Start it with hrv_motion_reset.
Definition hrv_motion.h:33
int16_t last_x
The sample before on the x axis, in milli-g.
Definition hrv_motion.h:34
int16_t last_y
The sample before on the y axis, in milli-g.
Definition hrv_motion.h:35
uint32_t sum
The movement from one sample to the next, added up.
Definition hrv_motion.h:38
uint16_t samples
How many moves are added up.
Definition hrv_motion.h:39
bool primed
Whether there is a sample before to measure from.
Definition hrv_motion.h:37
int16_t last_z
The sample before on the z axis, in milli-g.
Definition hrv_motion.h:36