V4

Dependencies:   BMP280

Fork of Thread_Communication_V4_fortest by BDG

Files at this revision

API Documentation at this revision

Comitter:
benparkes
Date:
Sat Jan 06 21:18:06 2018 +0000
Parent:
17:aa585f901750
Commit message:
time with mail;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sat Jan 06 19:44:43 2018 +0000
+++ b/main.cpp	Sat Jan 06 21:18:06 2018 +0000
@@ -172,7 +172,10 @@
 // Keep short
 void sensorRead ()
 {
-
+    volatile float LDR = 0;
+    volatile double PRES = 0;
+    volatile double TEMP = 0;
+    
     while (1) {
 
         dataLock.lock(); // Entering Critial Section
@@ -182,11 +185,6 @@
         TEMP = Sensor.getTemperature();
         PRES = Sensor.getPressure();
 
-        memset((char *)TIME, NULL, 21);
-        time(&raw_time);
-        sample_epoch = localtime(&raw_time);
-        strftime((char *)TIME, 21,"%d/%m/%Y, %X", sample_epoch);
-
         dataLock.unlock(); // Exiting Critical Section
 
         Green_int = !Green_int; // debugging
@@ -750,8 +748,12 @@
 
             if (evt.status == osEventMail) {
                 mail_t *mail = (mail_t*)evt.value.p;
-
-                sprintf(X_str,"%s, \n\rTemperature: %2.2f, \n\rPressure: %4.2f, \n\rLight: %.4f", mail->Time_Date, mail->temp_Value, mail->press_Value, mail->LDR_Value);
+                char sample_time[21];
+                int rTime = mail->Time_Date;
+                time((time_t*)rTime);
+                sample_epoch = localtime((time_t*)rTime);
+                strftime(sample_time, 21,"%d/%m/%Y, %X", sample_epoch);
+                sprintf(X_str,"%s, \n\rTemperature: %2.2f, \n\rPressure: %4.2f, \n\rLight: %.4f", sample_time, mail->temp_Value, mail->press_Value, mail->LDR_Value);
 
                 mail_Network.free(mail);
             }