UI: Clock on Desktop (#2891)
* Clock on desktop * Gui: gui_active_view_port_count * Gui: move gui_active_view_port_count to private header, update docs * Desktop: simplify desktop clock code * Desktop: refactor clock * Desktop: optimize clock code * Desktop: 3rd cleanup round * Desktop: 4th cleanup round, missing bits and pieces Co-authored-by: hedger <hedger@users.noreply.github.com> Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#define SCENE_EVENT_SELECT_FAVORITE_SECONDARY 1
|
||||
#define SCENE_EVENT_SELECT_PIN_SETUP 2
|
||||
#define SCENE_EVENT_SELECT_AUTO_LOCK_DELAY 3
|
||||
#define SCENE_EVENT_SELECT_CLOCK_DISPLAY 4
|
||||
|
||||
#define AUTO_LOCK_DELAY_COUNT 6
|
||||
const char* const auto_lock_delay_text[AUTO_LOCK_DELAY_COUNT] = {
|
||||
@@ -22,11 +23,27 @@ const char* const auto_lock_delay_text[AUTO_LOCK_DELAY_COUNT] = {
|
||||
const uint32_t auto_lock_delay_value[AUTO_LOCK_DELAY_COUNT] =
|
||||
{0, 30000, 60000, 120000, 300000, 600000};
|
||||
|
||||
#define CLOCK_ENABLE_COUNT 2
|
||||
const char* const clock_enable_text[CLOCK_ENABLE_COUNT] = {
|
||||
"OFF",
|
||||
"ON",
|
||||
};
|
||||
|
||||
const uint32_t clock_enable_value[CLOCK_ENABLE_COUNT] = {0, 1};
|
||||
|
||||
static void desktop_settings_scene_start_var_list_enter_callback(void* context, uint32_t index) {
|
||||
DesktopSettingsApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||
}
|
||||
|
||||
static void desktop_settings_scene_start_clock_enable_changed(VariableItem* item) {
|
||||
DesktopSettingsApp* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
|
||||
variable_item_set_current_value_text(item, clock_enable_text[index]);
|
||||
app->settings.display_clock = index;
|
||||
}
|
||||
|
||||
static void desktop_settings_scene_start_auto_lock_delay_changed(VariableItem* item) {
|
||||
DesktopSettingsApp* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
@@ -62,6 +79,18 @@ void desktop_settings_scene_start_on_enter(void* context) {
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, auto_lock_delay_text[value_index]);
|
||||
|
||||
item = variable_item_list_add(
|
||||
variable_item_list,
|
||||
"Show Clock",
|
||||
CLOCK_ENABLE_COUNT,
|
||||
desktop_settings_scene_start_clock_enable_changed, //
|
||||
app);
|
||||
|
||||
value_index =
|
||||
value_index_uint32(app->settings.display_clock, clock_enable_value, CLOCK_ENABLE_COUNT);
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, clock_enable_text[value_index]);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, DesktopSettingsAppViewVarItemList);
|
||||
}
|
||||
|
||||
@@ -86,6 +115,7 @@ bool desktop_settings_scene_start_on_event(void* context, SceneManagerEvent even
|
||||
consumed = true;
|
||||
break;
|
||||
case SCENE_EVENT_SELECT_AUTO_LOCK_DELAY:
|
||||
case SCENE_EVENT_SELECT_CLOCK_DISPLAY:
|
||||
consumed = true;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user