Store 1-4: prefill the preset name keypad with the active preset's name

Report: after PRESET > LOAD FROM SD and STORE > STORE 1 the name keypad
opened empty, and ENTER on an empty name kept the name stored inside the
.prs file (often the old name of the slot), so the user had to look up
and retype the name of the file they had just loaded.

The keypad now starts with the name of the active preset, the same way
STORE > SD already defaults to the file the preset was loaded from:
- loaded from SD: the file name without ".prs"
- otherwise: setting.preset_name, e.g. of a recalled slot
cut to PRESET_NAME_LENGTH - 1 characters so the keypad shows what the
slot stores. An unnamed preset still opens an empty keypad. A remote
"menu" invoke ignores the default as before (ui_process_keypad).

Tested on a ZS405 (HW V0.4.5.1): an unnamed preset opens empty, a
recalled slot "RESR1" offers RESR1, and with sd_preset_path set through
the ST-Link (this unit's SD card does not mount) "FMBAND.prs" offers
FMBAND and "AIRBAND_118.prs" offers AIRBAND_1; ENTER stores the slot
under the offered name. ULTRA +68 bytes, BASIC builds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
copilot/add-multi-platform-rf-scan-exports
erikkaashoek 2 weeks ago
parent 2e6cd0cd7d
commit 68826ff69e

19
ui.c

@ -109,7 +109,7 @@ static bool keypad_text_preset = false;
// Set while handling a keypad key that was held down longer than a short tap
static bool keypad_long_press = false;
#ifdef __SD_FILE_BROWSER__
#if defined(__SD_FILE_BROWSER__) || defined(TINYSA4)
// Preset the keypad input with the first len characters of text
static void ui_preset_keypad_text(const char *text, int len)
{
@ -2250,6 +2250,23 @@ static UI_FUNCTION_ADV_CALLBACK(menu_store_preset_acb)
}
#ifdef TINYSA4
else {
// Offer the name of the active preset, so a single ENTER keeps it: the SD file
// it was loaded from, else the name it was stored under
const char *name = setting.preset_name;
int len = strlen(name);
#ifdef __SD_FILE_BROWSER__
if (sd_preset_path[0]) {
name = sd_preset_path;
len = strlen(name);
int ext = sizeof(".prs") - 1;
if (len > ext && name[len - ext] == '.')
len -= ext;
}
#endif
if (len > PRESET_NAME_LENGTH - 1) // show only what the slot can hold
len = PRESET_NAME_LENGTH - 1;
if (len > 0)
ui_preset_keypad_text(name, len);
kp_help_text = "Preset name";
ui_mode_keypad(KM_PRESET_NAME);
}

Loading…
Cancel
Save

Powered by TurnKey Linux.