Project

General

Profile

Statistics
| Branch: | Revision:

robobuggy / arduino / RadioBuggyMega / filter.h @ 0c80370b

History | View | Annotate | Download (540 Bytes)

1
/**
2
 * @file filter.h
3
 * @brief Filter to filter data from rc_available
4
 *
5
 * @author: Audrey Yeoh (ayeoh)
6
 * 
7
 */
8

    
9
#ifndef _FILTER_H_
10
#define _FILTER_H_
11

    
12
#ifdef __cplusplus
13
extern "C"{
14
#endif
15

    
16
#define FILTER_LEN 5 // Averaging window size
17

    
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
28

    
29

    
30
#ifdef __cplusplus
31
}
32
#endif
33

    
34
#endif
35

    
36