diff --git a/scenes/scene_settings.c b/scenes/scene_settings.c index 0838f3d..e8d8598 100644 --- a/scenes/scene_settings.c +++ b/scenes/scene_settings.c @@ -14,17 +14,11 @@ #include -typedef enum { - SceneSettingsLayout, - SceneSettingsIcons, - SceneSettingsHeaders, - SceneSettingsRFIDDuration, - SceneSettingsNFCDuration, - SceneSettingsSubGHzRepeat, - SceneSettingsSubGHzExtAnt, - SceneSettingsHidden, - SceneSettingsAbout -} SceneSettingsIndex; +// Unfortunately, the VariableItemList does not provide a method to query the length +// of the list. Since we intend to place "About" last, it would be convenient to +// dynamically know it's list index for our on_event method. However, we'll need to +// hardcode the value.. +#define SCENE_SETTINGS_ABOUT 9 // 10 items in our Settings list, so last index is 9 static const char* const layout_text[2] = {"Vert", "Horiz"}; static const uint32_t layout_value[2] = {QUAC_APP_PORTRAIT, QUAC_APP_LANDSCAPE}; @@ -67,11 +61,8 @@ static const char* const repeat_text[V_REPEAT_COUNT] = { "50"}; static const uint32_t repeat_value[V_REPEAT_COUNT] = {1, 2, 3, 5, 8, 10, 15, 20, 50}; -static const char* const subghz_ext_text[2] = {"Disabled", "Enabled"}; -static const uint32_t subghz_ext_value[2] = {false, true}; - -static const char* const ir_ext_text[2] = {"Disabled", "Enabled"}; -static const uint32_t ir_ext_value[2] = {false, true}; +static const char* const disabled_enabled_text[2] = {"Disabled", "Enabled"}; +static const uint32_t disabled_enabled_value[2] = {false, true}; static void scene_settings_layout_changed(VariableItem* item) { App* app = variable_item_get_context(item); @@ -118,15 +109,15 @@ static void scene_settings_subghz_repeat_changed(VariableItem* item) { static void scene_settings_subghz_ext_changed(VariableItem* item) { App* app = variable_item_get_context(item); uint8_t index = variable_item_get_current_value_index(item); - variable_item_set_current_value_text(item, subghz_ext_text[index]); - app->settings.subghz_use_ext_antenna = subghz_ext_value[index]; + variable_item_set_current_value_text(item, disabled_enabled_text[index]); + app->settings.subghz_use_ext_antenna = disabled_enabled_value[index]; } static void scene_settings_ir_ext_changed(VariableItem* item) { App* app = variable_item_get_context(item); uint8_t index = variable_item_get_current_value_index(item); - variable_item_set_current_value_text(item, ir_ext_text[index]); - app->settings.ir_use_ext_module = ir_ext_value[index]; + variable_item_set_current_value_text(item, disabled_enabled_text[index]); + app->settings.ir_use_ext_module = disabled_enabled_value[index]; } static void scene_settings_show_hidden_changed(VariableItem* item) { @@ -188,14 +179,15 @@ void scene_settings_on_enter(void* context) { item = variable_item_list_add(vil, "SubGHz Ext Ant", 2, scene_settings_subghz_ext_changed, app); - value_index = value_index_uint32(app->settings.subghz_use_ext_antenna, subghz_ext_value, 2); + value_index = + value_index_uint32(app->settings.subghz_use_ext_antenna, disabled_enabled_value, 2); variable_item_set_current_value_index(item, value_index); - variable_item_set_current_value_text(item, subghz_ext_text[value_index]); + variable_item_set_current_value_text(item, disabled_enabled_text[value_index]); item = variable_item_list_add(vil, "IR Ext Module", 2, scene_settings_ir_ext_changed, app); - value_index = value_index_uint32(app->settings.ir_use_ext_module, ir_ext_value, 2); + value_index = value_index_uint32(app->settings.ir_use_ext_module, disabled_enabled_value, 2); variable_item_set_current_value_index(item, value_index); - variable_item_set_current_value_text(item, ir_ext_text[value_index]); + variable_item_set_current_value_text(item, disabled_enabled_text[value_index]); item = variable_item_list_add(vil, "Show Hidden", 2, scene_settings_show_hidden_changed, app); value_index = value_index_uint32(app->settings.show_hidden, show_offon_value, 2); @@ -215,7 +207,7 @@ bool scene_settings_on_event(void* context, SceneManagerEvent event) { if(event.type == SceneManagerEventTypeCustom) { switch(event.event) { - case SceneSettingsAbout: + case SCENE_SETTINGS_ABOUT: consumed = true; scene_manager_next_scene(app->scene_manager, QScene_About); break;