aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/motion/MotionController.h
diff options
context:
space:
mode:
authorFintasticMan <finlay.neon.kid@gmail.com>2024-02-12 11:37:34 +0100
committerJF <JF002@users.noreply.github.com>2024-03-12 19:14:58 +0100
commitf2df0c45ef17f5a6180ecd21654c74506d7d7dd8 (patch)
treed0f6e07ffb382ac34a3304eeaf86abb5eb223d87 /src/components/motion/MotionController.h
parent636af4d33da215f33ae09b6ae4c5e7195aaa356e (diff)
lowersleep: Improve algorithm by checking wrist angle
Inspired by https://github.com/InfiniTimeOrg/InfiniTime/pull/827#issuecomment-1881580414.
Diffstat (limited to 'src/components/motion/MotionController.h')
-rw-r--r--src/components/motion/MotionController.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/components/motion/MotionController.h b/src/components/motion/MotionController.h
index b2e7e7fe..be0241d3 100644
--- a/src/components/motion/MotionController.h
+++ b/src/components/motion/MotionController.h
@@ -21,7 +21,7 @@ namespace Pinetime {
void Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps);
int16_t X() const {
- return x;
+ return xHistory[0];
}
int16_t Y() const {
@@ -76,11 +76,14 @@ namespace Pinetime {
struct AccelStats {
static constexpr uint8_t numHistory = 2;
+ int16_t xMean = 0;
int16_t yMean = 0;
int16_t zMean = 0;
+ int16_t prevXMean = 0;
int16_t prevYMean = 0;
int16_t prevZMean = 0;
+ uint32_t xVariance = 0;
uint32_t yVariance = 0;
uint32_t zVariance = 0;
};
@@ -89,9 +92,8 @@ namespace Pinetime {
AccelStats stats = {};
- int16_t lastX = 0;
- int16_t x = 0;
static constexpr uint8_t histSize = 8;
+ Utility::CircularBuffer<int16_t, histSize> xHistory = {};
Utility::CircularBuffer<int16_t, histSize> yHistory = {};
Utility::CircularBuffer<int16_t, histSize> zHistory = {};
int32_t accumulatedSpeed = 0;