diff --git a/changelog.txt b/changelog.txt index f756ed3..9b6ddf9 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,10 @@ +V1.4321 2026-11-12 For all tinySA models +- Console: "ui off" stops all drawing on the screen while a PC is in control, so commands no longer wait for the screen to be redrawn (e.g. 2 ms instead of about 120 ms after a setting). The screen shows "Remote only mode. Touch screen to enable UI", "ui off "text"" adds a line under it, e.g. to tell the tracking generator from the analyzer when a PC uses two tinySA. A touch or a jog press gives the UI back, as do "ui on", unplugging USB, USB DISK mode and the commands that need the user (selftest, touchcal, touchtest, menu); the console then sends "ui on" before the next text reply. While the UI is off, messages such as errors go to the console. "ui" shows the state. It is not stored in the config or in presets and stays off when the mode changes (Ultra only) +- Console: "scanraw" no longer sets up the hardware again for every scan, only the RBW and timing of its frequency step: a one point scanraw takes about 2 ms instead of 86 ms on the tinySA basic, and the screen is no longer redrawn after each scanraw. "scanraw {f} {f} 1" (one point at one frequency) takes 2 ms instead of 93 ms on the tinySA basic and 6 ms instead of 40 ms on the Ultra +- Console: after a zero span "scanraw" with fewer points than the sweep, or an aborted zero span sweep, the next scanraw or sweep returned the remaining zero span samples for its first points, so a signal could be missing +- STORE TINYSA NF only stores the noise figure of MEASURE TINYSA NF: after VALIDATE TINYSA NF or MEASURE AMP NF it stored a wrong value (Ultra only) +- Leaving USB DISK mode in the signal generator shows the generator menu again, the screen stayed empty (Ultra only) + V1.4311 2026-11-11 For all tinySA models - Console: "measure {mode} [value]..." starts a measurement of the MEASURE menu, the values the menu asks for are the arguments, e.g. "measure channel_power 5800M 20M". Modes: off|harmonic|oip3|phase_noise|snr|3db_width|occupied_width|am|fm|thd|channel_power|linear, on the Ultra also nf_tinysa|nf_store|nf_validate|nf_amp - Console: "recall defaults" loads the factory settings in low input mode, as PRESET > LOAD DEFAULTS, but does not store them as the startup preset diff --git a/main.c b/main.c index de5e6a1..5b16396 100644 --- a/main.c +++ b/main.c @@ -63,7 +63,24 @@ char shell_line[VNA_SHELL_MAX_LENGTH]; char *shell_args[VNA_SHELL_MAX_ARGUMENTS + 1]; uint16_t shell_nargs; static volatile vna_shellcmd_t shell_function = 0; -static volatile bool shell_function_ui; // shell_function may also run in a UI wait loop (CMD_RUN_IN_UI) +static volatile uint8_t shell_function_flags; // CMD_xxx of shell_function: CMD_RUN_IN_UI also runs it in a UI wait loop + +// Some commands can executed only in sweep thread, not in main cycle +#define CMD_WAIT_MUTEX 1 +#define CMD_RUN_IN_LOAD 2 +#define CMD_RUN_IN_UI 4 +#ifdef __USE_USB_MSC__ +#define CMD_DISK_OK 8 // allowed in USB DISK mode, does not use SPI1 or spi_buffer +#else +#define CMD_DISK_OK 0 +#endif +#ifdef __UI_OFF__ +#define CMD_UI_ON 16 // needs the user at the tinySA: ui on before it runs (with CMD_WAIT_MUTEX) +#define CMD_BINARY 32 // binary reply: no "ui on" notice in front of it +#else +#define CMD_UI_ON 0 +#define CMD_BINARY 0 +#endif //#define ENABLED_DUMP // Allow get threads debug info @@ -90,6 +107,7 @@ void update_frequencies(void); static void set_frequencies(freq_t start, freq_t stop, uint16_t points); static bool sweep(bool break_on_operation); static long_t my_atoi(const char *p); +static bool shell_check_connect(void); uint8_t sweep_mode = SWEEP_ENABLE; uint16_t sweep_once_count = 1; @@ -152,11 +170,12 @@ void shell_run_pending(bool ui_wait) { chSysLock(); vna_shellcmd_t local_func = shell_function; - if (ui_wait && !shell_function_ui) + uint8_t local_flags = shell_function_flags; + if (ui_wait && !(local_flags & CMD_RUN_IN_UI)) local_func = 0; else { shell_function = 0; - shell_function_ui = false; + shell_function_flags = 0; // The shell sets OP_CONSOLE together with shell_function, a request without a // command (direct command, timed out command) has done its job: the sweep stopped operation_requested &= ~OP_CONSOLE; @@ -166,6 +185,10 @@ void shell_run_pending(bool ui_wait) if (local_func) { if (!ui_wait) // a UI wait loop keeps a pending touch or lever event operation_requested = OP_NONE; // otherwise commands will be aborted +#ifdef __UI_OFF__ + if (local_flags & CMD_UI_ON) // the command needs the user at the tinySA + set_ui(true); +#endif local_func(shell_nargs - 1, &shell_args[1]); if (ui_wait || operation_requested == OP_NONE) // Don't prompt if aborted @@ -315,6 +338,14 @@ static THD_FUNCTION(Thread1, arg) usb_disk_mode(); } #endif +#ifdef __UI_OFF__ + // An unplugged tinySA must not stay blind. The USB suspend also stops the endless sweep of + // an output mode (usbcfg.c), else this would only run after the next touch or command. + if (ui_off && !shell_check_connect()) { + set_ui(true); + ui_on_notice = false; // no PC to tell + } +#endif // START_PROFILE // Process UI inputs if (!(sweep_mode & SWEEP_SELFTEST)) @@ -1039,6 +1070,26 @@ VNA_SHELL_FUNCTION(cmd_release) #endif +#ifdef __UI_OFF__ +VNA_SHELL_FUNCTION(cmd_ui) +{ + if (argc == 0) { + shell_printf("ui %s" VNA_SHELL_NEWLINE_STR, ui_off ? "off" : "on"); + return; + } + int m = get_str_index(argv[0], "off|on"); + if (m < 0 || argc > 2 || (argc == 2 && m)) { + usage_printf("ui [off [\"text\"]|on]" VNA_SHELL_NEWLINE_STR); + return; + } + if (argc == 2) + set_ui_text(argv[1]); // a line under the message, e.g. "Tracking generator" + else + set_ui(m); + ui_on_notice = false; // the PC asked for it +} +#endif + #ifdef TINYSA4 // Row y of the screen for a capture, y counting up from 0: the screen is read as one DMA stream, // the next row into the other half of buf (2 * LCD_WIDTH pixels) while the caller uses row y. @@ -2758,15 +2809,6 @@ typedef struct { } VNAShellCommand; #pragma pack(pop) -// Some commands can executed only in sweep thread, not in main cycle -#define CMD_WAIT_MUTEX 1 -#define CMD_RUN_IN_LOAD 2 -#define CMD_RUN_IN_UI 4 -#ifdef __USE_USB_MSC__ -#define CMD_DISK_OK 8 // allowed in USB DISK mode, does not use SPI1 or spi_buffer -#else -#define CMD_DISK_OK 0 -#endif static const VNAShellCommand commands[] = { {"version" , cmd_version , CMD_DISK_OK}, @@ -2794,13 +2836,13 @@ static const VNAShellCommand commands[] = #ifdef TINYSA4 {"hop" , cmd_hop , CMD_WAIT_MUTEX}, #endif - {"scanraw" , cmd_scanraw , CMD_WAIT_MUTEX}, + {"scanraw" , cmd_scanraw , CMD_WAIT_MUTEX | CMD_BINARY}, {"abort" , cmd_abort , 0}, {"zero" , cmd_zero , CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD}, // Will set the scanraw measured value offset (128 or 174) {"sweep" , cmd_sweep , CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD}, {"test" , cmd_test , 0}, - {"touchcal" , cmd_touchcal , CMD_WAIT_MUTEX}, - {"touchtest" , cmd_touchtest , CMD_WAIT_MUTEX}, + {"touchcal" , cmd_touchcal , CMD_WAIT_MUTEX | CMD_UI_ON}, + {"touchtest" , cmd_touchtest , CMD_WAIT_MUTEX | CMD_UI_ON}, {"pause" , cmd_pause , CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD}, #ifdef TINYSA4 {"restart" , cmd_restart , CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD}, @@ -2825,11 +2867,14 @@ static const VNAShellCommand commands[] = {"usart" , cmd_usart , CMD_WAIT_MUTEX}, {"usart_cfg" , cmd_usart_cfg , CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD}, #endif - {"capture" , cmd_capture , CMD_WAIT_MUTEX | CMD_RUN_IN_UI}, + {"capture" , cmd_capture , CMD_WAIT_MUTEX | CMD_RUN_IN_UI | CMD_BINARY}, #ifdef __REMOTE_DESKTOP__ {"refresh" , cmd_refresh , CMD_DISK_OK}, {"touch" , cmd_touch , CMD_DISK_OK}, {"release" , cmd_release , CMD_DISK_OK}, +#endif +#ifdef __UI_OFF__ + {"ui" , cmd_ui , CMD_WAIT_MUTEX}, // draws: runs in the sweep thread #endif {"vbat" , cmd_vbat , CMD_WAIT_MUTEX}, // Uses same adc as touch!!!!! #ifdef ENABLE_VBAT_OFFSET_COMMAND @@ -2876,15 +2921,19 @@ static const VNAShellCommand commands[] = { "ext_gain", cmd_ext_gain, CMD_RUN_IN_LOAD}, { "output", cmd_output, CMD_RUN_IN_LOAD }, { "deviceid", cmd_deviceid, CMD_RUN_IN_LOAD }, +#ifdef __UI_OFF__ + { "selftest", cmd_selftest, CMD_WAIT_MUTEX | CMD_UI_ON }, // ui on: in the sweep thread +#else { "selftest", cmd_selftest, 0 }, +#endif { "correction", cmd_correction, CMD_RUN_IN_LOAD }, { "calc", cmd_calc, CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD}, - { "menu", cmd_menu, CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD }, + { "menu", cmd_menu, CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD | CMD_UI_ON }, { "text", cmd_text, CMD_RUN_IN_LOAD}, { "remark", cmd_remark, CMD_RUN_IN_LOAD }, #ifdef ENABLE_SD_CARD_CMD { "sd_list", cmd_sd_list, CMD_WAIT_MUTEX }, - { "sd_read", cmd_sd_read, CMD_WAIT_MUTEX }, + { "sd_read", cmd_sd_read, CMD_WAIT_MUTEX | CMD_BINARY }, { "sd_delete", cmd_sd_delete, CMD_WAIT_MUTEX }, #endif #ifdef __USE_USB_MSC__ @@ -3200,6 +3249,15 @@ static void VNAShell_executeLine(char *line) { // Execute line const VNAShellCommand *scp = VNAShell_parceLine(line); +#ifdef __UI_OFF__ + // The UI came back without "ui on" (touch, jog, a command that needs the user): tell the PC + // here, in this thread before the reply, so it never splits other console output. Not in + // front of binary data, that would shift it: then before the next text reply. + if (ui_on_notice && !(scp && (scp->flags & CMD_BINARY))) { + ui_on_notice = false; + shell_printf("ui on" VNA_SHELL_NEWLINE_STR); + } +#endif if (scp) { uint16_t cmd_flag = scp->flags; #ifdef __USE_USB_MSC__ @@ -3232,7 +3290,7 @@ static void VNAShell_executeLine(char *line) } if (cmd_flag & CMD_WAIT_MUTEX) { chSysLock(); - shell_function_ui = cmd_flag & CMD_RUN_IN_UI; + shell_function_flags = cmd_flag; shell_function = scp->sc_function; operation_requested|=OP_CONSOLE; // this will abort current sweep to give priority to the new request chSysUnlock(); diff --git a/nanovna.h b/nanovna.h index e49a30f..8aba95c 100644 --- a/nanovna.h +++ b/nanovna.h @@ -119,6 +119,7 @@ #define __VBW__ #define __SWEEP_RESTART__ #define __BURST__ // Burst modulation: TIM8 on PB9 keys the OOK of the Si4468 (GPIO1, normally CTS) +#define __UI_OFF__ // ui off: no LCD drawing while a PC is in control, a touch gives the UI back // #define DIRECT_CORRECTION // Not enough space for config in one flash page. #define DB_PER_DEGREE_BELOW 0.056 #define DB_PER_DEGREE_ABOVE 0.069 @@ -419,7 +420,9 @@ extern freq_t ultra_start; //extern bool ultra; #endif #ifdef TINYSA4 -extern float measured_noise_figure; +#ifdef __NOISE_FIGURE__ +float noise_figure(void); +#endif extern float *drive_dBm; extern bool level_error; extern bool depth_error; @@ -1672,6 +1675,15 @@ void refresh_sweep_menu(int i); void save_to_sd(int mask); void drawMessageBox(const char *header, char *text, uint32_t delay); bool isFullScreenMode(void); +#ifdef __UI_OFF__ +extern bool ui_off; // the screen shows the ui off message, the drawing functions return at once +extern volatile bool ui_on_notice; +void set_ui(bool on); +void set_ui_text(char *text); +#define UI_OFF ui_off +#else +#define UI_OFF false +#endif int btn_side(void); extern int si5351_available; diff --git a/plot.c b/plot.c index 9348ada..5230f8d 100644 --- a/plot.c +++ b/plot.c @@ -404,6 +404,24 @@ marker_to_value(const int i) return(v); } +#ifdef __NOISE_FIGURE__ +// Noise figure of marker 0 in the NF measurements, for the marker info and for nf_store +float noise_figure(void) +{ + float nf = marker_to_value(0) + 173.93f - nf_gain; // measured noise figure at 20C + if (setting.measurement != M_NF_TINYSA) { + float mnf = expf(nf/10.0f * logf(10.0f)); // measure noise factor + float tnf = expf(config.noise_figure/10.0f * logf(10.0f)); // tinySA noise factor + float amp_gain = expf(nf_gain/10.0f * logf(10.0f)); + float anf = mnf - (tnf - 1.0f)/amp_gain; + nf = 10.0f*logf(anf)/logf(10.0f); + } + // powf(10,x) = expf(x * logf(10)) + // log10f(x) = logf(x)/logf(10) + return nf; +} +#endif + #ifdef TINYSA3 float sa_sqrtf(const float x) { @@ -1391,6 +1409,7 @@ draw_cell(int m, int n) static void draw_all_cells(bool flush_markmap) { + if (UI_OFF) return; // redraw_marker(), redraw_trigger(): draw_all() is gated already int m, n; // START_PROFILE for (n = 0; n < (area_height+CELLHEIGHT-1) / CELLHEIGHT; n++){ @@ -1941,34 +1960,21 @@ static void cell_draw_marker_info(int x0, int y0) } #ifdef __NOISE_FIGURE__ } else if (i>=2 && (setting.measurement == M_NF_TINYSA || setting.measurement == M_NF_VALIDATE || setting.measurement == M_NF_AMPLIFIER) && markers[0].enabled) { - float aNP = 0; - aNP = marker_to_value(0); - measured_noise_figure = aNP + 173.93 - nf_gain; // measured noise figure at 20C - if (setting.measurement != M_NF_TINYSA) { - float mnf = expf(measured_noise_figure/10.0 * logf(10)); // measure noise factor - float tnf = expf(config.noise_figure/10.0 * logf(10.0)); // tinySA noise factor - float amp_gain = expf(nf_gain/10.0 * logf(10.0)); - float anf = mnf - (tnf - 1.0)/amp_gain; - measured_noise_figure = 10.0*logf(anf)/logf(10.0); - } - // powf(10,x) = expf(x * logf(10)) - // log10f(x) = logf(x)/logf(10) - - + float nf = noise_figure(); ili9341_set_foreground(marker_color(0)); // j = 1; int xpos = 1 + (j%2)*(WIDTH/2) + CELLOFFSETX - x0; int ypos = 1 + (j/2)*(16) - y0; if (setting.measurement == M_NF_TINYSA) { - cell_printf(xpos, ypos, FONT_b"TINYSA NF: %4.1f", measured_noise_figure); + cell_printf(xpos, ypos, FONT_b"TINYSA NF: %4.1f", nf); } else { if (setting.measurement == M_NF_VALIDATE) - cell_printf(xpos, ypos, FONT_b"TINYSA NF ERROR: %4.1f", measured_noise_figure); + cell_printf(xpos, ypos, FONT_b"TINYSA NF ERROR: %4.1f", nf); else - cell_printf(xpos, ypos, FONT_b"GAIN: %4.1fdB NF: %4.1f", nf_gain, measured_noise_figure); + cell_printf(xpos, ypos, FONT_b"GAIN: %4.1fdB NF: %4.1f", nf_gain, nf); } #ifdef __LEVEL_METER__ - plot_printf(level_text, sizeof(level_text), "%4.1f", measured_noise_figure); + plot_printf(level_text, sizeof(level_text), "%4.1f", nf); #endif break; @@ -2051,7 +2057,7 @@ draw_frequencies(void) { char buf1[40]; char buf2[32]; - if (MODE_OUTPUT(setting.mode)) // No frequencies during output + if (MODE_OUTPUT(setting.mode) || UI_OFF) // No frequencies during output or ui off return; if (current_menu_is_form() && !in_selftest) return; @@ -2207,6 +2213,7 @@ request_to_redraw_grid(void) void redraw_frame(void) { + if (UI_OFF) return; ili9341_set_background(LCD_BG_COLOR); ili9341_clear_screen(); draw_frequencies(); @@ -2473,7 +2480,7 @@ set_level_meter_or_waterfall(void) else graph_bottom = NO_WATERFALL; _grid_y = graph_bottom / NGRIDY; area_height = AREA_HEIGHT_NORMAL; - if (setting.waterfall != W_OFF || setting.level_meter){ + if ((setting.waterfall != W_OFF || setting.level_meter) && !UI_OFF){ ili9341_set_background(LCD_BG_COLOR); ili9341_fill(OFFSETX, graph_bottom, LCD_WIDTH - OFFSETX, CHART_BOTTOM - graph_bottom); } diff --git a/sa_cmd.c b/sa_cmd.c index 8d462fc..6def7ca 100644 --- a/sa_cmd.c +++ b/sa_cmd.c @@ -426,9 +426,25 @@ VNA_SHELL_FUNCTION(cmd_level) set_level(f); } +#ifdef __UI_OFF__ +// The actual RBW and sweep time of changed settings. While paused the cal status calculates +// them, but with the UI off it does not draw. +static void update_actual_values(void) +{ + if (dirty) { + update_rbw(); + calculate_step_delay(); + setting.actual_sweep_time_us = calc_min_sweep_time_us(); + } +} +#endif + VNA_SHELL_FUNCTION(cmd_sweeptime) { if (argc != 1 || argv[0][0] == '?') { +#ifdef __UI_OFF__ + update_actual_values(); +#endif usage_printf("sweeptime 0.003..60\r\n%5.3Fs\r\n",((float)setting.actual_sweep_time_us)/ONE_SECOND_TIME); return; } @@ -618,6 +634,9 @@ VNA_SHELL_FUNCTION(cmd_rbw) { if (argc != 1 || argv[0][0] == '?') { usage: +#ifdef __UI_OFF__ + update_actual_values(); +#endif #ifdef TINYSA4 usage_printf("rbw 0.2..850|auto\r\n%.1FHz\r\n", actual_rbw_x10*100.0); #else @@ -1371,14 +1390,24 @@ VNA_SHELL_FUNCTION(cmd_scanraw) freq_t old_step = setting.frequency_step; float f_step = (stop-start)/ points; setting.frequency_step = (freq_t)f_step; + // perform() recalculates for a new frequency step itself. Zero span measures a series of RSSI + // samples at one frequency, which needs a full setup, also for the sweep after it. + bool zero_span = setting.frequency_step == 0; + if (zero_span && points == 1) { // one point as in a sweep: one measurement, auto RBW as in zero span + setting.frequency_step = setting.rbw_x10 ? setting.rbw_x10*50 : 300000; + zero_span = false; + } again: operation_requested = false; - dirty = true; + if (zero_span) + dirty = true; // adc_stop_analog_watchdog(); int oldpos = 0; - ili9341_set_background(LCD_BG_COLOR); - ili9341_fill(OFFSETX, CHART_BOTTOM+1, WIDTH, 1); - ili9341_set_background(LCD_SWEEP_LINE_COLOR); + if (!UI_OFF) { // ui off: no progress bar + ili9341_set_background(LCD_BG_COLOR); + ili9341_fill(OFFSETX, CHART_BOTTOM+1, WIDTH, 1); + ili9341_set_background(LCD_SWEEP_LINE_COLOR); + } #define BUFFER_SIZE 64 uint8_t buf[BUFFER_SIZE]; int idx = 0; @@ -1395,7 +1424,7 @@ again: idx = 0; } int pos = i * (WIDTH+1) / points; - if (pos - oldpos > 8) { + if (pos - oldpos > 8 && !UI_OFF) { ili9341_fill(OFFSETX + oldpos, CHART_BOTTOM+1, pos - oldpos, 1); // update sweep progress bar oldpos = pos; } @@ -1405,10 +1434,13 @@ again: // adc_start_analog_watchdog(); if ((unbuffered & 2) && !operation_requested) goto again; - ili9341_set_background(LCD_BG_COLOR); - ili9341_fill(OFFSETX, CHART_BOTTOM+1, WIDTH, 1); + if (!UI_OFF) { + ili9341_set_background(LCD_BG_COLOR); + ili9341_fill(OFFSETX, CHART_BOTTOM+1, WIDTH, 1); + } setting.frequency_step = old_step; - dirty = true; + if (zero_span) + dirty = true; redraw_request = 0; // disable screen update in this mode } diff --git a/sa_core.c b/sa_core.c index 4d3a8f6..1db339a 100644 --- a/sa_core.c +++ b/sa_core.c @@ -3715,6 +3715,7 @@ bool depth_error = false; #endif +static freq_t setup_frequency_step; // frequency step the first point of perform() was set up for pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) // Measure the RSSI for one frequency, used from sweep and other measurement routines. Must do all HW setup { @@ -3735,7 +3736,11 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) / } #endif TRACE(10); - if (i == 0 && dirty ) { // if first point in scan and dirty + // First point after a change of settings (dirty) or of the frequency step (scanraw, the sweep + // after it): only dirty sets up the hardware, which takes about 80 ms on the tinySA basic + if (i == 0 && (dirty || setting.frequency_step != setup_frequency_step)) { + const bool hw = dirty; + if (hw) { #ifdef __ADF4351__ clear_frequency_cache(); #endif @@ -3749,15 +3754,27 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) / PE4302_Write_Byte((int)(setting.attenuate_x2)); #endif set_calibration_freq(setting.refer); - update_rbw(); - calculate_step_delay(); prev_output_level_dBm = MIN_RSSI_VALUE; // clear cached level setting - // Initialize HW - scandirty = true; // This is the first pass with new settings for (int t=0;t '~') // not in the font + *p = '?'; + w += wFONT_GET_WIDTH(*p); + if (w > LCD_WIDTH) { // only the characters that fit on the screen + *p = 0; + break; + } + } + ui_off = false; // draw the screen again + set_ui(false); + ui_off_line(text, 1); +} +#endif + bool isFullScreenMode(void) { + if (UI_OFF) return true; // draw_all() and the sweep progress bar draw nothing #ifdef __SD_FILE_BROWSER__ return ui_mode == UI_BROWSER; #else @@ -1880,8 +1949,6 @@ UI_FUNCTION_CALLBACK(menu_curve_confirm_cb) menu_move_back(false); } -float measured_noise_figure; - #if 0 UI_FUNCTION_CALLBACK(menu_noise_figure_confirm_cb) { @@ -3038,6 +3105,11 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb) return; } menu_move_back(false); +#ifdef __NOISE_FIGURE__ + // Store the NF of a running TINYSA NF measurement: here, before markers_reset(), as the marker + // info would show it (with the UI off nothing draws it) + float nf = (data == M_NF_STORE && setting.measurement == M_NF_TINYSA) ? noise_figure() : 0; +#endif markers_reset(); if ((data != M_OFF && setting.measurement != M_OFF) || data == M_OFF ) @@ -3262,8 +3334,8 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb) nf_gain = 0; goto noise_figure; case M_NF_STORE: - if (measured_noise_figure > 2 && measured_noise_figure < 20) { - config.noise_figure = measured_noise_figure; + if (nf > 2 && nf < 20) { + config.noise_figure = nf; config_save(); data = M_NF_VALIDATE; // Continue to validate goto validate; @@ -4520,6 +4592,9 @@ void usb_disk_mode(void) if ((disk_initialize(0) & STA_NOINIT) || disk_ioctl(0, GET_SECTOR_COUNT, &blocks) != RES_OK || blocks == 0) error = "SD card error"; } +#ifdef __UI_OFF__ + set_ui(true); // this screen needs the user +#endif ili9341_set_foreground(LCD_FG_COLOR); ili9341_set_background(LCD_BG_COLOR); ili9341_clear_screen(); @@ -4565,9 +4640,8 @@ void usb_disk_mode(void) msc_disk_mode = false; touch_wait_release(); dirty = true; // Restore MCU clock and hardware settings on the next sweep - ui_mode_normal(); - redraw_frame(); - request_to_redraw_grid(); + ui_mode_normal(); // the form menu of the output modes stays open + redraw_ui(); } static UI_FUNCTION_CALLBACK(menu_usb_disk_cb) { @@ -6582,6 +6656,7 @@ const char *month[] = { "Jan", "Feb", "Mar","Apr","May","Jun","Jul","Aug","Sep", void draw_cal_status(void) { + if (UI_OFF) return; #define BLEN 7 char buf[BLEN+1]; buf[6]=0; @@ -7163,6 +7238,12 @@ draw_button(uint16_t x, uint16_t y, uint16_t w, uint16_t h, ui_button_t *b) } void drawMessageBox(const char *header, char *text, uint32_t delay){ +#ifdef __UI_OFF__ + if (ui_off) { // the PC in control gets the message, without the delay + shell_printf("%s: %s\r\n", header, text); + return; + } +#endif ui_button_t b; b.bg = LCD_MENU_COLOR; b.fg = LCD_MENU_TEXT_COLOR; @@ -7424,6 +7505,7 @@ static const uint8_t check_box[] = { static void draw_menu_buttons(const menuitem_t *menu, uint32_t mask) { + if (UI_OFF) return; int i, y; ui_button_t button; const menuitem_t *m = menu; @@ -7840,7 +7922,7 @@ leave_ui_mode() if (setting.waterfall) set_level_meter_or_waterfall(); #ifdef __LEVEL_METER__ - if (setting.level_meter) + if (setting.level_meter && !UI_OFF) ili9341_fill(LCD_WIDTH-MENU_BUTTON_WIDTH, area_height, MENU_BUTTON_WIDTH, menu_button_height*MENU_BUTTON_MAX - area_height); #endif redraw_request|=REDRAW_AREA | REDRAW_FREQUENCY | REDRAW_CAL_STATUS | REDRAW_BATTERY; @@ -8834,7 +8916,7 @@ ui_process(void) { #ifdef __USE_SD_CARD__ // SD icon repeat, only from the normal screen: a capture would close an open menu - if (sd_repeat && setting.interval && ui_mode == UI_NORMAL && + if (sd_repeat && setting.interval && ui_mode == UI_NORMAL && !UI_OFF && chVTGetSystemTimeX() - sd_repeat_start >= (systime_t)setting.interval * CH_CFG_ST_FREQUENCY) sd_icon_save(); #endif @@ -8844,9 +8926,17 @@ ui_process(void) selection = -1; // hide keyboard mode selection ui_mode_menu(); } +#ifdef __UI_OFF__ + bool wake = false; // ui off: a jog press or a touch only gives the UI back +#endif // Clear only the handled request: the shell may have set OP_CONSOLE meanwhile for a // waiting command, without it an output mode sweep never stops to run that command if ((operation_requested&OP_LEVER) || previous_button_state != button_state) { +#ifdef __UI_OFF__ + if (ui_off) + wake = btn_check() != 0; // a press, also left or right, the release is no event + else +#endif ui_process_lever(); previous_button_state = button_state; chSysLock(); @@ -8854,11 +8944,23 @@ ui_process(void) chSysUnlock(); } if (operation_requested&OP_TOUCH) { +#ifdef __UI_OFF__ + if (ui_off) { + if (touch_check() != EVT_TOUCH_NONE) { + touch_wait_release(); + wake = true; + } + } else +#endif ui_process_touch(); chSysLock(); operation_requested &= ~OP_TOUCH; chSysUnlock(); } +#ifdef __UI_OFF__ + if (wake) + set_ui(true); +#endif touch_start_watchdog(); } diff --git a/usbcfg.c b/usbcfg.c index 7333816..b5f4387 100644 --- a/usbcfg.c +++ b/usbcfg.c @@ -422,6 +422,12 @@ static void usb_event(USBDriver *usbp, usbevent_t event) { /* Disconnection event on suspend.*/ sduDisconnectI(&SDU1); +#ifdef __UI_OFF__ + /* ui off: the sweep loop gives the UI back without the PC, but an output mode + keeps sweeping until an operation is requested.*/ + if (ui_off) + operation_requested |= OP_CONSOLE; +#endif chSysUnlockFromISR(); return;