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.
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; }