diff options
author | Tim Keller <geekboy1011@gmail.com> | 2021-09-30 00:04:51 +0000 |
---|---|---|
committer | Tim Keller <geekboy1011@gmail.com> | 2022-01-04 02:00:03 +0000 |
commit | 5c1320023815502ee3c8965ae75bb3d095058e0e (patch) | |
tree | b0aa40fffa3dee65f849db099bca734d34b6551a /src/components/motion | |
parent | d6b22645e319da820ff8e86336c774cdb4a78be4 (diff) |
Fix crash upon leaving app.
Code formatting
Diffstat (limited to 'src/components/motion')
-rw-r--r-- | src/components/motion/MotionController.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/components/motion/MotionController.cpp b/src/components/motion/MotionController.cpp index d26fffd0..7dd32127 100644 --- a/src/components/motion/MotionController.cpp +++ b/src/components/motion/MotionController.cpp @@ -48,20 +48,21 @@ bool MotionController::Should_ShakeWake(uint16_t thresh) { bool wake = false; auto diff = xTaskGetTickCount() - lastShakeTime; lastShakeTime = xTaskGetTickCount(); - int32_t speed = std::abs(z + (y/2) + (x/4)- lastYForShake - lastZForShake) / diff * 100; + /* Currently Polling at 10hz, If this ever goes faster scalar and EMA might need adjusting */ + int32_t speed = std::abs(z + (y / 2) + (x / 4) - lastYForShake - lastZForShake) / diff * 100; //(.2 * speed) + ((1 - .2) * accumulatedspeed); - //implemented without floats as .25Alpha - accumulatedspeed = (speed/5) + ((accumulatedspeed/5)*4); + // implemented without floats as .25Alpha + accumulatedspeed = (speed / 5) + ((accumulatedspeed / 5) * 4); - if (accumulatedspeed > thresh) { + if (accumulatedspeed > thresh) { wake = true; } - lastXForShake = x/4; - lastYForShake = y/2; + lastXForShake = x / 4; + lastYForShake = y / 2; lastZForShake = z; return wake; } -int32_t MotionController::currentShakeSpeed(){ +int32_t MotionController::currentShakeSpeed() { return accumulatedspeed; } |