polling for lab2

Fork of digitalInPolling_sample by William Marsh

Revision:
3:d35e20a7b695
Parent:
2:cd1fe8c29793
--- a/main.cpp	Tue Jan 16 18:02:44 2018 +0000
+++ b/main.cpp	Thu Feb 01 17:25:02 2018 +0000
@@ -9,10 +9,12 @@
 // A second thread (the default one) checks for the press event and toggles the LED
 
 DigitalIn b1(PTD0, PullUp);
-DigitalOut led(LED1);
+DigitalOut led(LED1); //Set press count 
 
 Thread pollT ; // thread to poll
 volatile int pressEvent = 0 ;  // Variabe set by the polling thread
+volatile int timecount =200;
+
 
 enum buttonPos { up, down, bounce }; // Button positions
 void polling() {
@@ -49,15 +51,33 @@
 /*  ---- Main function (default thread) ----
     Note that if this thread completes, nothing else works
  */
+
+ 
+
 int main() {
     led = 1 ;  // Initially off
     pollT.start(callback(polling));
+    
 
     while(true) {
-        if (pressEvent) {
-            pressEvent = 0 ; // clear the event variable
-            led = !led ;
+         
+         led = !led ;  
+         
+         if (pressEvent) {
+            pressEvent = 0 ;
+            
+         if (timecount < 1000) {
+             
+            timecount+=200;  
         }
-        Thread::wait(100) ;
+        else {
+           
+           timecount = 200;
+       }
+       }
+        Thread::wait(timecount) ;
     }
-}
\ No newline at end of file
+   
+    
+}
+ 
\ No newline at end of file