diff options
| author | Michele Bini <michele.bini@gmail.com> | 2022-04-09 16:47:37 (GMT) |
|---|---|---|
| committer | Michele Bini <michele.bini@gmail.com> | 2022-04-09 16:49:44 (GMT) |
| commit | 42d0d1ad338c55ca44f7f4cbb880c40e293b0d5c (patch) | |
| tree | d580a2d098d2a96f565d48ac1fcd90e59d34b5eb /src/components/motion/MotionController.cpp | |
| parent | 4d9c76afdacddb1f766c74789f49f3dc96aead9a (diff) | |
Integrate FintasticMan's RaiseWake and LowerToSleep mods
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; } |
