Skip to content

Commit 765f037

Browse files
KaffeinatedKatmark9064
authored andcommitted
aod: disable while in notification sleep
1 parent 301e68b commit 765f037

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

src/components/settings/Settings.h

+35-4
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,14 @@ namespace Pinetime {
196196
if (status != settings.notificationStatus) {
197197
settingsChanged = true;
198198
}
199+
// Disable always on screen while sleep mode is enabled
200+
if (settings.alwaysOnDisplay.enabled) {
201+
if (status == Notification::Sleep) {
202+
settings.alwaysOnDisplay.state = false;
203+
} else {
204+
settings.alwaysOnDisplay.state = true;
205+
}
206+
}
199207
settings.notificationStatus = status;
200208
};
201209

@@ -215,16 +223,32 @@ namespace Pinetime {
215223
};
216224

217225
void SetAlwaysOnDisplay(bool state) {
218-
if (state != settings.alwaysOnDisplay) {
226+
if (state != settings.alwaysOnDisplay.state) {
219227
settingsChanged = true;
220228
}
221-
settings.alwaysOnDisplay = state;
229+
settings.alwaysOnDisplay.state = state;
222230
};
223231

224232
bool GetAlwaysOnDisplay() const {
225-
return settings.alwaysOnDisplay;
233+
return settings.alwaysOnDisplay.state;
226234
};
227235

236+
void SetAlwaysOnDisplaySetting(bool state) {
237+
if (state != settings.alwaysOnDisplay.enabled) {
238+
settingsChanged = true;
239+
}
240+
settings.alwaysOnDisplay.enabled = state;
241+
242+
// Don't enable always on if we are currently in notification sleep
243+
if (GetNotificationStatus() != Notification::Sleep) {
244+
SetAlwaysOnDisplay(state);
245+
}
246+
}
247+
248+
bool GetAlwaysOnDisplaySetting() const {
249+
return settings.alwaysOnDisplay.enabled;
250+
}
251+
228252
void SetShakeThreshold(uint16_t thresh) {
229253
if (settings.shakeWakeThreshold != thresh) {
230254
settings.shakeWakeThreshold = thresh;
@@ -299,12 +323,19 @@ namespace Pinetime {
299323

300324
static constexpr uint32_t settingsVersion = 0x0008;
301325

326+
// To enable disabling it during notification sleep, differentiate between
327+
// the setting being on, and the setting being set by the user
328+
struct alwaysOnDisplayData {
329+
bool enabled = false;
330+
bool state = false;
331+
};
332+
302333
struct SettingsData {
303334
uint32_t version = settingsVersion;
304335
uint32_t stepsGoal = 10000;
305336
uint32_t screenTimeOut = 15000;
306337

307-
bool alwaysOnDisplay = false;
338+
alwaysOnDisplayData alwaysOnDisplay;
308339

309340
ClockType clockType = ClockType::H24;
310341
WeatherFormat weatherFormat = WeatherFormat::Metric;

src/displayapp/screens/settings/SettingDisplay.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ SettingDisplay::SettingDisplay(Pinetime::Applications::DisplayApp* app, Pinetime
6666

6767
alwaysOnCheckbox = lv_checkbox_create(container1, nullptr);
6868
lv_checkbox_set_text(alwaysOnCheckbox, "Always On");
69-
lv_checkbox_set_checked(alwaysOnCheckbox, settingsController.GetAlwaysOnDisplay());
69+
lv_checkbox_set_checked(alwaysOnCheckbox, settingsController.GetAlwaysOnDisplaySetting());
7070
lv_obj_add_state(alwaysOnCheckbox, LV_STATE_DEFAULT);
7171
alwaysOnCheckbox->user_data = this;
7272
lv_obj_set_event_cb(alwaysOnCheckbox, AlwaysOnEventHandler);
@@ -78,8 +78,8 @@ SettingDisplay::~SettingDisplay() {
7878
}
7979

8080
void SettingDisplay::ToggleAlwaysOn() {
81-
settingsController.SetAlwaysOnDisplay(!settingsController.GetAlwaysOnDisplay());
82-
lv_checkbox_set_checked(alwaysOnCheckbox, settingsController.GetAlwaysOnDisplay());
81+
settingsController.SetAlwaysOnDisplaySetting(!settingsController.GetAlwaysOnDisplaySetting());
82+
lv_checkbox_set_checked(alwaysOnCheckbox, settingsController.GetAlwaysOnDisplaySetting());
8383
}
8484

8585
void SettingDisplay::UpdateSelected(lv_obj_t* object, lv_event_t event) {

0 commit comments

Comments
 (0)