blob: 6c5de172d4531c8b1264fff9a52a9df55f3b3be4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#ifndef _L1_AVG_H
#define _L1_AVG_H
struct running_avg {
/* configuration */
uint16_t period; /* over how many samples to average */
uint16_t min_valid;
int32_t acc_val;
uint16_t num_samples; /* how often did we try to sample? */
uint16_t num_samples_valid; /* how often did we receive valid samples? */
void (*outfn)(struct running_avg *, int32_t avg);
void *priv;
};
/* input a new sample into the averaging process */
void runavg_input(struct running_avg *ravg, int32_t val, int valid);
/* check if sufficient samples have been obtained, and call outfn() */
int runavg_check_output(struct running_avg *ravg);
#endif /* _AVG_H */
|