Henry Herman
/
touchy
b
Diff: touchbutton.h
- Revision:
- 0:4841f4169944
diff -r 000000000000 -r 4841f4169944 touchbutton.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/touchbutton.h Wed Dec 01 03:29:25 2010 +0000 @@ -0,0 +1,32 @@ + +#ifndef TOUCHBUTTON_H +#define TOUCHBUTTON_H +#define NUMSAMP 10 +//#define DEBUGTOUCH +#define DEBUGTOUCHLED +class TouchButton { + +public: + TouchButton(PinName ain, PinName din, PinName dout, float threshold, int debounceTime, char *nm); + void setThreshold(float level); + void setDebounceTime(int t); + bool checkState(); + float sample(); + void charge(); + +private: + char name[10]; + float currentValue; + float previousValue; + AnalogIn sensor; + DigitalIn charger; + DigitalOut ground; + Timer timer; + Timer debounceTimer; + float analogThreshold; + int timeout_ms; + void storeValue(); + float difference(); +}; + +#endif \ No newline at end of file