diff options
author | Arseniy-Movshev <dodoradio@outlook.com> | 2023-07-12 12:31:33 +0100 |
---|---|---|
committer | Arseniy-Movshev <dodoradio@outlook.com> | 2023-07-12 17:13:50 +0100 |
commit | 640efc352c6540db9e00f4124b9eac611cfce2fe (patch) | |
tree | e2567ae58ba7b32281621a17476ded6bc1440546 /qmlplugin | |
parent | 3090f0f1def6140c793a415760da5cdb410ca205 (diff) |
Make sure we return a sane value even if sensor isn't warmed up
it seems that the sensor takes a while to warm up, and until it does, it will return 0.
This fixes a check that previously already existed, but was checking the wrong value - if the step offset causes step count to increase, we will be returning erroneous values.
Diffstat (limited to 'qmlplugin')
-rw-r--r-- | qmlplugin/stepsDataLoader.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/qmlplugin/stepsDataLoader.cpp b/qmlplugin/stepsDataLoader.cpp index 50a0101..0dcc6ba 100644 --- a/qmlplugin/stepsDataLoader.cpp +++ b/qmlplugin/stepsDataLoader.cpp @@ -36,11 +36,11 @@ StepsDataLoader::StepsDataLoader() : QObject() int StepsDataLoader::getTodayTotal() { QSettings settings("asteroid", "sensorlogd"); - int total = m_stepcounterSensor->reading()->steps() - settings.value("StepCounterPrivate/stepsOffset", 0).toInt(); - if (total < 0) { + int steps = m_stepcounterSensor->reading()->steps(); + if (steps < 1) { return getTotalForDate(QDate::currentDate()); } - return total; + return steps - settings.value("StepCounterPrivate/stepsOffset", 0).toInt(); } int StepsDataLoader::getTotalForDate(QDate date) { // This is obvious garbage. This should really be abstracted and cached, so that every page doesn't have to reload the file from scratch. |