Detecting changes in the state of particular pin
Fork of PinDetect by
Diff: PinDetect.h
- Revision:
- 2:cb3afc45028b
- Parent:
- 1:611a8f5ac65c
- Child:
- 3:12183fe8a09d
--- a/PinDetect.h Thu Jan 13 09:53:26 2011 +0000 +++ b/PinDetect.h Thu Jan 13 11:09:22 2011 +0000 @@ -166,6 +166,8 @@ public: + friend class Ticker; + PinDetect() { error("You must supply a PinName"); } /** PinDetect constructor @@ -202,6 +204,7 @@ */ void setSampleFrequency(int i = PINDETECT_SAMPLE_PERIOD) { _sampleTime = i; + _prevState = _in->read(); _ticker->attach_us( this, &PinDetect::isr, _sampleTime ); } @@ -449,7 +452,8 @@ * Read the value of the pin being sampled. */ operator int() { return _in->read(); } - + +protected: /** The Ticker periodic callback function */ void isr(void) {