-
Notifications
You must be signed in to change notification settings - Fork 0
/
AirwaySensors.h
50 lines (46 loc) · 1.28 KB
/
AirwaySensors.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef _AIRWAYSENSORS_H_
#define _AIRWAYSENSORS_H_
#define SENSOR_COUNT 6
//for uint8_t
#include <LUFA/Platform/Platform.h>
#include "Config/AppConfig.h"
#include "RunningVariance.h"
#include "Timer.h"
#include <math.h>
typedef enum {
RV_STATE_NOEVT
, RV_STATE_INEVT
} rv_stm_state_t;
typedef struct {
rv_stm_state_t st;
ms_time_t start_time;
TIME_t host_start_time;
ms_time_t last_renew;
int cur;
RunVar_t fst;
RunVar_t snd;
} rv_state_t;
typedef struct {
TIME_t host_time_start;
ms_time_t evt_dur;
uint8_t location;
} event_t;
_Static_assert(sizeof(event_t) == GET_SENSOR_EVENT_REPORT_SIZE,
"GET_SENSOR_EVENT_REPORT_SIZE is wrong");
typedef struct {
const unsigned int buflen;
int curempty;
int last_real;
unsigned int occupancy;
event_t evtbuf[];
} event_buf_t;
void setup_airwaysensor(void);
void airwaysensor_task(uint16_t* adc_vals, float* outs, float* thresh, event_buf_t* event);
//TODO add ATTR_NON_NULL_PTR_ARG(k)
float rv_push(rv_state_t* o, ms_time_t time, float val, float thresh, event_t* evt, int* evt_used);
float rv_curvarest(rv_state_t* o);
float rv_curmean(rv_state_t* o);
//use it immediately, it's not sticking around
const event_t* deq_event(event_buf_t* ebuf);
void event_to_wire(const event_t* e, uint8_t w[]);
#endif