Skip to content

Commit

Permalink
Improve and simplify Raise to Wake algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
FintasticMan committed Dec 13, 2021
1 parent 6a5946c commit d41fee0
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions src/components/motion/MotionController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,18 @@ void MotionController::Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps)
}

bool MotionController::ShouldWakeUp(bool isSleeping) {
if ((x + 335) <= 670 && z < 0) {
if (not isSleeping) {
if (y <= 0) {
return false;
} else {
lastYForWakeUp = 0;
return false;
}
}

if (y >= 0) {
lastYForWakeUp = 0;
return false;
}
if (y + 230 < lastYForWakeUp) {
lastYForWakeUp = y;
return true;
}
bool ret = false;

if (x >= -384 && x <= 384 &&
z <= 0 &&
y <= lastYForWakeUp - 192 &&
isSleeping) {
ret = true;
}
return false;

lastYForWakeUp = (y < 0) ? y : 0;

return ret;
}
void MotionController::IsSensorOk(bool isOk) {
isSensorOk = isOk;
Expand Down

0 comments on commit d41fee0

Please sign in to comment.