From 1b1fe432383aaf5dc7f648bbff80e017ab5e291d Mon Sep 17 00:00:00 2001 From: Andrew Bryson Date: Thu, 5 Jan 2012 18:55:14 +0000 Subject: [PATCH] Reset the lap timer based on erg file Resets the lap timer when we get to a new lap in a training plan. Previously it would only reset when the user pressed lap fixes Bug #576 --- src/TrainTool.cpp | 18 +++++++++++++++--- src/TrainTool.h | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/TrainTool.cpp b/src/TrainTool.cpp index e904f36cb..f50e0c24c 100644 --- a/src/TrainTool.cpp +++ b/src/TrainTool.cpp @@ -222,6 +222,7 @@ TrainTool::TrainTool(MainWindow *parent, const QDir &home) : GcWindow(parent), h connect(forward, SIGNAL(clicked()), this, SLOT(FFwd())); connect(rewind, SIGNAL(clicked()), this, SLOT(Rewind())); connect(lap, SIGNAL(clicked()), this, SLOT(newLap())); + connect(main, SIGNAL(newLap()), this, SLOT(resetLapTimer())); connect(intensitySlider, SIGNAL(valueChanged(int)), this, SLOT(adjustIntensity())); // not used but kept in case re-instated in the future @@ -1036,13 +1037,16 @@ void TrainTool::newLap() hrcount = 0; spdcount = 0; - lap_time.restart(); - lap_elapsed_msec = 0; - main->notifyNewLap(); } } +void TrainTool::resetLapTimer() +{ + lap_time.restart(); + lap_elapsed_msec = 0; +} + // can be called from the controller void TrainTool::nextDisplayMode() { @@ -1148,6 +1152,10 @@ void TrainTool::loadUpdate() if (status&RT_MODE_ERGO) { load = ergFile->wattsAt(load_msecs, curLap); + if(displayWorkoutLap != curLap) + { + resetLapTimer(); + } displayWorkoutLap = curLap; // we got to the end! @@ -1160,6 +1168,10 @@ void TrainTool::loadUpdate() } else { slope = ergFile->gradientAt(displayWorkoutDistance*1000, curLap); + if(displayWorkoutLap != curLap) + { + resetLapTimer(); + } displayWorkoutLap = curLap; // we got to the end! diff --git a/src/TrainTool.h b/src/TrainTool.h index 3aae9fd70..ab5478382 100644 --- a/src/TrainTool.h +++ b/src/TrainTool.h @@ -144,6 +144,7 @@ class TrainTool : public GcWindow void Higher(); // set load/gradient higher void Lower(); // set load/gradient higher void newLap(); // start new Lap! + void resetLapTimer(); //reset the lap timer // Timed actions void guiUpdate(); // refreshes the telemetry