![](/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@3:8ace1992bc93, 2016-03-12 (annotated)
- Committer:
- Jeriah
- Date:
- Sat Mar 12 01:42:13 2016 +0000
- Revision:
- 3:8ace1992bc93
- Parent:
- 2:04c2f253ec87
- Child:
- 4:4b67d7667474
Final working RGB_test program
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jeriah | 0:547856de255b | 1 | //Authors: Tom, Nathan, Jeriah |
Jeriah | 0:547856de255b | 2 | #include "mbed.h" |
Jeriah | 0:547856de255b | 3 | #include "RGBSensor.h" |
Jeriah | 0:547856de255b | 4 | #include "SDFileSystem.h" |
Jeriah | 0:547856de255b | 5 | #include "SDSave.h" |
Jeriah | 0:547856de255b | 6 | |
Jeriah | 1:e0fc716e2394 | 7 | |
Jeriah | 0:547856de255b | 8 | Timer t; |
Jeriah | 2:04c2f253ec87 | 9 | DigitalOut ledBlue(LED_BLUE); |
Jeriah | 2:04c2f253ec87 | 10 | DigitalOut ledRed(LED_RED); |
Jeriah | 2:04c2f253ec87 | 11 | Serial pc(USBTX,USBRX); |
Jeriah | 0:547856de255b | 12 | |
Jeriah | 0:547856de255b | 13 | int main() {//main function, calls other files to move temp,RGB,PV,UV all to one managable function |
Jeriah | 0:547856de255b | 14 | float lastTime = 0; |
Jeriah | 0:547856de255b | 15 | float interval = 0.5; |
Jeriah | 2:04c2f253ec87 | 16 | ledRed = 0; |
Jeriah | 2:04c2f253ec87 | 17 | ledBlue = 1; |
Jeriah | 2:04c2f253ec87 | 18 | wait(0.5); |
Jeriah | 2:04c2f253ec87 | 19 | RGB_init(); |
Jeriah | 0:547856de255b | 20 | t.start(); |
Jeriah | 2:04c2f253ec87 | 21 | pc.printf("The timer has started\n\r"); |
Jeriah | 2:04c2f253ec87 | 22 | if (mountSDCard()) { |
Jeriah | 0:547856de255b | 23 | return -1; //end program with error status |
Jeriah | 0:547856de255b | 24 | } |
Jeriah | 2:04c2f253ec87 | 25 | pc.printf("The SD card is mounted\n\r"); |
Jeriah | 2:04c2f253ec87 | 26 | createDataFile_testRGB(); |
Jeriah | 0:547856de255b | 27 | uint16_t rgb[3]; |
Jeriah | 2:04c2f253ec87 | 28 | ledRed = 1; |
Jeriah | 2:04c2f253ec87 | 29 | while (t.read()<60) { |
Jeriah | 2:04c2f253ec87 | 30 | if (t.read()>(lastTime+interval)) { |
Jeriah | 0:547856de255b | 31 | lastTime=t.read(); |
Jeriah | 0:547856de255b | 32 | get_rgb(rgb); |
Jeriah | 3:8ace1992bc93 | 33 | pc.printf("t = %.2f \t red = %d \t green = %d\t blue = %d\r\n",lastTime,rgb[0],rgb[1]); |
Jeriah | 1:e0fc716e2394 | 34 | writeData_testRGB(lastTime,rgb[0],rgb[1],rgb[2]);//send data to writeData in SDsave.cpp |
Jeriah | 0:547856de255b | 35 | //we will get all rgb readings through an array, with the corresponding integers going in order red, green, blue |
Jeriah | 0:547856de255b | 36 | } |
Jeriah | 0:547856de255b | 37 | } |
Jeriah | 0:547856de255b | 38 | closeDataFile(); |
Jeriah | 2:04c2f253ec87 | 39 | ledBlue = 0; |
Jeriah | 2:04c2f253ec87 | 40 | while (true) {}; |
Jeriah | 0:547856de255b | 41 | } |
Jeriah | 0:547856de255b | 42 |