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 by
Revision 3:cf12ac7d8d50, committed 2015-09-20
- Comitter:
- adithya_murali
- Date:
- Sun Sep 20 21:22:54 2015 +0000
- Parent:
- 2:cb3afc45028b
- Commit message:
- modified PinDetect
Changed in this revision
| PinDetect.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r cb3afc45028b -r cf12ac7d8d50 PinDetect.h
--- a/PinDetect.h Thu Jan 13 11:09:22 2011 +0000
+++ b/PinDetect.h Sun Sep 20 21:22:54 2015 +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();
@@ -172,13 +173,13 @@
/** PinDetect constructor
*
- * By default the PinMode is set to PullDown.
+ * By default the PinMode is set to PullDefault.
*
* @see http://mbed.org/handbook/DigitalIn
* @param p PinName is a valid pin that supports DigitalIn
*/
PinDetect(PinName p) {
- init( p, PullDown );
+ init( p, PullDefault );
}
/** PinDetect constructor
@@ -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 {
