From f98d2d38206243100ac3a4273dadb826c2e54242 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Tue, 3 Nov 2026 17:11:22 +0100 Subject: [PATCH] Generator: PRESET menu; a loaded preset opens the menu of its mode, a generator preset starts with the output off (issue #98) --- ui.c | 22 +++++++++++++++++++++- vna_browser.c | 7 +++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/ui.c b/ui.c index e38ee8b..7c27be8 100644 --- a/ui.c +++ b/ui.c @@ -2200,6 +2200,23 @@ static UI_FUNCTION_ADV_CALLBACK(menu_mode_acb) redraw_request |= REDRAW_CAL_STATUS; } +// After a preset load: a generator preset starts with the output off, a mode change shows the menu of the new mode +static void menu_preset_loaded(int old_mode) +{ + bool output = MODE_OUTPUT(setting.mode); + if (output) + setting.mute = true; + if (setting.mode == old_mode) { + menu_move_back(!output); // a generator returns to its form menu + return; + } + menu_move_top(); + if (output) + menu_push_submenu(setting.mode == M_GENLOW ? menu_lowoutputmode : menu_highoutputmode); + else + ui_mode_normal(); +} + static UI_FUNCTION_ADV_CALLBACK(menu_load_preset_acb) { (void)item; @@ -2216,11 +2233,12 @@ static UI_FUNCTION_ADV_CALLBACK(menu_load_preset_acb) plot_printf(b->text, sizeof(b->text), "EMPTY %d", (int)data); return; } + int old_mode = setting.mode; if (caldata_recall(data) == -1) { if (data == 0) reset_settings(setting.mode); // Restore factory defaults } - menu_move_back(true); + menu_preset_loaded(old_mode); } static UI_FUNCTION_ADV_CALLBACK(menu_store_preset_acb) @@ -4758,6 +4776,7 @@ const menuitem_t menu_lowoutputmode[] = { #ifdef TINYSA4 { MT_FORM | MT_ADV_CALLBACK, 255, "OUTPUT: %s", menu_lowoutput_settings_acb}, #endif + { MT_FORM | MT_SUBMENU, 0, "PRESET", menu_load_preset}, { MT_FORM | MT_CANCEL, 0, "MODE", NULL }, { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; @@ -4775,6 +4794,7 @@ const menuitem_t menu_highoutputmode[] = { #ifdef TINYSA4 { MT_FORM | MT_SUBMENU, 255, S_RARROW" Settings", menu_settings3}, #endif + { MT_FORM | MT_SUBMENU, 0, "PRESET", menu_load_preset}, { MT_FORM | MT_CANCEL, 0, "MODE", NULL }, { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; diff --git a/vna_browser.c b/vna_browser.c index 2b4605a..12d4ea7 100644 --- a/vna_browser.c +++ b/vna_browser.c @@ -468,7 +468,14 @@ static void browser_key_press(int key) { break; case FILE_BUTTON_FILE: // Open or delete file default: + { + int old_mode = setting.mode; browser_open_file(key - FILE_BUTTON_FILE + (current_page - 1) * FILES_PER_PAGE); + if (!sel_mode && keypad_mode == FMT_PRS_FILE) { + menu_preset_loaded(old_mode); + return; + } + } if (sel_mode) { file_count = 0; // Reeset file count (recalculate on draw page) selection = -1; // Reset delection