SOFT253 Coursework Weather Reader

Dependencies:   LPS25H hts221

Fork of Soft253-WeatherReader by Joseph Dumpleton

Revision:
1:8585a8d417dc
Parent:
0:b490b8486404
Child:
2:27b92722246b
--- a/main.cpp	Fri Apr 21 14:02:23 2017 +0000
+++ b/main.cpp	Fri Apr 21 17:33:38 2017 +0000
@@ -2,6 +2,7 @@
 #include "rtos.h"
 #include "hts221.h"
 #include "LPS25H.h"
+#include "DataGenerator.h"
 
 
 DigitalOut myled(LED1);
@@ -13,29 +14,43 @@
 char cmd=0;
 uint32_t seconds = 0, minutes=0, hours=0; 
 
-LPS25H barometer(i2c2, LPS25H_V_CHIP_ADDR);
-HTS221 humidity(I2C_SDA, I2C_SCL);
+//LPS25H barometer(i2c2, LPS25H_V_CHIP_ADDR);
+//HTS221 humidity(I2C_SDA, I2C_SCL);
 
+/* Test Data generator */
+DataGenerator dataGen;
 
-int main()
-  {
-  humidity.init();
-  humidity.calib();
-  printf("SOFT253 simple Temperature Humidity and Pressure Sensor Monitor\n\r");
-  printf("Using the X-NUCLEO-IKS01A1 shield and MBED Libraries\n\r");
+int main(){
+    //Humidity sensor setup.
+    //humidity.init();
+    //humidity.calib();
+    
+    printf("SOFT253 simple Temperature Humidity and Pressure Sensor Monitor\n\r");
+    printf("Using the X-NUCLEO-IKS01A1 shield and MBED Libraries\n\r");
+    
     //printf("%#x\n\r",barometer.read_id());
     
-  while(1) 
+    while(1) 
     {
-        humidity.ReadTempHumi(&tempCelsius, &humi);
+        /*Original temperature reader from nucleo. */
+        //humidity.ReadTempHumi(&tempCelsius, &humi);
+        
+        dataGen.ReadTempHumi(&tempCelsius, &humi);
+        
         printf("%4.2fC %3.1f%%", tempCelsius, humi);
-        barometer.get();
-        printf(" %6.1f %4.1f\r\n", barometer.pressure(), barometer.temperature());
+        
+        /*Original line of code working with the nucleo barometer. */
+        //barometer.get();
+        //printf(" %6.1f %4.1f\r\n", barometer.pressure(), barometer.temperature());
+        
+        printf(" %6.1f %4.1f\r\n", dataGen.pressure(), dataGen.temperature());
+        
+        /* Flicker the LED. */
         myled = 1; // LED is ON
         Thread::wait(200); // 200 ms NB 'Thread::wait(int d);' !!! d is in milliseconds! 
         myled = 0; // LED is OFF
         Thread::wait(100); // 100 ms
-    }
+      }
   }