![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
program for final combination of working pieces
Dependencies: SDFileSystem TMP102 mbed ISL29125
Fork of TEMP_Test by
main.cpp@12:7ed53be0057a, 2016-04-07 (annotated)
- Committer:
- tdale19
- Date:
- Thu Apr 07 15:46:20 2016 +0000
- Revision:
- 12:7ed53be0057a
- Parent:
- 11:cc9b7a7ce7cf
- Child:
- 13:906a647d7bd1
Extended Timer
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tdale19 | 6:61b76e7dc5b7 | 1 | //Authors: Tom, Nathan, Jeriah |
Jeriah | 0:547856de255b | 2 | #include "mbed.h" |
tdale19 | 4:4b67d7667474 | 3 | #include "TEMPSensor.h" |
Jeriah | 0:547856de255b | 4 | #include "SDFileSystem.h" |
Jeriah | 0:547856de255b | 5 | #include "SDSave.h" |
tdale19 | 7:6becc29457ce | 6 | #include "SolarPanel.h" |
tdale19 | 8:28f8162d2929 | 7 | #include "UVSensor.h" |
tdale19 | 9:9690da23e8d7 | 8 | #include "RGBSensor.h" |
tdale19 | 4:4b67d7667474 | 9 | |
Jeriah | 0:547856de255b | 10 | Timer t; |
Jeriah | 2:04c2f253ec87 | 11 | DigitalOut ledBlue(LED_BLUE); |
Jeriah | 2:04c2f253ec87 | 12 | DigitalOut ledRed(LED_RED); |
Jeriah | 2:04c2f253ec87 | 13 | Serial pc(USBTX,USBRX); |
Jeriah | 0:547856de255b | 14 | |
Jeriah | 0:547856de255b | 15 | int main() {//main function, calls other files to move temp,RGB,PV,UV all to one managable function |
Jeriah | 0:547856de255b | 16 | float lastTime = 0; |
Jeriah | 0:547856de255b | 17 | float interval = 0.5; |
tdale19 | 12:7ed53be0057a | 18 | int halfHour = 0; |
Jeriah | 2:04c2f253ec87 | 19 | ledRed = 0; |
Jeriah | 2:04c2f253ec87 | 20 | ledBlue = 1; |
Jeriah | 2:04c2f253ec87 | 21 | wait(0.5); |
Jeriah | 0:547856de255b | 22 | t.start(); |
Jeriah | 2:04c2f253ec87 | 23 | pc.printf("The timer has started\n\r"); |
Jeriah | 2:04c2f253ec87 | 24 | if (mountSDCard()) { |
Jeriah | 0:547856de255b | 25 | return -1; //end program with error status |
Jeriah | 0:547856de255b | 26 | } |
Jeriah | 2:04c2f253ec87 | 27 | pc.printf("The SD card is mounted\n\r"); |
tdale19 | 9:9690da23e8d7 | 28 | |
tdale19 | 9:9690da23e8d7 | 29 | uint16_t rgb[3]; |
Jeriah | 2:04c2f253ec87 | 30 | ledRed = 1; |
tdale19 | 9:9690da23e8d7 | 31 | createDataFile(); |
tdale19 | 12:7ed53be0057a | 32 | while (halfHour < 7) { |
tdale19 | 12:7ed53be0057a | 33 | if (t.read() >= 1800){ |
tdale19 | 12:7ed53be0057a | 34 | t.start(); |
tdale19 | 12:7ed53be0057a | 35 | halfHour++; |
tdale19 | 12:7ed53be0057a | 36 | } |
tdale19 | 12:7ed53be0057a | 37 | float totalTime = halfHour * 30 * 60 + t.read(); |
tdale19 | 12:7ed53be0057a | 38 | if (totalTime>(lastTime+interval)) { |
tdale19 | 12:7ed53be0057a | 39 | lastTime=totalTime; |
tdale19 | 11:cc9b7a7ce7cf | 40 | get_rgb(rgb); |
tdale19 | 11:cc9b7a7ce7cf | 41 | pc.printf("temp ouside = %.2f (c) inside = %.2f (c) on panel = %.2f (c) solar volage = %.2f (V) UV light =%.4f RGB Values: red = %d green = %d blue = %d\r\n" ,get_outsideTemp(),get_insideTemp(),get_panelTemp(),get_solar(),(get_UV()),rgb[0],rgb[1],rgb[2]);//prints titles and data of Temp readings |
tdale19 | 9:9690da23e8d7 | 42 | writeData(lastTime,get_outsideTemp(),get_insideTemp(),get_panelTemp(),get_solar(),get_UV(),rgb[0],rgb[1],rgb[2]);//send data to writeData in SDsave.cpp |
tdale19 | 8:28f8162d2929 | 43 | |
Jeriah | 0:547856de255b | 44 | } |
Jeriah | 0:547856de255b | 45 | } |
Jeriah | 0:547856de255b | 46 | closeDataFile(); |
Jeriah | 2:04c2f253ec87 | 47 | ledBlue = 0; |
Jeriah | 2:04c2f253ec87 | 48 | while (true) {}; |
Jeriah | 0:547856de255b | 49 | } |
Jeriah | 0:547856de255b | 50 |