Skip to content

Commit

Permalink
Adjust trigger values for Raise to Wake
Browse files Browse the repository at this point in the history
Also handle isSleeping in SystemTask
  • Loading branch information
FintasticMan committed Dec 13, 2021
1 parent d41fee0 commit 52bd0c3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/components/motion/MotionController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@ void MotionController::Update(int16_t x, int16_t y, int16_t z, uint32_t nbSteps)
this->nbSteps = nbSteps;
}

bool MotionController::ShouldWakeUp(bool isSleeping) {
bool MotionController::ShouldWakeUp() {
bool ret = false;

if (x >= -384 && x <= 384 &&
z <= 0 &&
y <= lastYForWakeUp - 192 &&
isSleeping) {
y <= lastYForWakeUp - 128) {
ret = true;
}

lastYForWakeUp = (y < 0) ? y : 0;
lastYForWakeUp = (y < 128) ? y : 128;

return ret;
}
Expand Down
4 changes: 2 additions & 2 deletions 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();

void IsSensorOk(bool isOk);
bool IsSensorOk() const {
Expand All @@ -53,4 +53,4 @@ namespace Pinetime {
Pinetime::Controllers::MotionService* service = nullptr;
};
}
}
}
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();
}
}
Expand Down

0 comments on commit 52bd0c3

Please sign in to comment.