From 97771077ea20f518a416323941961324177136ca Mon Sep 17 00:00:00 2001 From: Finlay Davidson Date: Mon, 13 Dec 2021 09:58:58 +0100 Subject: [PATCH] PR #826: Improve and simplify Raise to Wake algorithm Squashed commit of the following: commit 9d5ddb3f9879500393dd051937233ca7c4a74d65 Author: Finlay Davidson Date: Mon Nov 15 10:01:52 2021 +0100 Tweak the raise to wake values a bit more commit 52bd0c3120274a3475bb60e57a864e469d7c5f86 Author: Finlay Davidson Date: Sun Nov 14 01:39:37 2021 +0100 Adjust trigger values for Raise to Wake Also handle isSleeping in SystemTask commit d41fee0cf66c901b638eea05ca24c5f7ea5310ed Author: Finlay Davidson Date: Fri Nov 12 00:59:03 2021 +0100 Improve and simplify Raise to Wake algorithm --- src/components/motion/MotionController.cpp | 29 ++++++++-------------- src/components/motion/MotionController.h | 2 +- src/systemtask/SystemTask.cpp | 2 +- 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/components/motion/MotionController.cpp b/src/components/motion/MotionController.cpp index 76c2a7a1d1..42b47256f4 100644 --- a/src/components/motion/MotionController.cpp +++ b/src/components/motion/MotionController.cpp @@ -17,27 +17,18 @@ void MotionController::Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps) this->nbSteps = 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; - } - } +bool MotionController::ShouldWakeUp() { + bool ret = false; - if (y >= 0) { - lastYForWakeUp = 0; - return false; - } - if (y + 230 < lastYForWakeUp) { - lastYForWakeUp = y; - return true; - } + if (x >= -384 && x <= 384 && + z <= 0 && + y <= lastYForWakeUp - 160) { + ret = true; } - return false; + + lastYForWakeUp = (y < 0) ? y : 0; + + return ret; } bool MotionController::ShouldSleep() { bool ret = false; diff --git a/src/components/motion/MotionController.h b/src/components/motion/MotionController.h index 703d322dbc..c838417ea7 100644 --- a/src/components/motion/MotionController.h +++ b/src/components/motion/MotionController.h @@ -28,7 +28,7 @@ namespace Pinetime { uint32_t NbSteps() const { return nbSteps; } - bool ShouldWakeUp(bool isSleeping); + bool ShouldWakeUp(); bool ShouldSleep(); void IsSensorOk(bool isOk); diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index ff44c8c19d..298afa6d40 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -470,7 +470,7 @@ void SystemTask::UpdateMotion() { motionController.IsSensorOk(motionSensor.IsOk()); motionController.Update(motionValues.x, motionValues.y, motionValues.z, motionValues.steps); - if (motionController.ShouldWakeUp(isSleeping)) { + if (motionController.ShouldWakeUp() && isSleeping) { GoToRunning(); } if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::LowerWrist)) {