Changed default PinMode from PullDown to PullDefault for compatibility with KL25Z

Dependents:   ChordJoy idd_hw2_andrewhead_chordjoy idd_hw2_kevinlee_typinglove idd_hw2_kevinlee_typinglove ... more

Fork of PinDetect by Andy K

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 {