From 6d748206983ca1ae7c929fba58d62ddfdb365650 Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Mon, 27 Sep 2021 03:30:49 +0000 Subject: Add averaging to wake threshold. Makes it take more then just a "flick" to turn on --- src/components/motion/MotionController.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/components/motion/MotionController.cpp') diff --git a/src/components/motion/MotionController.cpp b/src/components/motion/MotionController.cpp index 615ad26c..4843f304 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; -- cgit v1.2.3-70-g09d2