From abb69b8fb5660d39147c16cd29c92ca2a1e0ed69 Mon Sep 17 00:00:00 2001 From: Alejandro Martinez Date: Wed, 11 Jan 2023 19:40:29 -0300 Subject: [PATCH] DialWindow - Fix rolling average initialization Reported in #4298 --- src/Train/DialWindow.cpp | 6 ++++-- src/Train/NullController.cpp | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Train/DialWindow.cpp b/src/Train/DialWindow.cpp index 166ec0c72..066978d60 100644 --- a/src/Train/DialWindow.cpp +++ b/src/Train/DialWindow.cpp @@ -149,8 +149,10 @@ DialWindow::telemetryUpdate(const RealtimeData &rtData) series == RealtimeData::Cadence) { sum += value; - int j = index-(count=0?j:150+j)]; + if (count >= average*5) { + int j = index - average*5; + sum -= rolling[(j>=0?j:150+j)]; + } //store value rolling[index] = value; diff --git a/src/Train/NullController.cpp b/src/Train/NullController.cpp index b27ed9ea2..353e528de 100644 --- a/src/Train/NullController.cpp +++ b/src/Train/NullController.cpp @@ -63,6 +63,7 @@ void NullController::getRealtimeData(RealtimeData &rtData) { rtData.setName((char *)"Null"); rtData.setWatts(load + ((rand()%25)-15)); // for testing virtual power rtData.setLoad(load); + rtData.setLRBalance(50 + ((rand()%20)-10)); // for testing LRBalance widget // Compute speed from principles and randomized power instead of randomizing it independantly. // This makes it easier to eyeball rlv behavior and test gpx tools using rides generated by