PRO2_Team 1_collected code with ticker_not working yet

Dependencies:   SHTx mbed

Fork of PRO2_samlet_kode by Software hold - Team 1 - PRO2 2017

Committer:
OlgaHoeyer
Date:
Fri May 19 11:12:46 2017 +0000
Revision:
3:b6c7d01e1eb8
Parent:
2:0864be57f81e
Child:
4:eb483906704a
tick syntax corrected

Who changed what in which revision?

UserRevisionLine numberNew contents of line
OlgaHoeyer 0:21e9cc38dd31 1 //Defining and Including stuff up here
OlgaHoeyer 2:0864be57f81e 2 #include "mbed.h"
OlgaHoeyer 1:135bd458e39e 3 #include "SHTx/sht15.hpp"
OlgaHoeyer 2:0864be57f81e 4 #include <7_segment_control.h>
OlgaHoeyer 2:0864be57f81e 5 #include <compare.h>
OlgaHoeyer 2:0864be57f81e 6 #include <data_out.h>
OlgaHoeyer 2:0864be57f81e 7 #include <logging.h>
OlgaHoeyer 2:0864be57f81e 8 #include <rgb_led.h>
OlgaHoeyer 2:0864be57f81e 9 #include <Ticker.h>
OlgaHoeyer 0:21e9cc38dd31 10
OlgaHoeyer 0:21e9cc38dd31 11 //Declaration of GLOBAL VARIABLES:
OlgaHoeyer 0:21e9cc38dd31 12 float temperature, humidity; //this will be data read from sensor
OlgaHoeyer 3:b6c7d01e1eb8 13 void GetTemperatureAndHumidity(); //via denne function
OlgaHoeyer 2:0864be57f81e 14
OlgaHoeyer 3:b6c7d01e1eb8 15 int temperature_low=18; //DELETE LATER!
OlgaHoeyer 3:b6c7d01e1eb8 16 int temperature_high=22; //DELETE LATER!
OlgaHoeyer 1:135bd458e39e 17
OlgaHoeyer 1:135bd458e39e 18 Serial pc(USBTX, USBRX);
OlgaHoeyer 1:135bd458e39e 19 InterruptIn event(USER_BUTTON);
OlgaHoeyer 1:135bd458e39e 20 DigitalOut myled(LED1);
OlgaHoeyer 1:135bd458e39e 21 DigitalIn up(PA_5);
OlgaHoeyer 1:135bd458e39e 22 DigitalIn down(PA_6);
OlgaHoeyer 2:0864be57f81e 23 SHTx::SHT15 sensor(PB_8, PB_9); //ports on the Nucleo: PB_8, PB_9
OlgaHoeyer 1:135bd458e39e 24
OlgaHoeyer 2:0864be57f81e 25 Ticker tick1;
OlgaHoeyer 2:0864be57f81e 26 Ticker tick2;
OlgaHoeyer 2:0864be57f81e 27 Ticker tick3;
OlgaHoeyer 2:0864be57f81e 28 Ticker tick4;
OlgaHoeyer 0:21e9cc38dd31 29
OlgaHoeyer 1:135bd458e39e 30 int main()
OlgaHoeyer 1:135bd458e39e 31 {
OlgaHoeyer 2:0864be57f81e 32 while(1) {
OlgaHoeyer 2:0864be57f81e 33 logging ();
OlgaHoeyer 1:135bd458e39e 34
OlgaHoeyer 2:0864be57f81e 35 //tick1.atach(Settings(), 20); //MISSING PROGRAM PART!!!!!!!
OlgaHoeyer 2:0864be57f81e 36
OlgaHoeyer 3:b6c7d01e1eb8 37 tick2.attach(GetTemperatureAndHumidity(),20); //Data Collection
OlgaHoeyer 1:135bd458e39e 38
OlgaHoeyer 3:b6c7d01e1eb8 39 tick3.attach(Compare_values(humidity, temperature, temperature_low, temperature_high),20); //Data Analysis
OlgaHoeyer 2:0864be57f81e 40
OlgaHoeyer 3:b6c7d01e1eb8 41 tick4.attach(rgb_outp(Compare_values(humidity, temperature, temperature_low, temperature_high)),20); //RGB_LED_output
OlgaHoeyer 3:b6c7d01e1eb8 42
OlgaHoeyer 2:0864be57f81e 43 }
OlgaHoeyer 2:0864be57f81e 44 }
OlgaHoeyer 2:0864be57f81e 45
OlgaHoeyer 2:0864be57f81e 46
OlgaHoeyer 2:0864be57f81e 47 void GetTemperatureAndHumidity() //canøt move to the .h file, pga "sensor" definitions.
OlgaHoeyer 2:0864be57f81e 48 {
OlgaHoeyer 0:21e9cc38dd31 49
OlgaHoeyer 2:0864be57f81e 50 // Speed things up a bit.
OlgaHoeyer 2:0864be57f81e 51 sensor.setOTPReload(false);
OlgaHoeyer 2:0864be57f81e 52 sensor.setResolution(true);
OlgaHoeyer 2:0864be57f81e 53
OlgaHoeyer 3:b6c7d01e1eb8 54 //busy = true;
OlgaHoeyer 2:0864be57f81e 55 sensor.update();
OlgaHoeyer 3:b6c7d01e1eb8 56 //busy = false;
OlgaHoeyer 0:21e9cc38dd31 57
OlgaHoeyer 2:0864be57f81e 58 // Temperature in celcius
OlgaHoeyer 2:0864be57f81e 59 sensor.setScale(false);
OlgaHoeyer 2:0864be57f81e 60 temperature=sensor.getTemperature();
OlgaHoeyer 1:135bd458e39e 61
OlgaHoeyer 2:0864be57f81e 62 // Relative Humidity
OlgaHoeyer 2:0864be57f81e 63 humidity=sensor.getHumidity();
OlgaHoeyer 2:0864be57f81e 64
OlgaHoeyer 2:0864be57f81e 65 wait(5);
OlgaHoeyer 2:0864be57f81e 66 return;
OlgaHoeyer 2:0864be57f81e 67 }