diff options
Diffstat (limited to 'src/components/motion/MotionController.cpp')
| -rw-r--r-- | src/components/motion/MotionController.cpp | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/src/components/motion/MotionController.cpp b/src/components/motion/MotionController.cpp index 7dd3212..c57d8aa 100644 --- a/src/components/motion/MotionController.cpp +++ b/src/components/motion/MotionController.cpp @@ -11,6 +11,7 @@ void MotionController::Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps) service->OnNewMotionValues(x, y, z); } + lastY = this->y; this->x = x; this->y = y; this->z = z; @@ -21,27 +22,8 @@ void MotionController::Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps) } } -bool MotionController::Should_RaiseWake(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; - } - } - return false; +bool MotionController::ShouldRaiseWake() const { + return x >= -384 && x <= 384 && z <= 0 && y <= -160 && y <= lastY - 160; } bool MotionController::Should_ShakeWake(uint16_t thresh) { @@ -66,6 +48,10 @@ int32_t MotionController::currentShakeSpeed() { return accumulatedspeed; } +bool MotionController::ShouldLowerSleep() const { + return y >= 512 && y >= lastY + 192; +} + void MotionController::IsSensorOk(bool isOk) { isSensorOk = isOk; } |
