my coursework

Dependencies:   CheckRTC LPS25H hts221

Fork of ELEC350-extended-referral by satbir panesar

Files at this revision

API Documentation at this revision

Comitter:
spanesar
Date:
Tue Nov 21 17:13:45 2017 +0000
Parent:
41:ce3d6fb38d3b
Commit message:
Tried to thread the serial functions but it locks

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Nov 17 14:40:45 2017 +0000
+++ b/main.cpp	Tue Nov 21 17:13:45 2017 +0000
@@ -62,6 +62,8 @@
     string buffer_str(buffer);
     char date [32];
     strftime(date, 32, "%Y/%m/%d %a", localtime(&seconds));
+      char time [32];
+    strftime(time, 32, "%H:%M:%S %p", localtime(&seconds));
     
     if(buffer_str=="READALL") {
         humidity.ReadTempHumi(&tempCelsius, &humi); // reads temperature and humity levels
@@ -69,12 +71,13 @@
         // displays all the variables of time, date, temperature, humidity and all the barometric readings to the serial
         printf("%s, %s, %4.2fC , %3.1f%%, %6.1f, %4.1f\n\r", time, date, tempCelsius, humi, barometer.pressure(), barometer.temperature());
         myled = 1; // LED is ON
+        Thread::wait(200); // 200 ms NB 'Thread::wait(int d);' !!! d is in milliseconds!
+        myled = 0; // LED is OFF
         t2.signal_set(READALL_OFF);
         }
         Thread::wait(200);
-        //Thread::wait(200); // 200 ms NB 'Thread::wait(int d);' !!! d is in milliseconds!
-        //myled = 0; // LED is OFF
-        //Thread::wait(100); // 100 ms
+        
+        
         }
 }
 void function2()
@@ -86,6 +89,8 @@
     string buffer_str(buffer);
     char date [32];
     strftime(date, 32, "%Y/%m/%d %a", localtime(&seconds));
+      char time [32];
+    strftime(time, 32, "%H:%M:%S %p", localtime(&seconds));
     if(buffer_str=="SETTIME") {
         set_time(1508268288);
         printf("time and date updated to %s %s\n\r", time, date);
@@ -109,6 +114,8 @@
     string buffer_str(buffer);
     char date [32];
     strftime(date, 32, "%Y/%m/%d %a", localtime(&seconds));
+      char time [32];
+    strftime(time, 32, "%H:%M:%S %p", localtime(&seconds));
     if(buffer_str=="SETT") {
         for (count = 0; count < 5; count++) {
             sz = snprintf(NULL, 0,"%s, %s, %4.2fC , %3.1f%%, %6.1f, %4.1f\n\r", time, date, tempCelsius, humi, barometer.pressure(), barometer.temperature());
@@ -138,7 +145,7 @@
         if(buffer_str=="READ") {
             printf("%s\n\r", buf);
             myled = 1;
-            t5.signal_set(READ_OFF);
+            osSignalSet(idMain, ALL_OFF);
             }
             //Thread::wait(200);
             //myled = 0;
@@ -159,8 +166,7 @@
     id3 = t3.gettid();
     id4 = t4.gettid();
     time_t seconds = time(NULL);
-    char time [32];
-    strftime(time, 32, "%H:%M:%S %p", localtime(&seconds));
+  
     humidity.init();
     humidity.calib();
     printf("Type SETTIME to set time and date [enter] \n\r");