Refresh UIs without scene shenanigans

This commit is contained in:
Willy-JL
2023-11-29 19:11:49 +00:00
parent f47332e799
commit ab46739d38
4 changed files with 88 additions and 20 deletions

View File

@@ -139,14 +139,28 @@ bool xtreme_app_scene_interface_mainmenu_on_event(void* context, SceneManagerEve
app->mainmenu_app_labels, app->mainmenu_app_index, app->mainmenu_app_index + 1); app->mainmenu_app_labels, app->mainmenu_app_index, app->mainmenu_app_index + 1);
CharList_remove_v( CharList_remove_v(
app->mainmenu_app_exes, app->mainmenu_app_index, app->mainmenu_app_index + 1); app->mainmenu_app_exes, app->mainmenu_app_index, app->mainmenu_app_index + 1);
if(app->mainmenu_app_index) app->mainmenu_app_index--;
/* fall through */ /* fall through */
case VarItemListIndexMoveApp: case VarItemListIndexMoveApp: {
app->save_mainmenu_apps = true; app->save_mainmenu_apps = true;
app->require_reboot = true; app->require_reboot = true;
scene_manager_previous_scene(app->scene_manager); size_t count = CharList_size(app->mainmenu_app_labels);
scene_manager_next_scene(app->scene_manager, XtremeAppSceneInterfaceMainmenu); VariableItem* item = variable_item_list_get(app->var_item_list, VarItemListIndexApp);
if(count) {
app->mainmenu_app_index = CLAMP(app->mainmenu_app_index, count - 1, 0U);
char label[20];
snprintf(label, 20, "App %u/%u", 1 + app->mainmenu_app_index, count);
variable_item_set_item_label(item, label);
variable_item_set_current_value_text(
item, *CharList_get(app->mainmenu_app_labels, app->mainmenu_app_index));
} else {
app->mainmenu_app_index = 0;
variable_item_set_item_label(item, "App");
variable_item_set_current_value_text(item, "None");
}
variable_item_set_current_value_index(item, app->mainmenu_app_index);
variable_item_set_values_count(item, count);
break; break;
}
case VarItemListIndexAddApp: case VarItemListIndexAddApp:
scene_manager_next_scene(app->scene_manager, XtremeAppSceneInterfaceMainmenuAdd); scene_manager_next_scene(app->scene_manager, XtremeAppSceneInterfaceMainmenuAdd);
break; break;

View File

@@ -48,6 +48,7 @@ static const struct {
{"Fuchsia", {255, 0, 255}}, {"Pink", {173, 31, 173}}, {"Brown", {165, 42, 42}}, {"Fuchsia", {255, 0, 255}}, {"Pink", {173, 31, 173}}, {"Brown", {165, 42, 42}},
{"White", {255, 192, 203}}, {"White", {255, 192, 203}},
}; };
static const size_t lcd_sz = COUNT_OF(lcd_colors);
static void xtreme_app_scene_misc_screen_lcd_color_changed(VariableItem* item, uint8_t led) { static void xtreme_app_scene_misc_screen_lcd_color_changed(VariableItem* item, uint8_t led) {
XtremeApp* app = variable_item_get_context(item); XtremeApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item); uint8_t index = variable_item_get_current_value_index(item);
@@ -64,6 +65,14 @@ static void xtreme_app_scene_misc_screen_lcd_color_1_changed(VariableItem* item)
static void xtreme_app_scene_misc_screen_lcd_color_2_changed(VariableItem* item) { static void xtreme_app_scene_misc_screen_lcd_color_2_changed(VariableItem* item) {
xtreme_app_scene_misc_screen_lcd_color_changed(item, 2); xtreme_app_scene_misc_screen_lcd_color_changed(item, 2);
} }
static const struct {
uint8_t led;
VariableItemChangeCallback cb;
} lcd_cols[] = {
{0, xtreme_app_scene_misc_screen_lcd_color_0_changed},
{1, xtreme_app_scene_misc_screen_lcd_color_1_changed},
{2, xtreme_app_scene_misc_screen_lcd_color_2_changed},
};
const char* const rainbow_lcd_names[RGBBacklightRainbowModeCount] = { const char* const rainbow_lcd_names[RGBBacklightRainbowModeCount] = {
"OFF", "OFF",
@@ -158,16 +167,6 @@ void xtreme_app_scene_misc_screen_on_enter(void* context) {
item = variable_item_list_add(var_item_list, "RGB Backlight", 1, NULL, app); item = variable_item_list_add(var_item_list, "RGB Backlight", 1, NULL, app);
variable_item_set_current_value_text(item, xtreme_settings.rgb_backlight ? "ON" : "OFF"); variable_item_set_current_value_text(item, xtreme_settings.rgb_backlight ? "ON" : "OFF");
struct {
uint8_t led;
VariableItemChangeCallback cb;
} lcd_cols[] = {
{0, xtreme_app_scene_misc_screen_lcd_color_0_changed},
{1, xtreme_app_scene_misc_screen_lcd_color_1_changed},
{2, xtreme_app_scene_misc_screen_lcd_color_2_changed},
};
size_t lcd_sz = COUNT_OF(lcd_colors);
RgbColor color; RgbColor color;
for(size_t i = 0; i < COUNT_OF(lcd_cols); i++) { for(size_t i = 0; i < COUNT_OF(lcd_cols); i++) {
char name[12]; char name[12];
@@ -285,8 +284,31 @@ bool xtreme_app_scene_misc_screen_on_event(void* context, SceneManagerEvent even
app->save_backlight = true; app->save_backlight = true;
notification_message(app->notification, &sequence_display_backlight_on); notification_message(app->notification, &sequence_display_backlight_on);
rgb_backlight_reconfigure(xtreme_settings.rgb_backlight); rgb_backlight_reconfigure(xtreme_settings.rgb_backlight);
scene_manager_previous_scene(app->scene_manager); variable_item_set_current_value_text(
scene_manager_next_scene(app->scene_manager, XtremeAppSceneMiscScreen); variable_item_list_get(app->var_item_list, VarItemListIndexRgbBacklight),
xtreme_settings.rgb_backlight ? "ON" : "OFF");
for(size_t i = 0; i < COUNT_OF(lcd_cols); i++) {
variable_item_set_locked(
variable_item_list_get(app->var_item_list, VarItemListIndexLcdColor0 + i),
!xtreme_settings.rgb_backlight,
"Needs RGB\nBacklight!");
}
variable_item_set_locked(
variable_item_list_get(app->var_item_list, VarItemListIndexRainbowLcd),
!xtreme_settings.rgb_backlight,
"Needs RGB\nBacklight!");
variable_item_set_locked(
variable_item_list_get(app->var_item_list, VarItemListIndexRainbowSpeed),
!xtreme_settings.rgb_backlight,
"Needs RGB\nBacklight!");
variable_item_set_locked(
variable_item_list_get(app->var_item_list, VarItemListIndexRainbowInterval),
!xtreme_settings.rgb_backlight,
"Needs RGB\nBacklight!");
variable_item_set_locked(
variable_item_list_get(app->var_item_list, VarItemListIndexRainbowSaturation),
!xtreme_settings.rgb_backlight,
"Needs RGB\nBacklight!");
} }
break; break;
} }

View File

@@ -71,16 +71,32 @@ bool xtreme_app_scene_protocols_freqs_hopper_on_event(void* context, SceneManage
*FrequencyList_get(app->subghz_hopper_freqs, app->subghz_hopper_index); *FrequencyList_get(app->subghz_hopper_freqs, app->subghz_hopper_index);
FrequencyList_it_t it; FrequencyList_it_t it;
FrequencyList_it(it, app->subghz_hopper_freqs); FrequencyList_it(it, app->subghz_hopper_freqs);
size_t removed = 0;
while(!FrequencyList_end_p(it)) { while(!FrequencyList_end_p(it)) {
if(*FrequencyList_ref(it) == value) { if(*FrequencyList_ref(it) == value) {
FrequencyList_remove(app->subghz_hopper_freqs, it); FrequencyList_remove(app->subghz_hopper_freqs, it);
removed++;
} else { } else {
FrequencyList_next(it); FrequencyList_next(it);
} }
} }
app->save_subghz_freqs = true; app->save_subghz_freqs = true;
scene_manager_previous_scene(app->scene_manager); VariableItem* item =
scene_manager_next_scene(app->scene_manager, XtremeAppSceneProtocolsFreqsHopper); variable_item_list_get(app->var_item_list, VarItemListIndexHopperFrequency);
variable_item_set_values_count(item, FrequencyList_size(app->subghz_hopper_freqs));
if(FrequencyList_size(app->subghz_hopper_freqs)) {
app->subghz_hopper_index -= removed;
uint32_t value =
*FrequencyList_get(app->subghz_hopper_freqs, app->subghz_hopper_index);
char text[10] = {0};
snprintf(
text, sizeof(text), "%lu.%02lu", value / 1000000, (value % 1000000) / 10000);
variable_item_set_current_value_text(item, text);
} else {
app->subghz_hopper_index = 0;
variable_item_set_current_value_text(item, "None");
}
variable_item_set_current_value_index(item, app->subghz_hopper_index);
break; break;
case VarItemListIndexAddHopperFreq: case VarItemListIndexAddHopperFreq:
scene_manager_set_scene_state( scene_manager_set_scene_state(

View File

@@ -71,16 +71,32 @@ bool xtreme_app_scene_protocols_freqs_static_on_event(void* context, SceneManage
*FrequencyList_get(app->subghz_static_freqs, app->subghz_static_index); *FrequencyList_get(app->subghz_static_freqs, app->subghz_static_index);
FrequencyList_it_t it; FrequencyList_it_t it;
FrequencyList_it(it, app->subghz_static_freqs); FrequencyList_it(it, app->subghz_static_freqs);
size_t removed = 0;
while(!FrequencyList_end_p(it)) { while(!FrequencyList_end_p(it)) {
if(*FrequencyList_ref(it) == value) { if(*FrequencyList_ref(it) == value) {
FrequencyList_remove(app->subghz_static_freqs, it); FrequencyList_remove(app->subghz_static_freqs, it);
removed++;
} else { } else {
FrequencyList_next(it); FrequencyList_next(it);
} }
} }
app->save_subghz_freqs = true; app->save_subghz_freqs = true;
scene_manager_previous_scene(app->scene_manager); VariableItem* item =
scene_manager_next_scene(app->scene_manager, XtremeAppSceneProtocolsFreqsStatic); variable_item_list_get(app->var_item_list, VarItemListIndexStaticFrequency);
variable_item_set_values_count(item, FrequencyList_size(app->subghz_static_freqs));
if(FrequencyList_size(app->subghz_static_freqs)) {
app->subghz_static_index -= removed;
uint32_t value =
*FrequencyList_get(app->subghz_static_freqs, app->subghz_static_index);
char text[10] = {0};
snprintf(
text, sizeof(text), "%lu.%02lu", value / 1000000, (value % 1000000) / 10000);
variable_item_set_current_value_text(item, text);
} else {
app->subghz_static_index = 0;
variable_item_set_current_value_text(item, "None");
}
variable_item_set_current_value_index(item, app->subghz_static_index);
break; break;
case VarItemListIndexAddStaticFreq: case VarItemListIndexAddStaticFreq:
scene_manager_set_scene_state( scene_manager_set_scene_state(