PRO2_Team 1_collected code with ticker and headers_not working yet

Dependencies:   SHTx mbed

Fork of PRO2_samlet_kode by Olga Høyer

Revision:
2:0864be57f81e
Parent:
1:135bd458e39e
Child:
3:b6c7d01e1eb8
--- a/main.cpp	Thu May 18 22:34:57 2017 +0000
+++ b/main.cpp	Fri May 19 10:59:26 2017 +0000
@@ -1,54 +1,68 @@
 //Defining and Including stuff up here
-#include <mbed.h>
+#include "mbed.h"
 #include "SHTx/sht15.hpp"
-#define temperature_low         //For use in the Data Analysis
-#define temperature_high        //For use in the Data Analysis
-#include "rgb_led.h"            //For use in the RGB_LED_output part
-#include "7_segment_control.h"  //For use in the RGB_LED_output part
-
-// MAIN er ikke færdig rettet!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-
-//Prototype definitions
-void Logging(); //Prototype for Logging
-void Hibernation();
-void Settings();
-void Comparevalues();
-void rgb_outp();
-
-
-//The correct order of files:
+#include <7_segment_control.h>
+#include <compare.h>
+#include <data_out.h>
+#include <logging.h>
+#include <rgb_led.h>
+#include <Ticker.h>
 
 //Declaration of GLOBAL VARIABLES:
 float temperature, humidity;            //this will be data read from sensor
-void GetTemperatureAndHumidity();
-int i,t,set_temp,timespan,status;
+void GetTemperatureAndHumidity();        //via denne function
+
+int temperature_low :=18;
+int temperature_high :=22;  //DELETE LATER!
 
 Serial pc(USBTX, USBRX);
-//DigitalOut busy(LED1);                 
 InterruptIn event(USER_BUTTON);
 DigitalOut myled(LED1);
 DigitalIn up(PA_5);
 DigitalIn down(PA_6);
-
+SHTx::SHT15 sensor(PB_8, PB_9);         //ports on the Nucleo: PB_8, PB_9
 
-//ports on the Nucleo: PB_8, PB_9
-SHTx::SHT15 sensor(PB_8, PB_9);
-
-
+Ticker tick1;
+Ticker tick2;
+Ticker tick3;
+Ticker tick4;
 
 int main()
 {
+    while(1) {
+        logging ();
 
-    Logging();
+        //tick1.atach(Settings(), 20);        //MISSING PROGRAM PART!!!!!!!
+
+        tick2.atach(GetTemperatureAndHumidity(),20);        //Data Collection
+
+        //tick3.atach(Compare_values(hum, temp, temperature_low, temperature_high),20); //Data Analysis
 
-    Settings();
-    
-    GetTemperatureAndHumidity();        //Data Collection
+        tick4.atach(rgb_outp(Compare_values(hum, temp, temperature_low, temperature_high)),20);                  //RGB_LED_output
+
+        return;
+    }
+}
+
+
+void GetTemperatureAndHumidity() //canøt move to the .h file, pga "sensor" definitions.
+{
 
-    Comparevalues( );                    //Data Analysis
+// Speed things up a bit.
+    sensor.setOTPReload(false);
+    sensor.setResolution(true);
+
+    busy = true;
+    sensor.update();
+    busy = false;
 
-    rgb_outp(status);                         //RGB_LED_output
+    // Temperature in celcius
+    sensor.setScale(false);
+    temperature=sensor.getTemperature();
 
-    return 0;
-}
+    // Relative Humidity
+    humidity=sensor.getHumidity();
+
+    wait(5);
+    return;
+}
\ No newline at end of file