diff options
| author | Tim Keller <geekboy1011@gmail.com> | 2021-09-27 03:30:49 (GMT) |
|---|---|---|
| committer | Tim Keller <geekboy1011@gmail.com> | 2022-01-04 01:59:01 (GMT) |
| commit | 6d748206983ca1ae7c929fba58d62ddfdb365650 (patch) | |
| tree | eb156d81507e897a8648df49fbd7b00da4e87e0d /src/components/motion/MotionController.cpp | |
| parent | 3ebf002f9db75513d036c0eaa0863e75882b3a40 (diff) | |
Add averaging to wake threshold. Makes it take more then just a "flick" to turn on
Diffstat (limited to 'src/components/motion/MotionController.cpp')
| -rw-r--r-- | src/components/motion/MotionController.cpp | 5 |
1 files changed, 4 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; |
