From 3085bb39901cd71c4e2fe006ad0c0967a66f7a80 Mon Sep 17 00:00:00 2001 From: Finlay Davidson Date: Sun, 25 Jun 2023 15:55:24 +0200 Subject: motioncontroller: Store acceleration history Store history of acceleration values for the y and z axes. --- src/components/motion/MotionController.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/components/motion/MotionController.h') diff --git a/src/components/motion/MotionController.h b/src/components/motion/MotionController.h index c524fef3..c967530b 100644 --- a/src/components/motion/MotionController.h +++ b/src/components/motion/MotionController.h @@ -6,6 +6,7 @@ #include "drivers/Bma421.h" #include "components/ble/MotionService.h" +#include "utility/CircularBuffer.h" namespace Pinetime { namespace Controllers { @@ -24,11 +25,11 @@ namespace Pinetime { } int16_t Y() const { - return y; + return yHistory[0]; } int16_t Z() const { - return z; + return zHistory[0]; } uint32_t NbSteps() const { @@ -70,10 +71,9 @@ namespace Pinetime { int16_t lastX = 0; int16_t x = 0; int16_t lastYForRaiseWake = 0; - int16_t lastY = 0; - int16_t y = 0; - int16_t lastZ = 0; - int16_t z = 0; + static constexpr uint8_t histSize = 8; + Utility::CircularBuffer yHistory = {}; + Utility::CircularBuffer zHistory = {}; int32_t accumulatedSpeed = 0; DeviceTypes deviceType = DeviceTypes::Unknown; -- cgit v1.2.3-70-g09d2