Lab 2 Part 2 - Polling Modified

Fork of digitalInPolling_sample by William Marsh

Files at this revision

API Documentation at this revision

Comitter:
diviavad
Date:
Fri Feb 02 17:15:34 2018 +0000
Parent:
2:cd1fe8c29793
Commit message:
Version 1

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r cd1fe8c29793 -r 446895514289 main.cpp
--- a/main.cpp	Tue Jan 16 18:02:44 2018 +0000
+++ b/main.cpp	Fri Feb 02 17:15:34 2018 +0000
@@ -16,7 +16,7 @@
 
 enum buttonPos { up, down, bounce }; // Button positions
 void polling() {
-    buttonPos pos = up ;
+    buttonPos pos = up ;//chose positing in enum
     int bcounter = 0 ;
     while (true) {
         switch (pos) {
@@ -50,14 +50,33 @@
     Note that if this thread completes, nothing else works
  */
 int main() {
-    led = 1 ;  // Initially off
-    pollT.start(callback(polling));
-
+      // Initially off
+    int wait_time= 200;
+    pollT.start(callback(polling));//start thread to check button
+    int counter=1;
     while(true) {
+        led = !led;
         if (pressEvent) {
+            if (counter==2){
+                wait_time=400;
+                }
+            else if(counter==3){
+                wait_time=600;
+                }
+            else if(counter==4){
+                wait_time=800;
+                }
+            else if(counter==5){
+                wait_time=1000;
+                counter=0;
+                }
+  
             pressEvent = 0 ; // clear the event variable
-            led = !led ;
+            led =!led ;//LED ON
+          
+            
+            counter++;
         }
-        Thread::wait(100) ;
+        Thread::wait(wait_time);
     }
 }
\ No newline at end of file