feat: always on display
This commit is contained in:
@@ -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()) {
|
||||
|
@@ -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()];
|
||||
|
Reference in New Issue
Block a user