Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of PinDetect_KL25Z by
Diff: PinDetect.h
- Revision:
- 4:4f11ae3737c7
- Parent:
- 3:2cc013fd659d
--- 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 {