Skip to content

Commit 66e4300

Browse files
authored
Merge pull request #102 from jniebuhr/feature/fix-grind-prediction
fix: Fix grind predictive scales
2 parents b64a5d5 + b922505 commit 66e4300

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/display/core/Process.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <numeric>
77

88
constexpr int PREDICTIVE_MEASUREMENTS = 30; // 3s
9-
constexpr int PREDICTIVE_TIME_MS = 1000;
9+
constexpr double PREDICTIVE_TIME_MS = 1000.0;
1010

1111
class Process {
1212
public:
@@ -230,8 +230,11 @@ class GrindProcess : public Process {
230230
}
231231

232232
double volumePerSecond() const {
233-
double sum = std::accumulate(measurements.begin(), measurements.end(), 0);
234-
return sum / measurements.size() * (1000.0 / PROGRESS_INTERVAL);
233+
double sum = 0.0;
234+
for (const auto n : measurements) {
235+
sum += n;
236+
}
237+
return sum / static_cast<double>(measurements.size()) * (1000.0 / static_cast<double>(PROGRESS_INTERVAL));
235238
}
236239

237240
void updateVolume(double volume) override { currentVolume = volume; };

0 commit comments

Comments
 (0)