diff options
Diffstat (limited to 'src/components/motion')
| -rw-r--r-- | src/components/motion/MotionController.cpp | 5 | ||||
| -rw-r--r-- | src/components/motion/MotionController.h | 1 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/components/motion/MotionController.cpp b/src/components/motion/MotionController.cpp index 615ad26..4843f30 100644 --- a/src/components/motion/MotionController.cpp +++ b/src/components/motion/MotionController.cpp @@ -50,7 +50,10 @@ bool MotionController::Should_ShakeWake(uint16_t thresh) { auto diff = xTaskGetTickCount() - lastShakeTime; lastShakeTime = xTaskGetTickCount(); int32_t speed = std::abs(y + z - lastYForShake - lastZForShake) / diff * 10; - if (speed > thresh) { + //(.2 * speed) + ((1 - .2) * accumulatedspeed); + //implemented without floats as .25Alpha + accumulatedspeed = (speed/4) + ((accumulatedspeed/4)*3); + if (accumulatedspeed > thresh) { wake = true; } lastXForShake = x; diff --git a/src/components/motion/MotionController.h b/src/components/motion/MotionController.h index 28f7d3a..aee9e63 100644 --- a/src/components/motion/MotionController.h +++ b/src/components/motion/MotionController.h @@ -65,6 +65,7 @@ namespace Pinetime { int16_t lastXForShake = 0; int16_t lastYForShake = 0; int16_t lastZForShake = 0; + int32_t accumulatedspeed = 0; uint32_t lastShakeTime = 0; }; } |
