Revision 0c80370b
Added struct filter_state, so we can filter multiple signals
arduino/RadioBuggyMega/filter.h | ||
---|---|---|
13 | 13 |
extern "C"{ |
14 | 14 |
#endif |
15 | 15 |
|
16 |
#define FILTER_LEN 5 // Averaging window size |
|
16 | 17 |
|
17 |
int filter(int val); // returns the int that has been filtered |
|
18 |
struct filter_state { |
|
19 |
int prev_values[FILTER_LEN]; |
|
20 |
char started; |
|
21 |
int pos; // next index to update |
|
22 |
}; |
|
23 |
|
|
24 |
|
|
25 |
void filter_init(struct filter_state *state); |
|
26 |
|
|
27 |
int filter_loop(struct filter_state *state, int val); // returns the int that has been filtered |
|
18 | 28 |
|
19 | 29 |
|
20 | 30 |
#ifdef __cplusplus |
... | ... | |
23 | 33 |
|
24 | 34 |
#endif |
25 | 35 |
|
26 |
|
|
36 |
|
Also available in: Unified diff