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: TripDataReader.cpp
- Revision:
- 6:4a25f3b9caef
- Parent:
- 5:ded8fe5991a2
--- a/TripDataReader.cpp Tue Sep 05 15:00:17 2017 +0000
+++ b/TripDataReader.cpp Fri Sep 08 07:35:33 2017 +0000
@@ -130,9 +130,9 @@
uint8_t obdData[16];
TripData d;
- d.averageSpeed = (float)tripDataHistory.speed*0.62137119f/(float)tripDataHistory.speedSamples;
+ d.averageSpeed = tripDataHistory.speedSamples ? (float)tripDataHistory.speed*0.62137119f/(float)tripDataHistory.speedSamples : 0;
d.minimumThrottle = (float)tripDataHistory.minT*0.39215686f;
- d.averageThrottle = (float)tripDataHistory.avgT*0.39215686f/(float)tripDataHistory.throttleSamples;
+ d.averageThrottle = tripDataHistory.throttleSamples ? (float)tripDataHistory.avgT*0.39215686f/(float)tripDataHistory.throttleSamples : 0;
d.maximumThrottle = (float)tripDataHistory.maxT*0.39215686f;
d.hardBrakeCount = tripDataHistory.hardBrakeCount;