PRO2_Team 1_collected code with ticker_not working yet
Fork of PRO2_samlet_kode by
main.cpp@2:0864be57f81e, 2017-05-19 (annotated)
- Committer:
- OlgaHoeyer
- Date:
- Fri May 19 10:59:26 2017 +0000
- Revision:
- 2:0864be57f81e
- Parent:
- 1:135bd458e39e
- Child:
- 3:b6c7d01e1eb8
get_temp modul changed, Ticker added_not working yet
Who changed what in which revision?
User | Revision | Line number | New 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 | 2:0864be57f81e | 13 | void GetTemperatureAndHumidity(); //via denne function |
OlgaHoeyer | 2:0864be57f81e | 14 | |
OlgaHoeyer | 2:0864be57f81e | 15 | int temperature_low :=18; |
OlgaHoeyer | 2:0864be57f81e | 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 | 2:0864be57f81e | 37 | tick2.atach(GetTemperatureAndHumidity(),20); //Data Collection |
OlgaHoeyer | 2:0864be57f81e | 38 | |
OlgaHoeyer | 2:0864be57f81e | 39 | //tick3.atach(Compare_values(hum, temp, temperature_low, temperature_high),20); //Data Analysis |
OlgaHoeyer | 1:135bd458e39e | 40 | |
OlgaHoeyer | 2:0864be57f81e | 41 | tick4.atach(rgb_outp(Compare_values(hum, temp, temperature_low, temperature_high)),20); //RGB_LED_output |
OlgaHoeyer | 2:0864be57f81e | 42 | |
OlgaHoeyer | 2:0864be57f81e | 43 | return; |
OlgaHoeyer | 2:0864be57f81e | 44 | } |
OlgaHoeyer | 2:0864be57f81e | 45 | } |
OlgaHoeyer | 2:0864be57f81e | 46 | |
OlgaHoeyer | 2:0864be57f81e | 47 | |
OlgaHoeyer | 2:0864be57f81e | 48 | void GetTemperatureAndHumidity() //canøt move to the .h file, pga "sensor" definitions. |
OlgaHoeyer | 2:0864be57f81e | 49 | { |
OlgaHoeyer | 0:21e9cc38dd31 | 50 | |
OlgaHoeyer | 2:0864be57f81e | 51 | // Speed things up a bit. |
OlgaHoeyer | 2:0864be57f81e | 52 | sensor.setOTPReload(false); |
OlgaHoeyer | 2:0864be57f81e | 53 | sensor.setResolution(true); |
OlgaHoeyer | 2:0864be57f81e | 54 | |
OlgaHoeyer | 2:0864be57f81e | 55 | busy = true; |
OlgaHoeyer | 2:0864be57f81e | 56 | sensor.update(); |
OlgaHoeyer | 2:0864be57f81e | 57 | busy = false; |
OlgaHoeyer | 0:21e9cc38dd31 | 58 | |
OlgaHoeyer | 2:0864be57f81e | 59 | // Temperature in celcius |
OlgaHoeyer | 2:0864be57f81e | 60 | sensor.setScale(false); |
OlgaHoeyer | 2:0864be57f81e | 61 | temperature=sensor.getTemperature(); |
OlgaHoeyer | 1:135bd458e39e | 62 | |
OlgaHoeyer | 2:0864be57f81e | 63 | // Relative Humidity |
OlgaHoeyer | 2:0864be57f81e | 64 | humidity=sensor.getHumidity(); |
OlgaHoeyer | 2:0864be57f81e | 65 | |
OlgaHoeyer | 2:0864be57f81e | 66 | wait(5); |
OlgaHoeyer | 2:0864be57f81e | 67 | return; |
OlgaHoeyer | 2:0864be57f81e | 68 | } |