lab2 first example

Fork of digitalInPolling_sample by William Marsh

Files at this revision

API Documentation at this revision

Comitter:
cvmanuel
Date:
Thu Jan 25 17:26:07 2018 +0000
Parent:
2:cd1fe8c29793
Commit message:
lab2 initial version

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r cd1fe8c29793 -r 16205569b8b5 main.cpp
--- a/main.cpp	Tue Jan 16 18:02:44 2018 +0000
+++ b/main.cpp	Thu Jan 25 17:26:07 2018 +0000
@@ -14,6 +14,8 @@
 Thread pollT ; // thread to poll
 volatile int pressEvent = 0 ;  // Variabe set by the polling thread
 
+volatile int timef = 200;
+
 enum buttonPos { up, down, bounce }; // Button positions
 void polling() {
     buttonPos pos = up ;
@@ -54,10 +56,18 @@
     pollT.start(callback(polling));
 
     while(true) {
+        led = !led ;
         if (pressEvent) {
             pressEvent = 0 ; // clear the event variable
-            led = !led ;
+            if(timef<1000)
+            {
+                timef+=200;
+            }else if(timef>=1000)
+            {
+                timef=200;
+                }
+            //led = !led ;
         }
-        Thread::wait(100) ;
+        Thread::wait(timef) ;
     }
 }
\ No newline at end of file