PRO2_Team 1_collected code with ticker_not working yet
Fork of PRO2_samlet_kode by
Revision 2:0864be57f81e, committed 2017-05-19
- Comitter:
- OlgaHoeyer
- Date:
- Fri May 19 10:59:26 2017 +0000
- Parent:
- 1:135bd458e39e
- Child:
- 3:b6c7d01e1eb8
- Commit message:
- get_temp modul changed, Ticker added_not working yet
Changed in this revision
--- a/get_humid.cpp Thu May 18 22:34:57 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -//Author : Olga Hoeyer -//Date : 18 May 2017 -//Version : 2.0 -//Changes: Structure changed to modular, to ease future use of the funktion. -//Copyright : Open for everyone -// -// Description : Function will get a humidity value from the SHF-15 sensor -// Output is relative humidity (float). - - -#include "mbed.h" -#include "SHTx/sht15.hpp" - -DigitalOut busy(LED1); -//ports on the Nucleo: PB_8, PB_9 -SHTx::SHT15 sensor(PB_8, PB_9); - -float GetHumid() -{ -//VARIABLES: - float humidity; //this will be data read from sensor - -// Speed things up a bit. - sensor.setOTPReload(false); - sensor.setResolution(true); - - busy = true; - sensor.update(); - busy = false; - - // Temperature in celcius - sensor.setScale(false); - humidity=sensor.getHumidity(); //don't know if it works - - wait(5); - return (humidity); - -} \ No newline at end of file
--- a/get_humid.h Thu May 18 22:34:57 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -//Author : Olga Hoeyer -//Date : 18 May 2017 -//Version : 2.0 -//Changes: Structure changed to modular, to ease future use of the funktion. -//Copyright : Open for everyone -// -// Description : Function will get a humidity value from the SHF-15 sensor -// Output is relative humidity (float). -// -// Usage: GetHumid() - -float GetHumid(); \ No newline at end of file
--- a/get_temp.cpp Thu May 18 22:34:57 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -//Author : Olga Hoeyer -//Date : 18 May 2017 -//Version : 2.0 -//Changes: Structure changed to modular, to ease future use of the funktion. -//Copyright : Open for everyone -// -//Description : Function will get a temperature value from the SHF-15 sensor -//Output is value in Celsius (float). - - -#include "mbed.h" -#include "SHTx/sht15.hpp" - -DigitalOut busy(LED1); -//ports on the Nucleo: PB_8, PB_9 -SHTx::SHT15 sensor(PB_8, PB_9); - -float GetTemperature() -{ -//VARIABLES: - float temperature; //this will be data read from sensor - - // Speed things up a bit. - sensor.setOTPReload(false); - sensor.setResolution(true); - - busy = true; - sensor.update(); - busy = false; - - // Temperature in celcius - sensor.setScale(false); - temperature=sensor.getTemperature(); - - wait(5); - return (temperature); - -} \ No newline at end of file
--- a/get_temp.h Thu May 18 22:34:57 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -//Author : Olga Hoeyer -//Date : 18 May 2017 -//Version : 2.0 -//Changes: Structure changed to modular, to ease future use of the funktion. -//Copyright : Open for everyone -// -// Description : Function will get a temperature value from the SHF-15 sensor -// Output is value in Celsius (float). -// -// Usage: GetTemperature() - -float GetTemperature(); \ No newline at end of file
--- 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