02/07/15
Dependencies: mbed
Data.cpp@71:60f06e7e50a3, 2015-09-03 (annotated)
- Committer:
- aidanPJG
- Date:
- Thu Sep 03 15:32:01 2015 +0000
- Revision:
- 71:60f06e7e50a3
- Parent:
- 70:168d67695a65
tried to add date but it failed;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ADAMSTRUTT | 35:085a674c9fdf | 1 | #include "mbed.h" |
aidanPJG | 71:60f06e7e50a3 | 2 | #include <string> |
ADAMSTRUTT | 35:085a674c9fdf | 3 | |
ADAMSTRUTT | 35:085a674c9fdf | 4 | LocalFileSystem local("local"); |
aidanPJG | 64:809bd19f4e7c | 5 | extern Serial pc; |
ADAMSTRUTT | 35:085a674c9fdf | 6 | |
aidanPJG | 71:60f06e7e50a3 | 7 | void initialise(int counter, string date ) |
aidanPJG | 43:8e154016dd89 | 8 | { |
aidanPJG | 70:168d67695a65 | 9 | FILE *fp1 = fopen("/local/Datalog.xls", "a"); // opens or creates fill Datalog, |
aidanPJG | 71:60f06e7e50a3 | 10 | fprintf(fp1, " Test %d \n %s \n", counter, date); //gives header |
aidanPJG | 70:168d67695a65 | 11 | fprintf(fp1, " Sensor \t Total Time \t Time Diff \t Inst Speed \t Avg Speed\n"); //writes field names |
aidanPJG | 70:168d67695a65 | 12 | fclose(fp1); //closes the file so it can be opened by another method |
aidanPJG | 43:8e154016dd89 | 13 | } |
aidanPJG | 43:8e154016dd89 | 14 | |
aidanPJG | 64:809bd19f4e7c | 15 | void data(int sensor_number, double time, double speed, double timesTotal,double speedAvg) |
aidanPJG | 43:8e154016dd89 | 16 | { |
aidanPJG | 70:168d67695a65 | 17 | FILE *fp = fopen("/local/Datalog.xls", "a"); // Open "Datalog |
aidanPJG | 70:168d67695a65 | 18 | fprintf(fp, " %d \t %lf \t %lf \t %lf \t %lf \n",sensor_number + 1, timesTotal ,time, speed, speedAvg); //fills the tables with the results. sensorNumber +1 because sensor starts at 0. |
aidanPJG | 70:168d67695a65 | 19 | fclose(fp); //close |
aidanPJG | 45:eb06f1d42938 | 20 | } |
aidanPJG | 45:eb06f1d42938 | 21 | |
aidanPJG | 70:168d67695a65 | 22 | //*********This has not been done yet, but it would be nice to have an average speed for each bend******** |
aidanPJG | 45:eb06f1d42938 | 23 | void averageData() //adds average data fom b2 to b6 |
aidanPJG | 45:eb06f1d42938 | 24 | { |
aidanPJG | 45:eb06f1d42938 | 25 | FILE *fp2 = fopen("/local/Datalog.xls", "a"); |
aidanPJG | 47:1dc3b5f7bf4a | 26 | fprintf(fp2, " Average \t=SUM(B2:B4) / 5 \n"); |
aidanPJG | 45:eb06f1d42938 | 27 | fclose(fp2); |
ADAMSTRUTT | 35:085a674c9fdf | 28 | } |