Syggestions

Dependencies:   CheckRTC LPS25H hts221

Fork of ELEC350-extended-referral2 by satbir panesar

Files at this revision

API Documentation at this revision

Comitter:
noutram
Date:
Thu Nov 23 11:50:35 2017 +0000
Parent:
46:794973f66ef6
Commit message:
Suggestions

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Nov 23 11:40:53 2017 +0000
+++ b/main.cpp	Thu Nov 23 11:50:35 2017 +0000
@@ -26,7 +26,13 @@
 char *buf;
 size_t sz;
 
+typedef struct {
+    float temp;
+    float press;
+    float humid;
+} measurement;
 
+measurement buffer [120];
 
 LPS25H barometer(i2c2, LPS25H_V_CHIP_ADDR);
 HTS221 humidity(I2C_SDA, I2C_SCL);
@@ -119,17 +125,25 @@
     while (true) {
         Thread::signal_wait(99);
         //Get samples
-        humidity.ReadTempHumi(&tempCelsius, &humi); // reads temperature and humity levels
-        barometer.get(); // gets barometer readings
-        //Put in buffer
-        typedef struct {
-            float temp;
-            float press;
-            float humid;
-        } measurement;
-        measurement buffer [120];
+        measurement m;
+        
         
+        float pressure = barometer.pressure();
+        m.pressure = pressure;
 
+        float temp;
+        float humidity;
+        humidity.ReadTempHumi(&temp, &humidity); // reads temperature and humity levels
+        m.humidity = humidity;
+        m.temperature = temp;
+        
+        buffer[oldest] = m;
+        
+        //update oldest
+        oldest++;
+        //wrap back to zero if at the end
+        //TO DO
+        
 
 
     }