diff --git a/nanovna.h b/nanovna.h index 94199d0..43022bc 100644 --- a/nanovna.h +++ b/nanovna.h @@ -1186,7 +1186,9 @@ void spi_init(void); #ifdef __BANDS__ #define BANDS_MAX 8 +#define BAND_NAME_SIZE 9 typedef struct { + char name[BAND_NAME_SIZE]; bool enabled; freq_t start; freq_t end; @@ -1336,6 +1338,8 @@ typedef struct setting bool increased_R; bool mixer_output; uint32_t interval; +#define PRESET_NAME_LENGTH 10 + char preset_name[PRESET_NAME_LENGTH]; #endif int64_t test_argument; // used for tests uint32_t checksum; // must be last and at 4 byte boundary diff --git a/plot.c b/plot.c index 271f4ca..09d659f 100644 --- a/plot.c +++ b/plot.c @@ -1918,10 +1918,14 @@ draw_frequencies(void) int b = getBand(idx); while (b == getBand(++next_idx)); // plot_printf(buf1, sizeof(buf1), "%.3QHz-%.3QHz %5.1QHz/", setting.bands[b].start + (setting.frequency_offset - FREQUENCY_SHIFT), setting.bands[b].end + (setting.frequency_offset - FREQUENCY_SHIFT), grid_span); - if (next_idx - idx < sweep_points/4-20) - plot_printf(buf1, sizeof(buf1), "%.3QHz", (setting.bands[b].start+setting.bands[b].end)/2 + (setting.frequency_offset - FREQUENCY_SHIFT), grid_span); - else - plot_printf(buf1, sizeof(buf1), "%.3QHz %5.1QHz/", setting.bands[b].start + (setting.frequency_offset - FREQUENCY_SHIFT), grid_span); + if (setting.bands[b].name[0]) + plot_printf(buf1, sizeof(buf1), "%s", setting.bands[b].name); + else { + if (next_idx - idx < sweep_points/4-20) + plot_printf(buf1, sizeof(buf1), "%.3QHz", (setting.bands[b].start+setting.bands[b].end)/2 + (setting.frequency_offset - FREQUENCY_SHIFT), grid_span); + else + plot_printf(buf1, sizeof(buf1), "%.3QHz %5.1QHz/", setting.bands[b].start + (setting.frequency_offset - FREQUENCY_SHIFT), grid_span); + } ili9341_drawstring(buf1, FREQUENCIES_XPOS1+idx, FREQUENCIES_YPOS); idx = next_idx; } while (idx < sweep_points - 10); diff --git a/sa_cmd.c b/sa_cmd.c index 2e11737..04d5987 100644 --- a/sa_cmd.c +++ b/sa_cmd.c @@ -1277,7 +1277,7 @@ VNA_SHELL_FUNCTION(cmd_scanraw) buf[idx++] = '{'; for (uint32_t i = 0; i < points; i++) { int val = perform(false, i, start +(freq_t)(f_step * i), false) + float_TO_PURE_RSSI(config.ext_zero_level); - if (operation_requested || SDU1.config->usbp->state != USB_ACTIVE) // break on operation in perform + if (operation_requested || ((uint32_t)shell_stream == (uint32_t)&SDU1 && SDU1.config->usbp->state != USB_ACTIVE)) // break on operation in perform break; buf[idx++] = 'x'; buf[idx++] = (uint8_t)(val & 0xFF); diff --git a/sa_core.c b/sa_core.c index b8eafe2..5382756 100644 --- a/sa_core.c +++ b/sa_core.c @@ -8037,7 +8037,7 @@ void calibrate(void) #ifdef TINYSA4 || (calibration_stage == CS_LNA && peakLevel < -40) || (calibration_stage == CS_ULTRA && peakLevel < -40) - || (calibration_stage == CS_DIRECT_LNA && peakLevel < direct_level - 20) + || (calibration_stage == CS_DIRECT_LNA && peakLevel < direct_level - 50) #endif ) { #ifdef TINYSA4 diff --git a/ui.c b/ui.c index da0bb95..e25c45f 100644 --- a/ui.c +++ b/ui.c @@ -1376,7 +1376,7 @@ enum { KM_LIMIT_FREQ, KM_LIMIT_LEVEL, #endif #ifdef __BANDS__ - KM_BAND_START, KM_BAND_END, KM_BAND_CENTER, KM_BAND_SPAN, KM_BAND_LEVEL, + KM_BAND_START, KM_BAND_END, KM_BAND_CENTER, KM_BAND_SPAN, KM_BAND_LEVEL,KM_BAND_NAME, #endif KM_MARKER_TIME, // #35 @@ -1393,6 +1393,7 @@ enum { KM_RTC_DATE, KM_RTC_TIME, KM_INTERVAL, + KM_PRESET_NAME, #endif #endif KM_CODE, @@ -1468,6 +1469,7 @@ static const struct { [KM_BAND_CENTER] = {keypads_freq , "CENTER\nFREQ"}, // KM_BAND_CENTER [KM_BAND_SPAN] = {keypads_freq , "SPAN\nFREQ"}, // KM_BAND_SPAN [KM_BAND_LEVEL] = {keypads_plusmin_unit , "LEVEL"}, // KM_BAND_LEVEL +[KM_BAND_NAME] = {keypads_text , "NAME"}, // KM_BAND_NAME #endif [KM_MARKER_TIME] = {keypads_time , "MARKER\nTIME"}, // KM_MARKER_TIME [KM_VAR] = {keypads_freq , "JOG\nSTEP"}, // jog step @@ -1484,6 +1486,7 @@ static const struct { [KM_RTC_TIME] = {keypads_positive , "SET TIME\n HHMMSS"}, // Time [KM_INTERVAL] = {keypads_positive , "SET INTERVAL\n HHMMSS"}, // Interval #endif +[KM_PRESET_NAME] = {keypads_text , "NAME"}, // KM_PRESET_NAME #endif [KM_CODE] = {keypads_positive , "CODE"}, // KM_CODE #ifdef __USE_SD_CARD__ @@ -2120,9 +2123,14 @@ static UI_FUNCTION_ADV_CALLBACK(menu_load_preset_acb) (void)item; if(b){ setting_t *p = caldata_pointer(data); - if (p) - plot_printf(b->text, sizeof(b->text), "%.6FHz\n%.6FHz", (float)p->frequency0, (float)p->frequency1); - else + if (p) { +#ifdef TINYSA4 + if (p->preset_name[0]) + plot_printf(b->text, sizeof(b->text), "LOAD\n\b%s", p->preset_name); + else +#endif + plot_printf(b->text, sizeof(b->text), "%.6FHz\n%.6FHz", (float)p->frequency0, (float)p->frequency1); + } else plot_printf(b->text, sizeof(b->text), "EMPTY %d", (int)data); return; } @@ -2139,9 +2147,14 @@ static UI_FUNCTION_ADV_CALLBACK(menu_store_preset_acb) if(b){ #if 1 setting_t *p = caldata_pointer(data); - if (p) - plot_printf(b->text, sizeof(b->text), "%.6FHz\n%.6FHz", (float)p->frequency0, (float)p->frequency1); - else + if (p) { +#ifdef TINYSA4 + if (p->preset_name[0]) + plot_printf(b->text, sizeof(b->text), "STORE\n\b%s", p->preset_name); + else +#endif + plot_printf(b->text, sizeof(b->text), "%.6FHz\n%.6FHz", (float)p->frequency0, (float)p->frequency1); + } else plot_printf(b->text, sizeof(b->text), "STORE %d", (int)data); #else b->param_1.u = data; @@ -2155,6 +2168,12 @@ static UI_FUNCTION_ADV_CALLBACK(menu_store_preset_acb) if (data == 101) clear_backup(); data = 0; } +#ifdef TINYSA4 + else { + kp_help_text = "Preset name"; + ui_mode_keypad(KM_PRESET_NAME); + } +#endif caldata_save(data); menu_move_back(true); } @@ -2826,6 +2845,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb) setting.bands[i].start = fundamental*(i+1) - half_span; setting.bands[i].end = fundamental*(i+1) + half_span; setting.bands[i].enabled = true; + setting.bands[i].name[0] = 0; } setting.multi_band = true; setting.multi_trace = false; @@ -3440,7 +3460,10 @@ static UI_FUNCTION_ADV_CALLBACK(menu_band_select_acb) for (int i=0;iicon = (setting.bands[data].enabled?BUTTON_ICON_CHECK:BUTTON_ICON_NOCHECK) ; - plot_printf(b->text, sizeof(b->text), "%.6FHz\n%.6FHz", (float)setting.bands[data].start, (float)setting.bands[data].end); + if (setting.bands[data].name[0]) + plot_printf(b->text, sizeof(b->text), "%s", setting.bands[data].name); + else + plot_printf(b->text, sizeof(b->text), "%.6FHz\n%.6FHz", (float)setting.bands[data].start, (float)setting.bands[data].end); reset_band(); return; } @@ -3641,6 +3664,7 @@ static UI_FUNCTION_CALLBACK(menu_BAND_disable_cb) if (active_band menu_back }; @@ -5475,6 +5500,12 @@ static void fetch_numeric_target(uint8_t mode) uistat.value = value(setting.bands[active_band].level); plot_printf(uistat.text, sizeof uistat.text, "%.1f", uistat.value); break; + case KM_BAND_NAME: + plot_printf(uistat.text, sizeof uistat.text, "%s", setting.bands[active_band].name); + break; + case KM_PRESET_NAME: + plot_printf(uistat.text, sizeof uistat.text, "%s", setting.preset_name); + break; #endif case KM_NOISE: uistat.value = setting.noise; @@ -5766,6 +5797,11 @@ set_numeric_value(void) update_frequencies(); dirty = true; update_grid(); +// BANDs_update(); + break; + case KM_BAND_NAME: + plot_printf(setting.bands[active_band].name, sizeof setting.bands[active_band].name, "%s", kp_buf); + dirty = true; // BANDs_update(); break; #endif @@ -5836,6 +5872,9 @@ set_numeric_value(void) case KM_DEPTH: set_depth((int)uistat.value); break; + case KM_PRESET_NAME: + plot_printf(setting.preset_name, sizeof setting.preset_name, "%s", kp_buf); + break; #endif case KM_VAR: setting.frequency_var = uistat.freq_value; @@ -7521,7 +7560,10 @@ static int full_keypad_click(int c, int kp_index) { if (c == S_ENTER[0]) { // Enter - return kp_index == 0 ? KP_CANCEL : KP_DONE; + if (kp_index == 0) + return KP_CANCEL; + set_numeric_value(); // Also for text values + return KP_DONE; } if (c == S_LARROW[0]) { // Backspace if (kp_index == 0)