Version 8, working version with Alix, sams and ollies code. Displays time, date and sensor info onto terminal, LCD and networking, and saves onto SD card.

Dependencies:   BMP280 ELEC350-Practicals-FZ429 TextLCD BME280 ntp-client

Revision:
10:eea19f8e6122
Parent:
9:f5eae5211225
Child:
11:42b0c567cc8c
--- a/LCD.hpp	Fri Dec 07 13:24:50 2018 +0000
+++ b/LCD.hpp	Thu Dec 13 15:24:22 2018 +0000
@@ -4,6 +4,9 @@
 #include "messageStruct.hpp"
 #include "sample_hardware.hpp"
 #include "Network.hpp"
+#include <stdio.h>
+#include <string.h>
+
 
 
 class LCD_Data
@@ -15,6 +18,11 @@
          float pressure;  //current pressure of sensor, updated every 15 seconds
          float fLDR;      //current light level from LDR, updated every 15 seconds
          int flip;
+         string day;
+         string month;
+         string date;
+         string time;
+         string year;
          
 
      private:
@@ -61,7 +69,7 @@
          update_LDR(msg.ldr);
     }
     
-    
+
     
     
     void display_LCD() //updates the current LCD display with the new sensor information
@@ -93,12 +101,41 @@
        
        
        
-       void update_time_date (){
-        timestamp = ntp.get_timestamp();
-       //timestamp = Network::ntp.get_timestamp(); //gets current time and date from NTP server in unix format
-      // timestamp = m_oNet.ntp.get_timestamp(); //gets current time and date from NTP server in unix format
+       time_and_date update_time_date (){
+           
+       timestamp = ntp.get_timestamp(); //reads the current time from a local NTP server in UNIX format
+        
+       string current_time =  ctime(&timestamp); //converts time to human readable format string
+
+
+     
+     day.assign(current_time, 0, 3); //extract only day from current_time string
+     month.assign(current_time, 4, 3); //extract only month from ""
+     date.assign(current_time, 9, 1); //extract only date from ""
+     time.assign(current_time, 11, 8); //extract only time from ""
+     year.assign(current_time, 20, 4); //extract only year from ""
+     
+     
+     //printf("current day is: %s\n", day);
+       // printf("current year is: %s\n", year);
+      // printf("current time is: %s\n", time);
+       // printf("current date is: %s\n", date);
+     // printf("current month is: %s\n", month);
+     
+ 
+          
+       m_oNet.Network_Queue.call(&m_oNet, &Network::update_Time, current_time);
        
-       flip = 3; //will tell the user that the time has been updated on next FLIP instance
+       time_and_date Timemsg; // Define instance of message structure
+        Timemsg.day = day;
+        Timemsg.month = month;
+        Timemsg.date = date;
+        Timemsg.time = time;
+        Timemsg.year = year;
+        Timemsg.current_time = current_time;
+        return Timemsg;
+        
+       flip = 3; //will tell the user that the time has been updated on next FLIP instance with the LCD
        
        }