Proj 324 Final

Fork of ELEC351_Group_T by Plymouth ELEC351 Group T

Revision:
15:c1592fc1a501
Parent:
13:db857b3744c6
Child:
16:067916791a25
--- a/main.cpp	Wed Dec 20 15:37:12 2017 +0000
+++ b/main.cpp	Sun Dec 24 14:15:57 2017 +0000
@@ -22,7 +22,7 @@
 #define NotSamplingTime 0
 #define Print_Time_to_LCD 1
 #define Dont_Print_Time_to_LCD 0
-#define TimerInterval 15 //This is in seconds
+#define TimerInterval 1 //This is in seconds
 #define EDGE_RISEN 1
 #define EDGE_FALLEN 0
 
@@ -62,6 +62,7 @@
 string buffer_time = 0;
 
 char buffer[32];
+char scom_time_buffer[32];
         
 
 void SW1FallingEdge();
@@ -180,8 +181,8 @@
         time_t seconds = time(NULL);
         //pc.printf("Time as seconds since January 1, 1970 = %d\n", seconds);       
         //pc.printf("Time as a basic string = %s", ctime(&seconds));
-        strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds));
-        pc.printf("Current Time:%s", buffer);
+        //strftime(buffer, 32, "%I:%M %p\n\r", localtime(&seconds));
+        //pc.printf("Current Time:%s", buffer);
         
         Thread::wait(1000);
     }   
@@ -190,7 +191,6 @@
 
 void Serial_Comms()//Thread for Serial Communications
 {
-    pc.printf("Hello World \n");
     while(1)
     {
         osEvent evt_serial = mail_box.get();                                   //Get the latest entry from "mail_box"
@@ -205,7 +205,10 @@
             msg_serial.set_pressure(Rec_Data_Serial->get_pressure());
             msg_serial.set_light(Rec_Data_Serial->get_light());  
             
-            pc.printf("Time = %d\t", msg_serial.get_time());                   //Print Time
+            time_t scom_time = msg_serial.get_time();
+            strftime(scom_time_buffer, 32, "%I:%M %p\t", localtime(&scom_time));
+            pc.printf("Time = %s", scom_time_buffer);
+            
             pc.printf("Temperature = %f\t", msg_serial.get_temperature());     //Print Temperature
             pc.printf("Pressure = %f\t", msg_serial.get_pressure());           //Print Pressure
             pc.printf("Light = %f\n\r", msg_serial.get_light());               //Print Light
@@ -230,7 +233,7 @@
         temp = sensor.getTemperature();         //Read Temperature
         pressure = sensor.getPressure();        //Read Pressure
         lux = adcIn.read();                     //Read Light
-        buffer_time = buffer;                   //Read Time
+        time_t buffer_time = time(NULL);                   //Read Time
         
         DATA *Send_Data = mail_box.alloc();           //Allocate a block from the memory pool, Type Data
         
@@ -259,10 +262,11 @@
 int main() 
 {  
     //Greeting
-    printf("Testing\n\n");    
+    printf("Test Start\n\n\r");    
     set_time(1512940530);               //Set RTC time to December 10 2017
     pc.baud(9600);                      //Sets the Serial Comms Baud Rate
     
+    /*
     post();     //Power on Self Test
     
     //Initialise the SD card (this needs to move)
@@ -288,6 +292,7 @@
     //Last message before sampling begins
     lcd.cls();
     lcd.printf("READY\n\n");
+    */
     
     //Run interrupt
     Sample_timer.attach(&Sample_signal_set,TimerInterval);
@@ -297,9 +302,9 @@
     t1.start(Sample);
     t2.start(Serial_Comms);
     t3.start(Time);
-    t4.start(PrintTime);
-    t5.start(ModeSelection);
-    t6.start(Network);
+    //t4.start(PrintTime);
+    //t5.start(ModeSelection);
+    //t6.start(Network);
     //Main thread ID
     
     idMain = osThreadGetId();   //CMSIS RTOS call
@@ -319,6 +324,7 @@
     }
     
     //Close File
+    /*
     fclose(fp);
     
     //Close down
@@ -326,6 +332,7 @@
     printf("Unmounted...\n");
     lcd.cls();
     lcd.printf("Unmounted...\n\n");
+    */
     
     while(true) {
         greenLED = 1;