Skip to content

Commit

Permalink
Opening app now sets lower brightness and restores when closing only …
Browse files Browse the repository at this point in the history
…if tracker disabled.
  • Loading branch information
cyberneel committed Dec 13, 2024
1 parent 66aaaae commit 14d173f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/components/infinisleep/InfiniSleepController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ void InfiniSleepController::Init(System::SystemTask* systemTask) {
}

void InfiniSleepController::EnableTracker() {
prevBrightnessLevel = brightnessController.Level();
brightnessController.Set(BrightnessController::Levels::Low);
// DisableTracker();
NRF_LOG_INFO("[InfiniSleepController] Enabling tracker");
isEnabled = true;
Expand All @@ -66,7 +64,6 @@ void InfiniSleepController::EnableTracker() {
}

void InfiniSleepController::DisableTracker() {
brightnessController.Set(prevBrightnessLevel);
NRF_LOG_INFO("[InfiniSleepController] Disabling tracker");
xTimerStop(trackerUpdateTimer, 0);
isEnabled = false;
Expand Down
4 changes: 4 additions & 0 deletions src/components/infinisleep/InfiniSleepController.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ namespace Pinetime {
return (9 - gradualWakeStep) + 1;
}

BrightnessController& GetBrightnessController() {
return brightnessController;
}

private:
bool isAlerting = false;
bool isGradualWakeAlerting = false;
Expand Down
8 changes: 8 additions & 0 deletions src/displayapp/screens/Sleep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ Sleep::Sleep(Controllers::InfiniSleepController& infiniSleepController,
lv_task_create(PressesToStopAlarmTimeoutCallback, PUSHES_TO_STOP_ALARM_TIMEOUT * 1000, LV_TASK_PRIO_MID, this);
infiniSleepController.infiniSleepSettings.sleepCycleDuration = 90;
infiniSleepController.SetSettingsChanged();

if (!infiniSleepController.IsEnabled()) {
infiniSleepController.prevBrightnessLevel = infiniSleepController.GetBrightnessController().Level();
}
infiniSleepController.GetBrightnessController().Set(Controllers::BrightnessController::Levels::Low);
}

Sleep::~Sleep() {
Expand All @@ -73,6 +78,9 @@ Sleep::~Sleep() {
lv_obj_clean(lv_scr_act());
infiniSleepController.SaveWakeAlarm();
infiniSleepController.SaveInfiniSleepSettings();
if (!infiniSleepController.IsEnabled()) {
infiniSleepController.GetBrightnessController().Set(infiniSleepController.prevBrightnessLevel);
}
}

void Sleep::DisableWakeAlarm() {
Expand Down

0 comments on commit 14d173f

Please sign in to comment.