![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
02/07/15
Dependencies: mbed
Diff: Calculate.cpp
- Revision:
- 32:792c4239a738
- Parent:
- 31:bea1117f14fb
- Child:
- 33:929f1755664b
diff -r bea1117f14fb -r 792c4239a738 Calculate.cpp --- a/Calculate.cpp Wed Jul 08 07:55:13 2015 +0000 +++ b/Calculate.cpp Wed Jul 08 08:13:10 2015 +0000 @@ -11,7 +11,7 @@ //c++ variables time_t sensor_time ; //time at which sensor is broken - double timeDifference; //time between 2 sensors - not used right now + int timeDiff; //time between 2 sensors - not used right now int times[6]; //array the size of #pins int calculate() @@ -29,14 +29,20 @@ } //error checking incase next one is done } sensor_time = time(NULL); - pc.printf(" %dth sensor %d : \t", i,sensor_time); + pc.printf(" %dth sensor: %d \t", i,sensor_time); times[i] = sensor_time; //adds sensor times to array for logging. + if ( i > 0) { //to ensure it is not the first one + // pc.printf(" time[i] : %d \t", times[i]); //testing + // pc.printf(" time[i -1] : %d \t", times[i -1 ]); //testing + timeDiff = difftime(times[i], times[i-1]); + pc.printf(" timediff: %d \t", timeDiff); + } i++; } - pc.printf("Calculate completed"); //alert to let user know it completed - for (int i = 6 - 1; i >= 0; i--) //printing module for array + pc.printf(" \n Calculate completed \n"); //alert to let user know it completed + for (int i = 0; i < 5 ; i++) //printing module for array { - pc.printf(" times %d : \t", times[i]); + pc.printf(" times: %d \t", times[i]); } }