CPS_Lab* / Mbed 2 deprecated Lab11

Dependencies:   ATParser TSL2561 mbed

Fork of Lab10 by CPS_Lab*

Files at this revision

API Documentation at this revision

Comitter:
youngs2
Date:
Tue Apr 24 22:51:44 2018 +0000
Parent:
5:3b7d8eb3cf35
Commit message:
added sleep when not connecting or taking data

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Apr 24 14:46:13 2018 +0000
+++ b/main.cpp	Tue Apr 24 22:51:44 2018 +0000
@@ -17,7 +17,8 @@
 
 
 void sendit()
-{     
+{   
+    int sleepvar = 1; 
     float lightnum = lightsensor.lux();
     pc.printf("light = %.5f\n\r", lightnum);
     day[i] = new char[8];
@@ -42,7 +43,8 @@
         {
             free(day[j]);
         }
-    }   
+    }
+    sleepvar = 0;   
 }
 
 void connect() 
@@ -78,8 +80,8 @@
     Teddy = 0;
     connect();
     flipper.attach(&sendit, 10);
-    while(1)
+    while(sleepvar == 0)
     {    
-      wait(420);
+      sleep();
     }
 }