Skip to content

Commit

Permalink
Have isSleeping be checked by SystemTask, and fix incorrect array size
Browse files Browse the repository at this point in the history
  • Loading branch information
FintasticMan committed Dec 13, 2021
1 parent 7d50102 commit fab8269
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/components/motion/MotionController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ bool MotionController::ShouldWakeUp(bool isSleeping) {
}
return false;
}
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;

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 @@ -29,7 +29,7 @@ namespace Pinetime {
return nbSteps;
}
bool ShouldWakeUp(bool isSleeping);
bool ShouldSleep(bool isSleeping);
bool ShouldSleep();

void IsSensorOk(bool isOk);
bool IsSensorOk() const {
Expand Down
2 changes: 1 addition & 1 deletion src/displayapp/screens/settings/SettingWakeUp.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Pinetime {
private:
Controllers::Settings& settingsController;
uint8_t optionsTotal;
lv_obj_t* cbOption[5];
lv_obj_t* cbOption[4];
// When UpdateSelected is called, it uses lv_checkbox_set_checked,
// which can cause extra events to be fired,
// which might trigger UpdateSelected again, causing a loop.
Expand Down
2 changes: 1 addition & 1 deletion src/systemtask/SystemTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ void SystemTask::UpdateMotion() {
GoToRunning();
}
if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::LowerWrist)) {
if (motionController.ShouldSleep(isSleeping))
if (motionController.ShouldSleep() && !isSleeping)
PushMessage(Messages::GoToSleep);
}
}
Expand Down

0 comments on commit fab8269

Please sign in to comment.