Improve and simplify algorithm

This commit is contained in:
Finlay Davidson 2021-11-12 00:48:04 +01:00
parent daae7d6d32
commit 943589d998

View File

@ -67,17 +67,14 @@ int32_t MotionController::currentShakeSpeed() {
}
bool MotionController::ShouldSleep(bool isSleeping) {
if (not isSleeping) {
if (y <= 0) {
lastYForSleep = 0;
return false;
}
if (y - 230 > lastYForSleep) {
lastYForSleep = y;
return true;
}
}
return false;
bool ret = false;
if (y >= lastYForSleep + 192 && !isSleeping)
ret = true;
lastYForSleep = (y > 320) ? y : 320;
return ret;
}
void MotionController::IsSensorOk(bool isOk) {