From a90d44f66481c0fbcc95a1fafedd0759036d717b Mon Sep 17 00:00:00 2001 From: Finlay Davidson Date: Sun, 14 Nov 2021 01:31:29 +0100 Subject: [PATCH] Have isSleeping be checked by SystemTask, and fix incorrect array size --- src/components/motion/MotionController.cpp | 5 +++-- src/components/motion/MotionController.h | 2 +- src/systemtask/SystemTask.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/motion/MotionController.cpp b/src/components/motion/MotionController.cpp index 2593d33a..da553603 100644 --- a/src/components/motion/MotionController.cpp +++ b/src/components/motion/MotionController.cpp @@ -66,11 +66,12 @@ int32_t MotionController::currentShakeSpeed() { return accumulatedspeed; } -bool MotionController::ShouldSleep(bool isSleeping) { +bool MotionController::ShouldSleep() { bool ret = false; - if (y >= lastYForSleep + 192 && !isSleeping) + if (y >= lastYForSleep + 192) { ret = true; + } lastYForSleep = (y > 320) ? y : 320; diff --git a/src/components/motion/MotionController.h b/src/components/motion/MotionController.h index 0b9f5b18..3c8bca63 100644 --- a/src/components/motion/MotionController.h +++ b/src/components/motion/MotionController.h @@ -39,7 +39,7 @@ namespace Pinetime { bool Should_ShakeWake(uint16_t thresh); bool Should_RaiseWake(bool isSleeping); int32_t currentShakeSpeed(); - bool ShouldSleep(bool isSleeping); + bool ShouldSleep(); void IsSensorOk(bool isOk); bool IsSensorOk() const { return isSensorOk; diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index e9f90df8..545b8349 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -504,7 +504,7 @@ void SystemTask::UpdateMotion() { GoToRunning(); } if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::LowerWrist)) { - if (motionController.ShouldSleep(isSleeping)) + if (motionController.ShouldSleep() && !isSleeping) PushMessage(Messages::GoToSleep); } }