Skip to content

Commit

Permalink
PR InfiniTimeOrg#826: Improve and simplify Raise to Wake algorithm
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 9d5ddb3
Author: Finlay Davidson <[email protected]>
Date:   Mon Nov 15 10:01:52 2021 +0100

    Tweak the raise to wake values a bit more

commit 52bd0c3
Author: Finlay Davidson <[email protected]>
Date:   Sun Nov 14 01:39:37 2021 +0100

    Adjust trigger values for Raise to Wake

    Also handle isSleeping in SystemTask

commit d41fee0
Author: Finlay Davidson <[email protected]>
Date:   Fri Nov 12 00:59:03 2021 +0100

    Improve and simplify Raise to Wake algorithm
  • Loading branch information
FintasticMan committed Dec 13, 2021
1 parent 53788ed commit 9777107
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
29 changes: 10 additions & 19 deletions src/components/motion/MotionController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/components/motion/MotionController.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Pinetime {
uint32_t NbSteps() const {
return nbSteps;
}
bool ShouldWakeUp(bool isSleeping);
bool ShouldWakeUp();
bool ShouldSleep();

void IsSensorOk(bool isOk);
Expand Down
2 changes: 1 addition & 1 deletion src/systemtask/SystemTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 9777107

Please sign in to comment.