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.h | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/components/motion/MotionController.h') diff --git a/src/components/motion/MotionController.h b/src/components/motion/MotionController.h index ad95f31f..ed6cbbd1 100644 --- a/src/components/motion/MotionController.h +++ b/src/components/motion/MotionController.h @@ -18,6 +18,15 @@ namespace Pinetime { BMA425, }; + enum class Days : uint8_t { + Today = 0, + Yesterday, + }; + + static constexpr size_t stepHistorySize = 2; // Store this many day's step counter + + void AdvanceDay(); + void Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps); int16_t X() const { @@ -32,8 +41,8 @@ namespace Pinetime { return zHistory[0]; } - uint32_t NbSteps() const { - return nbSteps; + uint32_t NbSteps(Days day = Days::Today) const { + return nbSteps[static_cast>(day)]; } void ResetTrip() { @@ -66,9 +75,13 @@ namespace Pinetime { } private: - uint32_t nbSteps = 0; + Utility::CircularBuffer nbSteps = {0}; uint32_t currentTripSteps = 0; + void SetSteps(Days day, uint32_t steps) { + nbSteps[static_cast>(day)] = steps; + } + TickType_t lastTime = 0; TickType_t time = 0; -- cgit v1.2.3-70-g09d2