Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of PRO2_samlet_kode by
Settings.cpp@11:3ff48fb0aa0b, 2017-06-20 (annotated)
- Committer:
- OlgaHoeyer
- Date:
- Tue Jun 20 12:18:09 2017 +0000
- Revision:
- 11:3ff48fb0aa0b
- Parent:
- 9:de77a6f5ba43
with pointers
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
OlgaHoeyer | 6:12f1849aad21 | 1 | /* |
OlgaHoeyer | 6:12f1849aad21 | 2 | ------------------------------------------------------------------------------- |
OlgaHoeyer | 6:12f1849aad21 | 3 | -- Project: PRO2 "Awareness and Optimisation of energy consumption" |
OlgaHoeyer | 6:12f1849aad21 | 4 | -- Team: Team 1 |
OlgaHoeyer | 6:12f1849aad21 | 5 | |
OlgaHoeyer | 6:12f1849aad21 | 6 | -- File Name: Settings.cpp |
OlgaHoeyer | 6:12f1849aad21 | 7 | -- Author: Emil Hammer |
OlgaHoeyer | 6:12f1849aad21 | 8 | -- Date: 19/05-2017 |
OlgaHoeyer | 6:12f1849aad21 | 9 | -- Copyright: Open to all |
OlgaHoeyer | 6:12f1849aad21 | 10 | -- Version: 1.0 - Creation of file. |
OlgaHoeyer | 6:12f1849aad21 | 11 | -- |
OlgaHoeyer | 6:12f1849aad21 | 12 | -- Description: Settings |
OlgaHoeyer | 6:12f1849aad21 | 13 | -- |
OlgaHoeyer | 6:12f1849aad21 | 14 | ------------------------------------------------------------------------------- |
OlgaHoeyer | 6:12f1849aad21 | 15 | */ |
OlgaHoeyer | 5:b366110c0d59 | 16 | |
OlgaHoeyer | 5:b366110c0d59 | 17 | #include "mbed.h" |
OlgaHoeyer | 5:b366110c0d59 | 18 | |
OlgaHoeyer | 5:b366110c0d59 | 19 | DigitalOut myled(LED1); |
OlgaHoeyer | 5:b366110c0d59 | 20 | DigitalIn up(p5); |
OlgaHoeyer | 5:b366110c0d59 | 21 | DigitalIn down(p6); |
OlgaHoeyer | 5:b366110c0d59 | 22 | |
OlgaHoeyer | 5:b366110c0d59 | 23 | |
OlgaHoeyer | 5:b366110c0d59 | 24 | extern int timespan; |
OlgaHoeyer | 5:b366110c0d59 | 25 | int t; |
OlgaHoeyer | 5:b366110c0d59 | 26 | int i, set_temp; |
OlgaHoeyer | 11:3ff48fb0aa0b | 27 | //int temperature_low,temperature_high; |
OlgaHoeyer | 5:b366110c0d59 | 28 | |
OlgaHoeyer | 11:3ff48fb0aa0b | 29 | void Settings(int *temperature_low, int *temperature_high) |
OlgaHoeyer | 5:b366110c0d59 | 30 | { |
OlgaHoeyer | 5:b366110c0d59 | 31 | while(i<1) { //Open set_temp for user input. |
OlgaHoeyer | 5:b366110c0d59 | 32 | |
OlgaHoeyer | 5:b366110c0d59 | 33 | if (up==1) {//recieve input from user |
OlgaHoeyer | 5:b366110c0d59 | 34 | set_temp = (set_temp +1); |
OlgaHoeyer | 5:b366110c0d59 | 35 | } // when "up" tricked set_temp raise 1 |
OlgaHoeyer | 5:b366110c0d59 | 36 | if (down==1) { |
OlgaHoeyer | 5:b366110c0d59 | 37 | set_temp = (set_temp -1); |
OlgaHoeyer | 5:b366110c0d59 | 38 | } // when "down" tricked set_temp raise 1 |
OlgaHoeyer | 5:b366110c0d59 | 39 | else if (timespan == 500); |
OlgaHoeyer | 5:b366110c0d59 | 40 | { |
OlgaHoeyer | 5:b366110c0d59 | 41 | /* if 500 ms passes without a user input |
OlgaHoeyer | 5:b366110c0d59 | 42 | the program will break the loop*/ |
OlgaHoeyer | 5:b366110c0d59 | 43 | break; |
OlgaHoeyer | 5:b366110c0d59 | 44 | } |
OlgaHoeyer | 5:b366110c0d59 | 45 | } |
OlgaHoeyer | 5:b366110c0d59 | 46 | |
OlgaHoeyer | 11:3ff48fb0aa0b | 47 | *temperature_low = (set_temp-3); |
OlgaHoeyer | 11:3ff48fb0aa0b | 48 | *temperature_high = (set_temp+3); |
OlgaHoeyer | 5:b366110c0d59 | 49 | /* Temperature that defines what uncomfortable */ |
OlgaHoeyer | 5:b366110c0d59 | 50 | |
OlgaHoeyer | 5:b366110c0d59 | 51 | |
OlgaHoeyer | 5:b366110c0d59 | 52 | i=2; |
OlgaHoeyer | 5:b366110c0d59 | 53 | t=700; //force the program to pass hibernation. |
OlgaHoeyer | 5:b366110c0d59 | 54 | return 0; |
OlgaHoeyer | 5:b366110c0d59 | 55 | } |