diff --git a/main.c b/main.c index 03ee392..b9d31d7 100644 --- a/main.c +++ b/main.c @@ -955,12 +955,7 @@ VNA_SHELL_FUNCTION(cmd_text) { if (argc!= 1) return; - char *p = argv[0]; - char *t = kp_buf; - while (*p) { - *t++ = *p++; - } - *t = 0; + ui_set_keypad_text(argv[0]); uistat.value = my_atof(kp_buf); uistat.freq_value = my_atoui(kp_buf); set_numeric_value(); diff --git a/nanovna.h b/nanovna.h index 18fd053..5f1485a 100644 --- a/nanovna.h +++ b/nanovna.h @@ -1593,6 +1593,7 @@ extern const char * const averageText[]; extern uint8_t menu_current_level; void menu_invoke(int item); extern char kp_buf[]; +void ui_set_keypad_text(const char *text); void set_numeric_value(void); void ui_mode_normal(void); diff --git a/ui.c b/ui.c index b2847fd..e163aee 100644 --- a/ui.c +++ b/ui.c @@ -96,6 +96,12 @@ char kp_buf[NUMINPUT_LEN+2]; // !!!!!! WARNING size must be + 2 from NUMINPU #else char kp_buf[TXTINPUT_LEN+1]; // !!!!!! WARNING size must be + 2 from NUMINPUT_LEN or TXTINPUT_LEN + 1 #endif + +void ui_set_keypad_text(const char *text) +{ + plot_printf(kp_buf, sizeof(kp_buf), "%s", text); +} + static uint8_t ui_mode = UI_NORMAL; static uint8_t keypad_mode; static char *kp_help_text = NULL;