aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaffeinatedKat <coffeeboi47@protonmail.com>2023-09-29 21:00:07 -0600
committerJF <JF002@users.noreply.github.com>2024-08-05 20:32:43 +0200
commit20ac7e8df38836d0a72c378b900b99c827c996c2 (patch)
tree9e2b05866873cc1a540ffc71fe485c94362ce038
parentf8f8993fac0bdd022dc9ef41a67c0b558f29ba89 (diff)
feat: always on display
-rw-r--r--src/components/settings/Settings.h15
-rw-r--r--src/displayapp/DisplayApp.cpp6
-rw-r--r--src/displayapp/screens/settings/SettingDisplay.cpp14
-rw-r--r--src/displayapp/screens/settings/SettingDisplay.h2
-rw-r--r--src/systemtask/SystemTask.cpp15
5 files changed, 43 insertions, 9 deletions
diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h
index 06312077..d75cd678 100644
--- a/src/components/settings/Settings.h
+++ b/src/components/settings/Settings.h
@@ -214,6 +214,17 @@ namespace Pinetime {
return settings.screenTimeOut;
};
+ void SetAlwaysOnDisplay(bool state) {
+ if (state != settings.alwaysOnDisplay) {
+ settingsChanged = true;
+ }
+ settings.alwaysOnDisplay = state;
+ };
+
+ bool GetAlwaysOnDisplay() const {
+ return settings.alwaysOnDisplay;
+ };
+
void SetShakeThreshold(uint16_t thresh) {
if (settings.shakeWakeThreshold != thresh) {
settings.shakeWakeThreshold = thresh;
@@ -286,13 +297,15 @@ namespace Pinetime {
private:
Pinetime::Controllers::FS& fs;
- static constexpr uint32_t settingsVersion = 0x0007;
+ static constexpr uint32_t settingsVersion = 0x0008;
struct SettingsData {
uint32_t version = settingsVersion;
uint32_t stepsGoal = 10000;
uint32_t screenTimeOut = 15000;
+ bool alwaysOnDisplay = false;
+
ClockType clockType = ClockType::H24;
WeatherFormat weatherFormat = WeatherFormat::Metric;
Notification notificationStatus = Notification::On;
diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp
index 3fd34b3a..c7fb62ab 100644
--- a/src/displayapp/DisplayApp.cpp
+++ b/src/displayapp/DisplayApp.cpp
@@ -203,7 +203,11 @@ void DisplayApp::Refresh() {
TickType_t queueTimeout;
switch (state) {
case States::Idle:
- queueTimeout = portMAX_DELAY;
+ if (settingsController.GetAlwaysOnDisplay()) {
+ queueTimeout = lv_task_handler();
+ } else {
+ queueTimeout = portMAX_DELAY;
+ }
break;
case States::Running:
if (!currentScreen->IsRunning()) {
diff --git a/src/displayapp/screens/settings/SettingDisplay.cpp b/src/displayapp/screens/settings/SettingDisplay.cpp
index bd533e67..760f1e9e 100644
--- a/src/displayapp/screens/settings/SettingDisplay.cpp
+++ b/src/displayapp/screens/settings/SettingDisplay.cpp
@@ -15,7 +15,7 @@ namespace {
}
}
-constexpr std::array<uint16_t, 6> SettingDisplay::options;
+constexpr std::array<uint16_t, 7> SettingDisplay::options;
SettingDisplay::SettingDisplay(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
: app {app}, settingsController {settingsController} {
@@ -46,7 +46,11 @@ SettingDisplay::SettingDisplay(Pinetime::Applications::DisplayApp* app, Pinetime
char buffer[4];
for (unsigned int i = 0; i < options.size(); i++) {
cbOption[i] = lv_checkbox_create(container1, nullptr);
- snprintf(buffer, sizeof(buffer), "%2" PRIu16 "s", options[i] / 1000);
+ if (options[i] == 0) {
+ sprintf(buffer, "%s", "Always On");
+ } else {
+ sprintf(buffer, "%2ds", options[i] / 1000);
+ }
lv_checkbox_set_text(cbOption[i], buffer);
cbOption[i]->user_data = this;
lv_obj_set_event_cb(cbOption[i], event_handler);
@@ -64,6 +68,12 @@ SettingDisplay::~SettingDisplay() {
}
void SettingDisplay::UpdateSelected(lv_obj_t* object, lv_event_t event) {
+ if (settingsController.GetScreenTimeOut() == 0) {
+ settingsController.SetAlwaysOnDisplay(true);
+ } else {
+ settingsController.SetAlwaysOnDisplay(false);
+ }
+
if (event == LV_EVENT_CLICKED) {
for (unsigned int i = 0; i < options.size(); i++) {
if (object == cbOption[i]) {
diff --git a/src/displayapp/screens/settings/SettingDisplay.h b/src/displayapp/screens/settings/SettingDisplay.h
index 64212c02..a4370463 100644
--- a/src/displayapp/screens/settings/SettingDisplay.h
+++ b/src/displayapp/screens/settings/SettingDisplay.h
@@ -21,7 +21,7 @@ namespace Pinetime {
private:
DisplayApp* app;
- static constexpr std::array<uint16_t, 6> options = {5000, 7000, 10000, 15000, 20000, 30000};
+ static constexpr std::array<uint16_t, 7> options = {5000, 7000, 10000, 15000, 20000, 30000, 0};
Controllers::Settings& settingsController;
lv_obj_t* cbOption[options.size()];
diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp
index a56c2591..fb7493aa 100644
--- a/src/systemtask/SystemTask.cpp
+++ b/src/systemtask/SystemTask.cpp
@@ -198,7 +198,10 @@ void SystemTask::Work() {
doNotGoToSleep = true;
break;
case Messages::GoToRunning:
- spi.Wakeup();
+ // SPI doesn't go to sleep for always on mode
+ if (!settingsController.GetAlwaysOnDisplay()) {
+ spi.Wakeup();
+ }
// Double Tap needs the touch screen to be in normal mode
if (!settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) {
@@ -231,7 +234,7 @@ void SystemTask::Work() {
break;
}
case Messages::GoToSleep:
- if (doNotGoToSleep) {
+ if (doNotGoToSleep or settingsController.GetAlwaysOnDisplay()) {
break;
}
state = SystemTaskState::GoingToSleep; // Already set in PushMessage()
@@ -323,7 +326,11 @@ void SystemTask::Work() {
// if it's in sleep mode. Avoid bricked device by disabling sleep mode on these versions.
spiNorFlash.Sleep();
}
- spi.Sleep();
+
+ // Must keep SPI awake when still updating the display for always on
+ if (!settingsController.GetAlwaysOnDisplay()) {
+ spi.Sleep();
+ }
// Double Tap needs the touch screen to be in normal mode
if (!settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) {
@@ -503,7 +510,7 @@ void SystemTask::OnTouchEvent() {
}
void SystemTask::PushMessage(System::Messages msg) {
- if (msg == Messages::GoToSleep && !doNotGoToSleep) {
+ if (msg == Messages::GoToSleep && !doNotGoToSleep && !settingsController.GetAlwaysOnDisplay()) {
state = SystemTaskState::GoingToSleep;
}