PRO2_Team 1_collected code with ticker and headers_not working yet
Fork of PRO2_samlet_kode by
Settings.cpp@5:b366110c0d59, 2017-05-24 (annotated)
- Committer:
- OlgaHoeyer
- Date:
- Wed May 24 09:34:54 2017 +0000
- Revision:
- 5:b366110c0d59
- Child:
- 6:12f1849aad21
included settings og logging, rettet tickers syntax, not working yet.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
OlgaHoeyer | 5:b366110c0d59 | 1 | //Author : Emil Hammer |
OlgaHoeyer | 5:b366110c0d59 | 2 | //Date : 19 May 2017 |
OlgaHoeyer | 5:b366110c0d59 | 3 | //Version : 1.0 |
OlgaHoeyer | 5:b366110c0d59 | 4 | //Copyright : Open for everyone |
OlgaHoeyer | 5:b366110c0d59 | 5 | //Description : Settings |
OlgaHoeyer | 5:b366110c0d59 | 6 | |
OlgaHoeyer | 5:b366110c0d59 | 7 | #include "mbed.h" |
OlgaHoeyer | 5:b366110c0d59 | 8 | |
OlgaHoeyer | 5:b366110c0d59 | 9 | DigitalOut myled(LED1); |
OlgaHoeyer | 5:b366110c0d59 | 10 | DigitalIn up(p5); |
OlgaHoeyer | 5:b366110c0d59 | 11 | DigitalIn down(p6); |
OlgaHoeyer | 5:b366110c0d59 | 12 | |
OlgaHoeyer | 5:b366110c0d59 | 13 | |
OlgaHoeyer | 5:b366110c0d59 | 14 | extern int timespan; |
OlgaHoeyer | 5:b366110c0d59 | 15 | int t; |
OlgaHoeyer | 5:b366110c0d59 | 16 | int i, set_temp; |
OlgaHoeyer | 5:b366110c0d59 | 17 | int temperature_low,temperature_high; |
OlgaHoeyer | 5:b366110c0d59 | 18 | |
OlgaHoeyer | 5:b366110c0d59 | 19 | int main() |
OlgaHoeyer | 5:b366110c0d59 | 20 | { |
OlgaHoeyer | 5:b366110c0d59 | 21 | while(i<1) { //Open set_temp for user input. |
OlgaHoeyer | 5:b366110c0d59 | 22 | |
OlgaHoeyer | 5:b366110c0d59 | 23 | if (up==1) {//recieve input from user |
OlgaHoeyer | 5:b366110c0d59 | 24 | set_temp = (set_temp +1); |
OlgaHoeyer | 5:b366110c0d59 | 25 | } // when "up" tricked set_temp raise 1 |
OlgaHoeyer | 5:b366110c0d59 | 26 | if (down==1) { |
OlgaHoeyer | 5:b366110c0d59 | 27 | set_temp = (set_temp -1); |
OlgaHoeyer | 5:b366110c0d59 | 28 | } // when "down" tricked set_temp raise 1 |
OlgaHoeyer | 5:b366110c0d59 | 29 | else if (timespan == 500); |
OlgaHoeyer | 5:b366110c0d59 | 30 | { |
OlgaHoeyer | 5:b366110c0d59 | 31 | /* if 500 ms passes without a user input |
OlgaHoeyer | 5:b366110c0d59 | 32 | the program will break the loop*/ |
OlgaHoeyer | 5:b366110c0d59 | 33 | break; |
OlgaHoeyer | 5:b366110c0d59 | 34 | } |
OlgaHoeyer | 5:b366110c0d59 | 35 | } |
OlgaHoeyer | 5:b366110c0d59 | 36 | |
OlgaHoeyer | 5:b366110c0d59 | 37 | int temperature_low = (set_temp-5); |
OlgaHoeyer | 5:b366110c0d59 | 38 | int temperature_high = (set_temp+5); |
OlgaHoeyer | 5:b366110c0d59 | 39 | /* Temperature that defines what uncomfortable */ |
OlgaHoeyer | 5:b366110c0d59 | 40 | |
OlgaHoeyer | 5:b366110c0d59 | 41 | |
OlgaHoeyer | 5:b366110c0d59 | 42 | i=2; |
OlgaHoeyer | 5:b366110c0d59 | 43 | t=700; //force the program to pass hibernation. |
OlgaHoeyer | 5:b366110c0d59 | 44 | return 0; |
OlgaHoeyer | 5:b366110c0d59 | 45 | } |