![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
02/07/15
Dependencies: mbed
Diff: Calculate.cpp
- Revision:
- 50:d794595c6868
- Parent:
- 47:1dc3b5f7bf4a
- Child:
- 51:210353276e06
--- a/Calculate.cpp Wed Jul 15 13:52:20 2015 +0000 +++ b/Calculate.cpp Wed Jul 15 15:16:03 2015 +0000 @@ -4,7 +4,7 @@ #include <iostream> #include "Distance.h" -void printArray(int array[3]); +void printArray(double array[3], int timesArray[3]); void data(int sensor_number, int speed); //mbed pins @@ -18,8 +18,8 @@ int timeDiff; //time between 2 sensors - not used right now float speed; int times[3]; //array the size of #pins - double speeds[6]; //array of speeds -int calculate(float distance) + double speeds[3]; //array of speeds +int calculate(double distance) { pc.printf("new program \n"); //alert user of initialisation @@ -46,20 +46,21 @@ i++; } pc.printf(" \n Calculate completed \n"); //alert to let user know it completed - printArray(times); - //printArray(speeds); + // printArray(times); + printArray(speeds, times); } -void printArray(int array[3]) +void printArray(double array[3], int timesArray[3]) { for (int i = 0; i < 3 ; i++) //printing module for array { - pc.printf(" %d : %d \t", i,times[i]); + pc.printf(" Sensor : %d Time %d Speed %f \n", i,times[i],speeds[i]); + // pc.printf(" %d : %d \t", i,times[i]); } for (int i = 0; i < 3 ; i++) //printing to Datalog { - data( i,times[i]); + data( i,speeds[i]); } }