aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Crawford <coffeeboi47@protonmail.com>2023-10-03 18:50:36 -0600
committerJF <JF002@users.noreply.github.com>2024-08-05 20:32:43 +0200
commite884b053d32d4a7c3b4464e07edaddfbb334ec27 (patch)
treef6e6a1d8ca5010f95bbba2cf9343b0765f8d563b
parent85a2181b648d4219fef269e562bbfc1a4f4c9436 (diff)
aod: disable while in notification sleep
-rw-r--r--src/components/settings/Settings.h39
-rw-r--r--src/displayapp/screens/settings/SettingDisplay.cpp6
2 files changed, 38 insertions, 7 deletions
diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h
index d75cd678..1ab67095 100644
--- a/src/components/settings/Settings.h
+++ b/src/components/settings/Settings.h
@@ -196,6 +196,14 @@ namespace Pinetime {
if (status != settings.notificationStatus) {
settingsChanged = true;
}
+ // Disable always on screen while sleep mode is enabled
+ if (settings.alwaysOnDisplay.enabled) {
+ if (status == Notification::Sleep) {
+ settings.alwaysOnDisplay.state = false;
+ } else {
+ settings.alwaysOnDisplay.state = true;
+ }
+ }
settings.notificationStatus = status;
};
@@ -215,16 +223,32 @@ namespace Pinetime {
};
void SetAlwaysOnDisplay(bool state) {
- if (state != settings.alwaysOnDisplay) {
+ if (state != settings.alwaysOnDisplay.state) {
settingsChanged = true;
}
- settings.alwaysOnDisplay = state;
+ settings.alwaysOnDisplay.state = state;
};
bool GetAlwaysOnDisplay() const {
- return settings.alwaysOnDisplay;
+ return settings.alwaysOnDisplay.state;
};
+ void SetAlwaysOnDisplaySetting(bool state) {
+ if (state != settings.alwaysOnDisplay.enabled) {
+ settingsChanged = true;
+ }
+ settings.alwaysOnDisplay.enabled = state;
+
+ // Don't enable always on if we are currently in notification sleep
+ if (GetNotificationStatus() != Notification::Sleep) {
+ SetAlwaysOnDisplay(state);
+ }
+ }
+
+ bool GetAlwaysOnDisplaySetting() const {
+ return settings.alwaysOnDisplay.enabled;
+ }
+
void SetShakeThreshold(uint16_t thresh) {
if (settings.shakeWakeThreshold != thresh) {
settings.shakeWakeThreshold = thresh;
@@ -299,12 +323,19 @@ namespace Pinetime {
static constexpr uint32_t settingsVersion = 0x0008;
+ // To enable disabling it during notification sleep, differentiate between
+ // the setting being on, and the setting being set by the user
+ struct alwaysOnDisplayData {
+ bool enabled = false;
+ bool state = false;
+ };
+
struct SettingsData {
uint32_t version = settingsVersion;
uint32_t stepsGoal = 10000;
uint32_t screenTimeOut = 15000;
- bool alwaysOnDisplay = false;
+ alwaysOnDisplayData alwaysOnDisplay;
ClockType clockType = ClockType::H24;
WeatherFormat weatherFormat = WeatherFormat::Metric;
diff --git a/src/displayapp/screens/settings/SettingDisplay.cpp b/src/displayapp/screens/settings/SettingDisplay.cpp
index 12d0f561..57a64d7f 100644
--- a/src/displayapp/screens/settings/SettingDisplay.cpp
+++ b/src/displayapp/screens/settings/SettingDisplay.cpp
@@ -66,7 +66,7 @@ SettingDisplay::SettingDisplay(Pinetime::Applications::DisplayApp* app, Pinetime
alwaysOnCheckbox = lv_checkbox_create(container1, nullptr);
lv_checkbox_set_text(alwaysOnCheckbox, "Always On");
- lv_checkbox_set_checked(alwaysOnCheckbox, settingsController.GetAlwaysOnDisplay());
+ lv_checkbox_set_checked(alwaysOnCheckbox, settingsController.GetAlwaysOnDisplaySetting());
lv_obj_add_state(alwaysOnCheckbox, LV_STATE_DEFAULT);
alwaysOnCheckbox->user_data = this;
lv_obj_set_event_cb(alwaysOnCheckbox, AlwaysOnEventHandler);
@@ -78,8 +78,8 @@ SettingDisplay::~SettingDisplay() {
}
void SettingDisplay::ToggleAlwaysOn() {
- settingsController.SetAlwaysOnDisplay(!settingsController.GetAlwaysOnDisplay());
- lv_checkbox_set_checked(alwaysOnCheckbox, settingsController.GetAlwaysOnDisplay());
+ settingsController.SetAlwaysOnDisplaySetting(!settingsController.GetAlwaysOnDisplaySetting());
+ lv_checkbox_set_checked(alwaysOnCheckbox, settingsController.GetAlwaysOnDisplaySetting());
}
void SettingDisplay::UpdateSelected(lv_obj_t* object, lv_event_t event) {