Fixed a typo in the example code DigitialOut to DigitalOut
Fork of PinDetect_KL25Z by
Diff: PinDetect.h
- Revision:
- 4:4f11ae3737c7
- Parent:
- 3:2cc013fd659d
- Child:
- 5:054fc24ec446
--- a/PinDetect.h Mon Aug 04 22:50:38 2014 +0000 +++ b/PinDetect.h Tue Aug 05 03:30:12 2014 +0000 @@ -140,6 +140,7 @@ int _samplesTillAssert; int _samplesTillHeldReload; int _samplesTillHeld; + bool _holdRepeat; FunctionPointer _callbackAsserted; FunctionPointer _callbackDeasserted; FunctionPointer _callbackAssertedHeld; @@ -157,7 +158,7 @@ _samplesTillAssertReload = PINDETECT_ASSERT_COUNT; _samplesTillHeldReload = PINDETECT_HOLD_COUNT; _assertValue = PINDETECT_PIN_ASSTERED; - + _holdRepeat = false; _in = new DigitalIn( p ); _in->mode( m ); _prevState = _in->read(); @@ -198,6 +199,13 @@ if ( _in ) delete( _in ); } + /** Set whether hold callback is repeatedly invoked while held. + * + * @param bool true to repeat callback, false to call back only once + */ + void setHoldRepeat(bool repeat) { + _holdRepeat = repeat; + } /** Set the sampling time in microseconds. * * @param int The time between pin samples in microseconds. @@ -484,6 +492,9 @@ _callbackAssertedHeld.call(); else _callbackDeassertedHeld.call(); + if(_holdRepeat) { + _samplesTillHeld = _samplesTillHeldReload; + } } } else {