@@ -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;
0 commit comments