Alarm

Dependents:   Alarm

Fork of PinDetect by Andy K

Files at this revision

API Documentation at this revision

Comitter:
AjK
Date:
Thu Jan 13 11:09:22 2011 +0000
Parent:
1:611a8f5ac65c
Commit message:
1.5 See ChangeLog.h

Changed in this revision

ChangeLog.h Show annotated file Show diff for this revision Revisions of this file
PinDetect.h Show annotated file Show diff for this revision Revisions of this file
diff -r 611a8f5ac65c -r cb3afc45028b ChangeLog.h
--- a/ChangeLog.h	Thu Jan 13 09:53:26 2011 +0000
+++ b/ChangeLog.h	Thu Jan 13 11:09:22 2011 +0000
@@ -19,6 +19,10 @@
     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
     THE SOFTWARE.
 
+    1.5     13 Jan 2011 - Made the isr() protected and made the class a friend of Ticker.
+                          Read the previous state and store when the sample frequency is
+                          set so that initial assert_deassert_held() isn't called at startup.
+                              
     1.4     13 Jan 2011 - Added an extra overloaded constructor that allows
                           the DigitalIn PinMode to be passed when the the class
                           is declared. So mode() isn't really needed but is left
diff -r 611a8f5ac65c -r cb3afc45028b PinDetect.h
--- 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) {