tortuga DataLogging Library: battery, speed, time, average...
Fork of DataLogging by
Data.cpp
- Committer:
- ptuytsch
- Date:
- 2016-07-12
- Revision:
- 3:610ace66d7af
- Parent:
- 2:f3c2bf5521e5
File content as of revision 3:610ace66d7af:
#include "mbed.h" #include "Data.h" //CONSTRUCTOR Data::Data(float startDistance, uint32_t startTime, uint8_t ppr, float Periphery) : //setting start values up StartTime(time(NULL)-startTime), distance(startDistance), PPR(ppr), periphery(Periphery) { } void Data::interval(int count){ //log each interval and update the status distance += count * periphery / PPR; //debugging //printf("distance: %f \r\nTime Passed: %i:%i:%i\nAverage: %f\n\n",distance,(time(NULL) - StartTime)/3600, ((time(NULL) - StartTime)/60)%60, (time(NULL) - StartTime)%60, (distance/(time(NULL) - StartTime) * 3.6)); } float Data::getDistance(void){ return distance; } uint32_t Data::getTime(void){ return (time(NULL) - StartTime); } float Data::getAverage(void){ return distance/(time(NULL) - StartTime) * 3.6; }