mbed with Nintendo DS touchpad, accelerometer & touchpad.

Dependencies:   mbed

Committer:
Clemo
Date:
Wed May 05 12:10:15 2010 +0000
Revision:
0:0a76ae27065b

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Clemo 0:0a76ae27065b 1 /*
Clemo 0:0a76ae27065b 2 mbed touchpad & accelerometer experiments.
Clemo 0:0a76ae27065b 3
Clemo 0:0a76ae27065b 4 CPV, 14/09/2009
Clemo 0:0a76ae27065b 5 */
Clemo 0:0a76ae27065b 6
Clemo 0:0a76ae27065b 7
Clemo 0:0a76ae27065b 8 #ifndef __FILTERS_H__
Clemo 0:0a76ae27065b 9 #define __FILTERS_H__
Clemo 0:0a76ae27065b 10
Clemo 0:0a76ae27065b 11 #define FILTER_MAX_SIZE 16
Clemo 0:0a76ae27065b 12
Clemo 0:0a76ae27065b 13 class FilterBoxF
Clemo 0:0a76ae27065b 14 {
Clemo 0:0a76ae27065b 15 public:
Clemo 0:0a76ae27065b 16 FilterBoxF(void) { initialise(FILTER_MAX_SIZE); }
Clemo 0:0a76ae27065b 17 void initialise(unsigned int size);
Clemo 0:0a76ae27065b 18 float tick(float in);
Clemo 0:0a76ae27065b 19 float get() { return m_out; }
Clemo 0:0a76ae27065b 20 float operator()(void) { return m_out; }
Clemo 0:0a76ae27065b 21
Clemo 0:0a76ae27065b 22 protected:
Clemo 0:0a76ae27065b 23 float m_history[FILTER_MAX_SIZE];
Clemo 0:0a76ae27065b 24 unsigned int m_size;
Clemo 0:0a76ae27065b 25 unsigned int m_index;
Clemo 0:0a76ae27065b 26 float m_out;
Clemo 0:0a76ae27065b 27 };
Clemo 0:0a76ae27065b 28
Clemo 0:0a76ae27065b 29
Clemo 0:0a76ae27065b 30 class FilterBoxI
Clemo 0:0a76ae27065b 31 {
Clemo 0:0a76ae27065b 32 public:
Clemo 0:0a76ae27065b 33 FilterBoxI(void) { initialise(FILTER_MAX_SIZE); }
Clemo 0:0a76ae27065b 34 void initialise(unsigned int size);
Clemo 0:0a76ae27065b 35 int tick(int in);
Clemo 0:0a76ae27065b 36 int operator()(void) { return m_out; }
Clemo 0:0a76ae27065b 37
Clemo 0:0a76ae27065b 38 protected:
Clemo 0:0a76ae27065b 39 int m_history[FILTER_MAX_SIZE];
Clemo 0:0a76ae27065b 40 unsigned int m_size;
Clemo 0:0a76ae27065b 41 unsigned int m_index;
Clemo 0:0a76ae27065b 42 int m_out;
Clemo 0:0a76ae27065b 43 };
Clemo 0:0a76ae27065b 44
Clemo 0:0a76ae27065b 45
Clemo 0:0a76ae27065b 46 class FilterIirI
Clemo 0:0a76ae27065b 47 {
Clemo 0:0a76ae27065b 48 public:
Clemo 0:0a76ae27065b 49 FilterIirI(void) { initialise(); }
Clemo 0:0a76ae27065b 50 void initialise(int tau=1, int limit=0xffff);
Clemo 0:0a76ae27065b 51 int tick(int in);
Clemo 0:0a76ae27065b 52 int operator()(void) { return m_out; }
Clemo 0:0a76ae27065b 53
Clemo 0:0a76ae27065b 54 protected:
Clemo 0:0a76ae27065b 55 int m_out;
Clemo 0:0a76ae27065b 56 int m_remainder;
Clemo 0:0a76ae27065b 57 int m_limit;
Clemo 0:0a76ae27065b 58 int m_tau;
Clemo 0:0a76ae27065b 59 };
Clemo 0:0a76ae27065b 60
Clemo 0:0a76ae27065b 61
Clemo 0:0a76ae27065b 62 #endif // __FILTERS_H__