Lab version

Fork of Task327 by Nicholas Outram

Files at this revision

API Documentation at this revision

Comitter:
noutram
Date:
Thu Oct 12 14:57:29 2017 +0000
Parent:
3:384a8f9726ac
Commit message:
Now even simpler

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Oct 12 14:35:26 2017 +0000
+++ b/main.cpp	Thu Oct 12 14:57:29 2017 +0000
@@ -23,10 +23,10 @@
     //Which event does this follow?
     switch (sw1State) {
     case EDGE_RISEN:    
-        sw1.fall(&sw1FallingEdge);  //Now wait for a falling edge
+        sw1.fall(callback(&sw1FallingEdge));  //Now wait for a falling edge
         break;
     case EDGE_FALLEN:
-        sw1.rise(&sw1RisingEdge);   //Now wait for a rising edge
+        sw1.rise(callback(&sw1RisingEdge));   //Now wait for a rising edge
         break;
     } //end switch 
 }
@@ -45,17 +45,16 @@
 
 //Main - only has to initialise and sleep
 int main() {
-    //Initial logging message
-    puts("START");
     
     //Configure interrupts, wait for first rising edge
-    sw1.rise(&sw1RisingEdge);
+    sw1.rise(callback(&sw1RisingEdge));
     
+    //Set LED to ON
+    led    = 1;
+     
     //Main Polling Loop
     while (true) {
-        //Set LED to OFF
-        led    = 0; 
-        
+  
         //Put CPU back to sleep
         sleep();                //woken by rising edge
         puts("Rising");                
@@ -66,10 +65,7 @@
         updateState();
         
         //You can ONLY reach this point if an ISR wakes the CPU twice
-        for (int n=0; n<10; n++) {
-            led = !led;
-            wait(0.1);
-        }
+        led = !led;
         
     } //end while