Jon Trinder
/
gu_squirt_tester
Test code for interfacing to megasquirt ECU.
Diff: Counter/Counter.h
- Revision:
- 0:cf99a7b873b3
diff -r 000000000000 -r cf99a7b873b3 Counter/Counter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Counter/Counter.h Sat Feb 14 08:50:32 2015 +0000 @@ -0,0 +1,34 @@ +#ifndef COUNTER_ +#define COUNTER_ + +#define DEBOUNCING_INTERVAL 200 // Debouncing interval (in mili-seconds) +/*=====================================================================================*/ +// Counter object, which also setups up irq +/*=====================================================================================*/ + +//from http://mbed.org/handbook/InterruptIn, modified to add debouncing +class Counter +{ +public: + Counter(PinName pin, void (*function)(void)); + +void increment(); + +int read(); + +int set(int val); + +void reset(); + +private: + InterruptIn _interrupt; + volatile int _count; + Timer t; // To manage debounce by menchanical switch +protected: + //the callback + FunctionPointer jim; +}; + + + +#endif