diff options
| author | Finlay Davidson <finlay.davidson@coderclass.nl> | 2023-06-25 15:55:24 +0200 |
|---|---|---|
| committer | JF <JF002@users.noreply.github.com> | 2023-08-17 21:21:22 +0200 |
| commit | 3085bb39901cd71c4e2fe006ad0c0967a66f7a80 (patch) | |
| tree | f29069cf2d93f06bfc041a3b2df6997bfc048812 /src/components/motion/MotionController.h | |
| parent | 47ca403857a06e6432f36b7e1f722dd9acbfd5af (diff) | |
motioncontroller: Store acceleration history
Store history of acceleration values for the y and z axes.
Diffstat (limited to 'src/components/motion/MotionController.h')
| -rw-r--r-- | src/components/motion/MotionController.h | 12 |
1 files changed, 6 insertions, 6 deletions
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<int16_t, histSize> yHistory = {}; + Utility::CircularBuffer<int16_t, histSize> zHistory = {}; int32_t accumulatedSpeed = 0; DeviceTypes deviceType = DeviceTypes::Unknown; |
