Sampling ldr temp and pressure data into 120 sample FIFO buffer.

Dependencies:   BME280 BMP280

Fork of Task690-mbed-os-FZ429ZI by University of Plymouth - Stages 1, 2 and 3

Revision:
6:c2299e3de428
Parent:
5:cc1b9f5c27a0
--- a/main.cpp	Sun Dec 10 20:17:31 2017 +0000
+++ b/main.cpp	Sat Dec 23 18:44:37 2017 +0000
@@ -1,4 +1,6 @@
 #include "mbed.h"
+
+#include <string.h>
 //#define BME
 #ifdef BME
 #include "BME280.h"
@@ -9,7 +11,8 @@
 
 // Buffer
 #include "buffer.hpp"
-
+// LCD
+#include "hardware_setup.hpp"
 
  
 #define Signal 1
@@ -61,8 +64,8 @@
 
 void FunctionSample()
 {
-    pc.printf("Testing");
-    pc.printf("%d\n", BUFFERSIZE);
+    pc.printf("Testing with %d sample buffer", BUFFERSIZE);
+    //pc.printf("%d\n", BUFFERSIZE);
     while (true) {
         Thread::signal_wait(Signal);
         led1 = !led1;
@@ -73,9 +76,6 @@
         fLDR = LDR_In;
         pc.printf("LDRinThread = %6.4f\n", fLDR);
         
-        addToBuffer(fLDR);
-        
-        
         //Read BMP280 Sensors (I2C)
         float temp = sensor.getTemperature();
         float pressure = sensor.getPressure();
@@ -83,16 +83,24 @@
         pc.printf("Temperature: %5.1f\n", temp);
         pc.printf("Pressure: %5.1f\n", pressure);
         
+        addToBuffer(fLDR);
+        addToBuffer(temp);
+        addToBuffer(pressure);
+
+        // date and time
+        int year = LCD.year;
+        char month = LCD.month;
+        char day = LCD.day;
+        char hour = LCD.hours;
+        char minute = LCD.minutes;
         
-        //decrement old data when buffer is full
-        //int32_t Nsamples = samplesInBuffer.wait();
-       // pc.printf("Nsamples = %i\n", Nsamples);
-        //if (Nspaces == BUFFERSIZE)
-        //{
-            
+        char DaT[100];
+        int n; 
+        n=sprintf (DaT, "%d.%d.%d %d:%d Data Temp:%5.1f Pressure:%5.1f LDR:%6.4f", year, month, day, hour, minute, temp, pressure, fLDR);
+        pc.printf ("[%s] is a string %d chars long\n",DaT,n);
+        //addToBuffer(DaT); CHANGE addToBuffer to char, as now we only need to put in DaT, which is a char
         
-        //nextChar = tolower(nextChar);
-        //}        
+        
         
         sensorLock.unlock();
         
@@ -122,7 +130,7 @@
         //float _ldr = fLDR;
         //ldrLock.unlock();
         //pc.printf("LDR = %6.4f\n", _ldr);
-        Thread::wait(1000);
+        Thread::wait(3000);
         
         // make scheduler put the board to sleep until a signal is set?
         //Thread::wait(osWaitForever);