mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 14:28:36 -07:00
Refresh UIs without scene shenanigans
This commit is contained in:
@@ -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);
|
||||
CharList_remove_v(
|
||||
app->mainmenu_app_exes, app->mainmenu_app_index, app->mainmenu_app_index + 1);
|
||||
if(app->mainmenu_app_index) app->mainmenu_app_index--;
|
||||
/* fall through */
|
||||
case VarItemListIndexMoveApp:
|
||||
case VarItemListIndexMoveApp: {
|
||||
app->save_mainmenu_apps = true;
|
||||
app->require_reboot = true;
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
scene_manager_next_scene(app->scene_manager, XtremeAppSceneInterfaceMainmenu);
|
||||
size_t count = CharList_size(app->mainmenu_app_labels);
|
||||
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;
|
||||
}
|
||||
case VarItemListIndexAddApp:
|
||||
scene_manager_next_scene(app->scene_manager, XtremeAppSceneInterfaceMainmenuAdd);
|
||||
break;
|
||||
|
||||
@@ -48,6 +48,7 @@ static const struct {
|
||||
{"Fuchsia", {255, 0, 255}}, {"Pink", {173, 31, 173}}, {"Brown", {165, 42, 42}},
|
||||
{"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) {
|
||||
XtremeApp* app = variable_item_get_context(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) {
|
||||
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] = {
|
||||
"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);
|
||||
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;
|
||||
for(size_t i = 0; i < COUNT_OF(lcd_cols); i++) {
|
||||
char name[12];
|
||||
@@ -285,8 +284,31 @@ bool xtreme_app_scene_misc_screen_on_event(void* context, SceneManagerEvent even
|
||||
app->save_backlight = true;
|
||||
notification_message(app->notification, &sequence_display_backlight_on);
|
||||
rgb_backlight_reconfigure(xtreme_settings.rgb_backlight);
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
scene_manager_next_scene(app->scene_manager, XtremeAppSceneMiscScreen);
|
||||
variable_item_set_current_value_text(
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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_it_t it;
|
||||
FrequencyList_it(it, app->subghz_hopper_freqs);
|
||||
size_t removed = 0;
|
||||
while(!FrequencyList_end_p(it)) {
|
||||
if(*FrequencyList_ref(it) == value) {
|
||||
FrequencyList_remove(app->subghz_hopper_freqs, it);
|
||||
removed++;
|
||||
} else {
|
||||
FrequencyList_next(it);
|
||||
}
|
||||
}
|
||||
app->save_subghz_freqs = true;
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
scene_manager_next_scene(app->scene_manager, XtremeAppSceneProtocolsFreqsHopper);
|
||||
VariableItem* item =
|
||||
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;
|
||||
case VarItemListIndexAddHopperFreq:
|
||||
scene_manager_set_scene_state(
|
||||
|
||||
@@ -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_it_t it;
|
||||
FrequencyList_it(it, app->subghz_static_freqs);
|
||||
size_t removed = 0;
|
||||
while(!FrequencyList_end_p(it)) {
|
||||
if(*FrequencyList_ref(it) == value) {
|
||||
FrequencyList_remove(app->subghz_static_freqs, it);
|
||||
removed++;
|
||||
} else {
|
||||
FrequencyList_next(it);
|
||||
}
|
||||
}
|
||||
app->save_subghz_freqs = true;
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
scene_manager_next_scene(app->scene_manager, XtremeAppSceneProtocolsFreqsStatic);
|
||||
VariableItem* item =
|
||||
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;
|
||||
case VarItemListIndexAddStaticFreq:
|
||||
scene_manager_set_scene_state(
|
||||
|
||||
Reference in New Issue
Block a user