void Calculate::reset()
{
averageSpeed = 0;
+ averagePower = 0;
+ peakPower = 0;
+ currentPower = 0;
currentSpeed = 0;
+ maxSpeed = 0;
distanceTraveled = 0;
lastAcceleration = 0;
lastDistance = 0;
// First integration of acceleration provides speed
currentSpeed = (lastSpeed + (((currentAcceleration + lastAcceleration) * seconds) / 2));
+ // Update maximum speed
+ if (currentSpeed > maxSpeed)
+ maxSpeed = currentSpeed;
+
// Second integration: distance.
distanceTraveled = (lastDistance + (((currentSpeed + lastSpeed) * seconds) / 2));
{
foreach (double speed, speedCheckPoints)
{
- if ((lastCheckpoint != floor(speed)) && (floor(currentSpeed) == floor(speed)))
+ if ((lastCheckpoint != floor(speed)) && (floor(getCurrentSpeed()) == floor(speed)))
{
- emit checkPointReached(totalTime, currentSpeed);
- lastCheckpoint = floor(currentSpeed);
+ emit checkPointReached(totalTime, getCurrentSpeed());
+ lastCheckpoint = floor(getCurrentSpeed());
}
}
}
*/
void Calculate::accelStoppedCheck(double currentAcceleration)
{
-
// counting number of acceleration samples that equals zero
if (currentAcceleration==0) {
count++;
count = 0;
}
- // if count exceeds 15, we assume that velocity is zero
- if (count >= 15)
+ // if count exceeds 25, we assume that velocity is zero
+ if (count >= 25)
{
currentSpeed=0;
}
averagePower = value;
}
+double Calculate::getMaxSpeed()
+{
+ return maxSpeed;
+}
+
+void Calculate::setMaxSpeed(double value)
+{
+ maxSpeed = value;
+}