Add averaging to wake threshold. Makes it take more then just a "flick" to turn on

This commit is contained in:
Tim Keller
2021-09-27 03:30:49 +00:00
parent 3ebf002f9d
commit 6d74820698
3 changed files with 7 additions and 3 deletions

View File

@@ -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;