feat: always on display
This commit is contained in:
parent
f8f8993fac
commit
20ac7e8df3
|
@ -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;
|
||||
|
|
|
@ -203,7 +203,11 @@ void DisplayApp::Refresh() {
|
|||
TickType_t queueTimeout;
|
||||
switch (state) {
|
||||
case States::Idle:
|
||||
if (settingsController.GetAlwaysOnDisplay()) {
|
||||
queueTimeout = lv_task_handler();
|
||||
} else {
|
||||
queueTimeout = portMAX_DELAY;
|
||||
}
|
||||
break;
|
||||
case States::Running:
|
||||
if (!currentScreen->IsRunning()) {
|
||||
|
|
|
@ -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]) {
|
||||
|
|
|
@ -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()];
|
||||
|
|
|
@ -198,7 +198,10 @@ void SystemTask::Work() {
|
|||
doNotGoToSleep = true;
|
||||
break;
|
||||
case Messages::GoToRunning:
|
||||
// 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();
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue