From 716deff7d0456cdd9eb1d152d3b29f1f39c7a231 Mon Sep 17 00:00:00 2001 From: Hunman Date: Sat, 8 Nov 2025 21:58:23 +0100 Subject: Step counter history Store 2 days steps history and display yesterday's steps on the Steps screen --- src/components/motion/MotionController.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/components/motion/MotionController.cpp') diff --git a/src/components/motion/MotionController.cpp b/src/components/motion/MotionController.cpp index 6cfff61f..ce959f0e 100644 --- a/src/components/motion/MotionController.cpp +++ b/src/components/motion/MotionController.cpp @@ -35,8 +35,17 @@ namespace { } } +void MotionController::AdvanceDay() { + --nbSteps; // Higher index = further in the past + SetSteps(Days::Today, 0); + if (service != nullptr) { + service->OnNewStepCountValue(NbSteps(Days::Today)); + } +} + void MotionController::Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps) { - if (this->nbSteps != nbSteps && service != nullptr) { + uint32_t oldSteps = NbSteps(Days::Today); + if (oldSteps != nbSteps && service != nullptr) { service->OnNewStepCountValue(nbSteps); } @@ -64,11 +73,11 @@ void MotionController::Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps) stats = GetAccelStats(); - int32_t deltaSteps = nbSteps - this->nbSteps; + int32_t deltaSteps = nbSteps - oldSteps; if (deltaSteps > 0) { currentTripSteps += deltaSteps; } - this->nbSteps = nbSteps; + SetSteps(Days::Today, nbSteps); } MotionController::AccelStats MotionController::GetAccelStats() const { -- cgit v1.2.3-70-g09d2