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.
Diff: Calculate.cpp
- Revision:
- 0:efdae9d24ee1
diff -r 000000000000 -r efdae9d24ee1 Calculate.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Calculate.cpp Wed Jul 22 13:12:14 2015 +0000 @@ -0,0 +1,74 @@ +//#include "mbed.h" +//#include <time.h> +//#include <string> +//#include <iostream> +//#include "Distance.h" +// +//void printArray(double array[20], int timesArray[20], int NoOfPins); +//void data(int sensor_number, int time, double speed); +// +// //mbed pins +//extern Serial pc; +//DigitalIn sensor[20] = {p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23,p24};//array of sensors. +// +// +////c++ variables +//time_t sensor_time ; //time at which sensor is broken +//int timeDiff; //time between 2 sensors +//float speed; +//int times[20]; //array the size of #pins +//double speeds[20]; //array of speeds +// +// +////Speed Calculations +//int calculate(double distance, int noOfPins) +//{ +// +// pc.printf("new program \n"); //alert user of initialisation +// +// int i = 0, i1 = 0; +// +// while( i < noOfPins) +// { +// while(!sensor[i]) +// { +// if(sensor[i + 1]) { //checks if there is an error in the first sensor +// sensor_time = time(NULL); +// pc.printf ("Error with sensor: %d", i); +// i++; +// } +// if(sensor[i + 2]) { //checks if there is an error in the second sensor after +// sensor_time = time(NULL); +// pc.printf ("Error with sensors: %d, %d", i,i1 = i + 1); +// i = i + 2; +// } +// } +// sensor_time = time(NULL); //gets current time +// pc.printf("\n sensor %d : %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 +// timeDiff = difftime(times[i], times[i-1]); //calculates the time difference +// pc.printf(" timediff: %d s \t", timeDiff); +// speed = distance / timeDiff; +// pc.printf(" speed : %f m/s ", speed); +// speeds[i] = speed; +// } +// i++; +// } +// pc.printf(" \n Calculate completed \n"); //alert to let user know it completed +// printArray(speeds, times, noOfPins); +// +//} +// +//void printArray(double array[23], int timesArray[23], int noOfPins) +// { +// for (int i = 0; i < noOfPins ; i++) //printing module for array +// { +// 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 < noOfPins ; i++) //printing to Datalog +// { +// data( i,times[i],speeds[i]); +// } +// +// }