From 5901b61126f3a9f4eae70587d889ad8e94e2686b Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Tue, 15 Dec 2020 15:11:07 +0100 Subject: [PATCH 1/6] Reduce differences --- nanovna.h | 2 +- plot.c | 4 ++-- sa_core.c | 14 ++++++-------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/nanovna.h b/nanovna.h index 58eca55..f8a3e53 100644 --- a/nanovna.h +++ b/nanovna.h @@ -364,7 +364,7 @@ extern uint16_t graph_bottom; // Maximum menu buttons count #define MENU_BUTTON_MAX 8 #define MENU_BUTTON_WIDTH 80 -#define MENU_BUTTON_HEIGHT (LCD_HEIGHT/8-2) +#define MENU_BUTTON_HEIGHT (LCD_HEIGHT/8-1) #define MENU_BUTTON_BORDER 1 #define KEYBOARD_BUTTON_BORDER 2 #define FORM_BUTTON_BORDER 2 diff --git a/plot.c b/plot.c index 49a4840..da169a1 100644 --- a/plot.c +++ b/plot.c @@ -2394,7 +2394,7 @@ redraw_frame(void) static void update_waterfall(void){ int i; - int w_width = area_width < POINTS_COUNT ? area_width : POINTS_COUNT; + int w_width = area_width < WIDTH ? area_width : WIDTH; // Waterfall only in 290 or 145 points // if (!(sweep_points == 290 || sweep_points == 145)) // return; @@ -2447,7 +2447,7 @@ static void update_waterfall(void){ else color = RGB565( 0, 124-((y-160)*4), 252-((y-160)*4)); #endif - while (j * sweep_points < (i+1) * 290) { // Scale waterfall to 290 points + while (j * sweep_points < (i+1) * WIDTH) { // Scale waterfall to WIDTH points spi_buffer[j++] = color; } } diff --git a/sa_core.c b/sa_core.c index 96f65fb..b3f4736 100644 --- a/sa_core.c +++ b/sa_core.c @@ -1009,9 +1009,7 @@ void apply_settings(void) // Ensure all settings in the setting structure if (setting.mode == M_LOW) { } -#ifdef __SI4432__ set_calibration_freq(setting.refer); -#endif update_rbw(); calculate_step_delay(); } @@ -1767,10 +1765,10 @@ modulation_again: if (MODE_HIGH(setting.mode)) { local_IF = 0; } else if (MODE_LOW(setting.mode)){ // All low mode - if (!setting.auto_IF) { + if (!setting.auto_IF) local_IF = setting.frequency_IF; - } - local_IF = DEFAULT_IF; + else + local_IF = DEFAULT_IF; if (setting.mode == M_LOW) { if (tracking) { // VERY SPECIAL CASE!!!!! Measure BPF local_IF += lf - reffer_freq[setting.refer]; // Offset so fundamental of reffer is visible @@ -1884,8 +1882,8 @@ modulation_again: // jump here if in zero span mode and all HW frequency setup is done. -#ifdef __SI4432__ #ifdef __FAST_SWEEP__ +#ifdef __SI4432__ if (i == 0 && setting.frequency_step == 0 && setting.trigger == T_AUTO && S_STATE(setting.spur_removal) == 0 && SI4432_step_delay == 0 && setting.repeat == 1 && setting.sweep_time_us < 100*ONE_MS_TIME) { // if ultra fast scanning is needed prefill the SI4432 RSSI read buffer SI4432_Fill(MODE_SELECT(setting.mode), 0); @@ -1957,7 +1955,7 @@ modulation_again: } #ifdef __SPUR__ static pureRSSI_t spur_RSSI = -1; // Initialization only to avoid warning. - if (S_STATE(setting.spur_removal)) { + if (setting.mode == M_LOW && S_STATE(setting.spur_removal)) { if (!spur_second_pass) { // If first spur pass spur_RSSI = pureRSSI; // remember measure RSSI spur_second_pass = true; @@ -2624,7 +2622,7 @@ sweep_again: // stay in sweep loop when output mo palSetPad(GPIOB, GPIOB_LED); #endif #ifdef TINYSA4 - palSetPad(GPIOC, GPIOC_LED); + palSetLine(LINE_LED); #endif return true; From 70243003150af3fa1772663776bc33887989dada Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Wed, 16 Dec 2020 16:17:59 +0100 Subject: [PATCH 2/6] Pre/Post?Mid trigger added --- nanovna.h | 5 ++- sa_core.c | 17 +++++++-- si4432.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- si4432.h | 1 + ui_sa.c | 16 +++++++- 5 files changed, 142 insertions(+), 8 deletions(-) diff --git a/nanovna.h b/nanovna.h index f8a3e53..0b0f647 100644 --- a/nanovna.h +++ b/nanovna.h @@ -805,6 +805,7 @@ typedef struct setting int fast_speedup; float normalize_level; // Level to set normalize to, zero if not doing anything int modulation_frequency; + int trigger_mode; uint32_t checksum; }setting_t; @@ -1064,6 +1065,7 @@ typedef int16_t pureRSSI_t; // External programm zero level settings (need decrease on this value -) #define EXT_ZERO_LEVEL (128) #define DEVICE_TO_PURE_RSSI(rssi) ((rssi)<<4) +#define PURE_TO_DEVICE_RSSI(rssi) ((rssi)>>4) #define float_TO_PURE_RSSI(rssi) ((rssi)*32) #define PURE_TO_float(rssi) ((rssi)/32.0) @@ -1097,6 +1099,7 @@ enum { }; enum { - T_AUTO, T_NORMAL, T_SINGLE, T_DONE, T_UP, T_DOWN + T_AUTO, T_NORMAL, T_SINGLE, T_DONE, T_UP, T_DOWN, T_MODE, T_PRE, T_POST, T_MID }; + /*EOF*/ diff --git a/sa_core.c b/sa_core.c index b3f4736..50854d3 100644 --- a/sa_core.c +++ b/sa_core.c @@ -117,6 +117,7 @@ void reset_settings(int m) setting.offset = 0.0; setting.trigger = T_AUTO; setting.trigger_direction = T_UP; + setting.trigger_mode = T_MID; setting.fast_speedup = 0; setting.level_sweep = 0.0; setting.level = -15.0; @@ -912,7 +913,9 @@ void set_trigger_level(float trigger_level) void set_trigger(int trigger) { - if (trigger == T_UP || trigger == T_DOWN){ + if (trigger == T_PRE || trigger == T_POST || trigger == T_MID) { + setting.trigger_mode = trigger; + } else if (trigger == T_UP || trigger == T_DOWN){ setting.trigger_direction = trigger; } else if (trigger == T_DONE) { pause_sweep(); // Trigger once so pause after this sweep has completed!!!!!!! @@ -1906,6 +1909,11 @@ modulation_again: #define T_LEVEL_CLEAN ~(1<= sweep_points) + buf_index -= sweep_points; + goto store; + break; + case T_MID: // Trigger in the middle of the scan + buf_index = i + sweep_points/2; + if (buf_index >= sweep_points) + buf_index -= sweep_points; + break; + } + } + break; + case ST_FILLING: +store: + if (i == buf_index) + goto done; + } + i++; + if (i >= sweep_points) + i = 0; + if (t) + my_microsecond_delay(t); + }while(1); +done: + buf_end = buf_index; + buf_read = true; +} + void SI4432_Fill(int s, int start) { SI4432_Sel = s; @@ -440,7 +541,7 @@ void SI4432_Fill(int s, int start) uint32_t t = setting.additional_step_delay_us; systime_t measure = chVTGetSystemTimeX(); // __disable_irq(); -#if 0 +#if 1 SPI2_CLK_LOW; int i = start; do { @@ -458,6 +559,7 @@ void SI4432_Fill(int s, int start) // __enable_irq(); setting.measure_sweep_time_us = (chVTGetSystemTimeX() - measure)*100; buf_index = start; // Is used to skip 1st entry during level triggering + buf_end = sweep_points - 1; buf_read = true; } #endif @@ -483,9 +585,12 @@ pureRSSI_t SI4432_RSSI(uint32_t i, int s) //START_PROFILE #ifdef __FAST_SWEEP__ if (buf_read) { - if (buf_index == sweep_points-1) + pureRSSI_t val = DEVICE_TO_PURE_RSSI(age[buf_index++]); + if (buf_index >= sweep_points) + buf_index = 0; + if (buf_index == buf_end) buf_read = false; - return DEVICE_TO_PURE_RSSI(age[buf_index++]); + return val; } #endif SI4432_Sel = s; diff --git a/si4432.h b/si4432.h index 43a2784..6f74b8d 100644 --- a/si4432.h +++ b/si4432.h @@ -137,6 +137,7 @@ extern const int SI4432_RBW_count; void set_calibration_freq(int freq); #ifdef __FAST_SWEEP__ void SI4432_Fill(int s, int start); +void SI4432_trigger_fill(int s, uint8_t trigger_lvl, int up_direction, int trigger_mode); #if 0 int SI4432_is_fast_mode(void); #endif diff --git a/ui_sa.c b/ui_sa.c index 2577a02..c2c6e0d 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -1125,20 +1125,33 @@ static UI_FUNCTION_ADV_CALLBACK(menu_scale_per_acb) } #endif +const char *mode_text[] = {"PRE","POST","MID"}; + static UI_FUNCTION_ADV_CALLBACK(menu_trigger_acb) { (void)item; if(b){ - if (data == T_UP || data == T_DOWN) + if (data == T_MODE) { + b->param_1.text = mode_text[setting.trigger_mode - T_PRE]; + } else if (data == T_UP || data == T_DOWN) b->icon = setting.trigger_direction == data ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP; else b->icon = setting.trigger == data ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP; return; } + if (data == T_MODE) { + setting.trigger_mode += 1; + if (setting.trigger_mode > T_MID) + setting.trigger_mode = T_PRE; + data = setting.trigger_mode; + goto done; + } else if (data != T_DONE) { + done: set_trigger(data); // menu_move_back(); ui_mode_normal(); + draw_menu(); completed = true; } } @@ -1856,6 +1869,7 @@ static const menuitem_t menu_trigger[] = { { MT_KEYPAD, KM_TRIGGER, "TRIGGER\nLEVEL", NULL}, { MT_ADV_CALLBACK, T_UP, "UP\nEDGE", menu_trigger_acb}, { MT_ADV_CALLBACK, T_DOWN, "DOWN\nEDGE", menu_trigger_acb}, + { MT_ADV_CALLBACK, T_MODE, "%s\nTRIGGER", menu_trigger_acb}, { MT_CANCEL, 0, S_LARROW" BACK", NULL }, { MT_NONE, 0, NULL, NULL } // sentinel }; From 0c0d62e131006f8917d0fca85149c16b1632ce9f Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Thu, 17 Dec 2020 13:27:50 +0100 Subject: [PATCH 3/6] THD info overlap bug solved --- plot.c | 34 +++++++++++++++------------------- si4432.c | 18 +++++++----------- ui_sa.c | 11 ++++------- 3 files changed, 26 insertions(+), 37 deletions(-) diff --git a/plot.c b/plot.c index da169a1..fe07e07 100644 --- a/plot.c +++ b/plot.c @@ -2133,33 +2133,29 @@ static void cell_draw_marker_info(int x0, int y0) break; plot_printf(buf, sizeof buf, "DEVIATION:%6.1qHz", dev); goto show_computed; - } - } - if (i >= 2 && setting.measurement == M_THD) { - if (i == 2 && (markers[0].index << 5) > sweep_points ) { + } else if (setting.measurement == M_THD && markers[0].enabled && (markers[0].index << 5) > sweep_points ) { int old_unit = setting.unit; setting.unit = U_WATT; float p = index_to_value(markers[0].index); - int j = 2; + int h_i = 2; uint32_t f = markers[0].frequency; float h = 0.0; - while (f * j < frequencies[sweep_points-1]) { - if (search_maximum(1, f*j, 4*j) ) // use marker 1 for searching harmonics + while (f * h_i < frequencies[sweep_points-1]) { + if (search_maximum(1, f*h_i, 4*h_i) ) // use marker 1 for searching harmonics h += index_to_value(markers[1].index); - j++; + h_i++; } float thd = 100.0 * sqrt(h/p); setting.unit = old_unit; - + ili9341_set_foreground(marker_color(markers[0].mtype)); plot_printf(buf, sizeof buf, "THD: %4.1f%%", thd); - j = 1; +// j = 1; int xpos = 1 + (j%2)*(WIDTH/2) + CELLOFFSETX - x0; int ypos = 1 + (j/2)*(16) - y0; cell_drawstring_7x13(buf, xpos, ypos); // cell_drawstring(buf, xpos, ypos); break; } - break; } else if (i >= 2 && setting.measurement == M_OIP3 && markers[2].enabled && markers[3].enabled) { float il = index_to_value(markers[2].index); @@ -2202,14 +2198,6 @@ static void cell_draw_marker_info(int x0, int y0) for (t = TRACE_ACTUAL; t <= TRACE_ACTUAL; t++) { // Only show info on actual trace if (!trace[t].enabled) continue; -#if 1 - int xpos = 1 + (j%2)*(WIDTH/2) + CELLOFFSETX - x0; -// int ypos = 1 + (j/2)*(13) - y0; - int ypos = 1 + (j/2)*(16) - y0; -#else - int xpos = 1 + CELLOFFSETX - x0; - int ypos = 1 + j*(FONT_GET_HEIGHT*2+1) - y0; -#endif int k = 0; if (i == active_marker) { // ili9341_set_foreground(LCD_BG_COLOR); @@ -2248,6 +2236,14 @@ static void cell_draw_marker_info(int x0, int y0) trace_get_value_string( t, &buf[k], (sizeof buf) - k, idx, measured[trace[t].channel], ridx, markers[i].mtype,markers[i].frequency, markers[ref_marker].frequency); +#if 1 + int xpos = 1 + (j%2)*(WIDTH/2) + CELLOFFSETX - x0; +// int ypos = 1 + (j/2)*(13) - y0; + int ypos = 1 + (j/2)*(16) - y0; +#else + int xpos = 1 + CELLOFFSETX - x0; + int ypos = 1 + j*(FONT_GET_HEIGHT*2+1) - y0; +#endif if (/* strlen(buf)*7> WIDTH/2 && */active > 1) cell_drawstring(buf, xpos, ypos); else diff --git a/si4432.c b/si4432.c index 7735cf5..e9ce892 100644 --- a/si4432.c +++ b/si4432.c @@ -454,7 +454,6 @@ void SI4432_trigger_fill(int s, uint8_t trigger_lvl, int up_direction, int trigg register uint16_t t_mode; uint16_t data_level = T_LEVEL_UNDEF; - if (up_direction) t_mode = T_UP_MASK; else @@ -469,6 +468,9 @@ void SI4432_trigger_fill(int s, uint8_t trigger_lvl, int up_direction, int trigg rssi = shiftIn(); palSetPad(GPIOC, sel); age[i] = rssi; + i++; + if (i >= sweep_points) + i = 0; switch (waiting) { case ST_ARMING: if (i == sweep_points-1) { @@ -491,15 +493,12 @@ void SI4432_trigger_fill(int s, uint8_t trigger_lvl, int up_direction, int trigg waiting = ST_FILLING; switch (trigger_mode) { case T_PRE: // Trigger at the begin of the scan - buf_index = i - 1; - if (buf_index < 0) - buf_index += sweep_points; + buf_index = i; + goto fill_rest; break; case T_POST: // Trigger at the end of the scan buf_index = i; - if (buf_index >= sweep_points) - buf_index -= sweep_points; - goto store; + goto done; break; case T_MID: // Trigger in the middle of the scan buf_index = i + sweep_points/2; @@ -510,13 +509,10 @@ void SI4432_trigger_fill(int s, uint8_t trigger_lvl, int up_direction, int trigg } break; case ST_FILLING: -store: if (i == buf_index) goto done; } - i++; - if (i >= sweep_points) - i = 0; +fill_rest: if (t) my_microsecond_delay(t); }while(1); diff --git a/ui_sa.c b/ui_sa.c index c2c6e0d..e4d9167 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -1143,17 +1143,14 @@ static UI_FUNCTION_ADV_CALLBACK(menu_trigger_acb) setting.trigger_mode += 1; if (setting.trigger_mode > T_MID) setting.trigger_mode = T_PRE; - data = setting.trigger_mode; - goto done; - } else - if (data != T_DONE) { - done: + set_trigger(setting.trigger_mode); + } else if (data != T_DONE) { set_trigger(data); // menu_move_back(); ui_mode_normal(); - draw_menu(); - completed = true; } + draw_menu(); + completed = true; } #if 0 From 8921e10de4f34c31bd8e188a45bee9c3e722974d Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Fri, 18 Dec 2020 08:50:11 +0100 Subject: [PATCH 4/6] Double click for bottom quick menu bug solved --- nanovna.h | 2 +- ui.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/nanovna.h b/nanovna.h index 0b0f647..ac84335 100644 --- a/nanovna.h +++ b/nanovna.h @@ -370,7 +370,7 @@ extern uint16_t graph_bottom; #define FORM_BUTTON_BORDER 2 // Form button (at center screen better be less LCD_WIDTH - 2*OFFSETX) -#define MENU_FORM_WIDTH 256 +#define MENU_FORM_WIDTH (LCD_WIDTH - 2*OFFSETX) // Num Input height at bottom #define NUM_INPUT_HEIGHT 32 diff --git a/ui.c b/ui.c index 5f1af56..32a591c 100644 --- a/ui.c +++ b/ui.c @@ -2587,6 +2587,7 @@ touch_lever_mode_select(void) else ui_mode_keypad(KM_START); ui_process_keypad(); + return TRUE; } if (touch_x > FREQUENCIES_XPOS2 - 50 && touch_x < FREQUENCIES_XPOS2 +50) { touch_wait_release(); @@ -2604,8 +2605,10 @@ touch_lever_mode_select(void) else ui_mode_keypad(KM_STOP); ui_process_keypad(); + return TRUE; } select_lever_mode(touch_x < FREQUENCIES_XPOS2 ? LM_CENTER : LM_SPAN); + touch_wait_release(); return TRUE; } if (touch_x Date: Fri, 18 Dec 2020 10:47:37 +0100 Subject: [PATCH 5/6] Added external amp in output mode --- nanovna.h | 2 +- sa_core.c | 4 ++-- ui.c | 4 ++-- ui_sa.c | 46 ++++++++++++++++++++++++++++++++++++++++------ 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/nanovna.h b/nanovna.h index ac84335..df82b24 100644 --- a/nanovna.h +++ b/nanovna.h @@ -992,7 +992,7 @@ typedef struct uistat { uint8_t marker_noise; uint8_t marker_tracking; uint8_t auto_center_marker; - char text[20]; + char text[28]; } uistat_t; typedef struct ui_button { diff --git a/sa_core.c b/sa_core.c index 50854d3..d8b6a75 100644 --- a/sa_core.c +++ b/sa_core.c @@ -303,8 +303,8 @@ void set_sweep_time_us(uint32_t t) // Set the sweep time as the user wa if (t > MAXIMUM_SWEEP_TIME) t = MAXIMUM_SWEEP_TIME; setting.sweep_time_us = t; - if (MODE_OUTPUT(setting.mode)) - setting.actual_sweep_time_us = t; // To ensure time displayed is correct before first sweep is completed +// if (MODE_OUTPUT(setting.mode)) +// setting.actual_sweep_time_us = t; // To ensure time displayed is correct before first sweep is completed #if 0 uint32_t ta = calc_min_sweep_time_us(); // Can not be faster than minimum sweep time if (ta < t) diff --git a/ui.c b/ui.c index 32a591c..29a4dec 100644 --- a/ui.c +++ b/ui.c @@ -491,8 +491,8 @@ enum { MT_LOW = 0x40, // Only applicable to low mode MT_FORM = 0x80, // Large button menu }; -#define MT_BACK 0x40 -#define MT_LEAVE 0x20 +//#define MT_BACK 0x40 +//#define MT_LEAVE 0x20 #define MT_MASK(x) (0xF & (x)) // Call back functions for MT_CALLBACK type diff --git a/ui_sa.c b/ui_sa.c index e4d9167..857bb4a 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -455,6 +455,7 @@ static const menuitem_t menu_top[]; static const menuitem_t menu_reffer[]; static const menuitem_t menu_modulation[]; static const menuitem_t menu_drive_wide[]; +static const menuitem_t menu_sweep[]; #ifdef __ULTRA__ static const menuitem_t menu_tophigh[]; static const menuitem_t menu_topultra[]; @@ -462,6 +463,25 @@ static const menuitem_t menu_topultra[]; #define AUTO_ICON(S) (S>=2?BUTTON_ICON_CHECK_AUTO:S) // Depends on order of ICONs!!!!! +static UI_FUNCTION_ADV_CALLBACK(menu_sweep_acb) +{ + (void)data; + if (b){ + if (setting.level_sweep != 0 || get_sweep_frequency(ST_SPAN) != 0) { + plot_printf(uistat.text, sizeof uistat.text, "SW:%3.2fMHz %+ddB %.3Fs", + get_sweep_frequency(ST_SPAN) / 1000000.0, + (int)setting.level_sweep, + setting.sweep_time_us/(float)ONE_SECOND_TIME); + b->param_1.text = uistat.text; + } + else + b->param_1.text = "SWEEP: OFF"; + return; + } + menu_push_submenu(menu_sweep); +} + + static UI_FUNCTION_ADV_CALLBACK(menu_mode_acb) { (void)data; @@ -701,7 +721,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_drive_acb) { (void)item; if(b){ - b->param_1.i = menu_drive_value[data]; + b->param_1.i = menu_drive_value[data] + (setting.mode==M_GENHIGH ? setting.offset : 0); b->icon = data == setting.drive ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP; return; } @@ -716,7 +736,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_sdrive_acb){ (void)item; (void)data; if(b){ - b->param_1.i = menu_drive_value[setting.drive]; + b->param_1.i = menu_drive_value[setting.drive] + (setting.mode==M_GENHIGH ? setting.offset : 0); return; } menu_push_submenu(menu_drive_wide); @@ -1448,14 +1468,25 @@ static const menuitem_t menu_modulation[] = { { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; +static const menuitem_t menu_sweep[] = { + { MT_FORM | MT_KEYPAD, KM_SPAN, "SPAN: %s", "0..350MHz"}, + { MT_FORM | MT_KEYPAD | MT_LOW, KM_LEVELSWEEP,"LEVEL CHANGE: %s", "-70..70"}, + { MT_FORM | MT_KEYPAD, KM_SWEEP_TIME, "SWEEP TIME: %s", "0..600 seconds"}, + { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK",NULL }, + { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel +}; + + static const menuitem_t menu_lowoutputmode[] = { { MT_FORM | MT_ADV_CALLBACK, 0, "LOW OUTPUT %s", menu_outputmode_acb}, { MT_FORM | MT_KEYPAD, KM_CENTER, "FREQ: %s", "10kHz..350MHz"}, { MT_FORM | MT_KEYPAD, KM_LOWOUTLEVEL, "LEVEL: %s", "-76..-6"}, { MT_FORM | MT_ADV_CALLBACK, 0, "MOD: %s", menu_smodulation_acb}, - { MT_FORM | MT_KEYPAD, KM_SPAN, "SPAN: %s", "0..350MHz"}, - { MT_FORM | MT_KEYPAD | MT_LOW, KM_LEVELSWEEP,"LEVEL CHANGE: %s", "-70..70"}, - { MT_FORM | MT_KEYPAD, KM_SWEEP_TIME, "SWEEP TIME: %s", "0..600 seconds"}, + { MT_FORM | MT_ADV_CALLBACK, 0, "%s", menu_sweep_acb}, +// { MT_FORM | MT_KEYPAD, KM_SPAN, "SPAN: %s", "0..350MHz"}, +// { MT_FORM | MT_KEYPAD | MT_LOW, KM_LEVELSWEEP,"LEVEL CHANGE: %s", "-70..70"}, +// { MT_FORM | MT_KEYPAD, KM_SWEEP_TIME, "SWEEP TIME: %s", "0..600 seconds"}, + { MT_FORM | MT_KEYPAD, KM_OFFSET, "AMP: %s", "-100..+100"}, { MT_FORM | MT_CANCEL, 0, "MODE", NULL }, { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; @@ -1467,6 +1498,7 @@ static const menuitem_t menu_highoutputmode[] = { { MT_FORM | MT_ADV_CALLBACK, 0, "MOD: %s", menu_smodulation_acb}, { MT_FORM | MT_KEYPAD, KM_SPAN, "SPAN: %s", NULL}, { MT_FORM | MT_KEYPAD, KM_SWEEP_TIME,"SWEEP TIME: %s", "0..600 seconds"}, + { MT_FORM | MT_KEYPAD, KM_OFFSET, "AMP: %s", "-100..+100"}, { MT_FORM | MT_CANCEL, 0, "MODE", NULL }, { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; @@ -2042,6 +2074,8 @@ static void fetch_numeric_target(void) end_level = -76; if (end_level > -6) end_level = -6; + uistat.value += setting.offset; + end_level += setting.offset; if (setting.level_sweep != 0) plot_printf(uistat.text, sizeof uistat.text, "%d to %ddBm", ((int32_t)uistat.value), end_level); else @@ -2164,7 +2198,7 @@ set_numeric_value(void) set_drive(uistat.value); break; case KM_LOWOUTLEVEL: - set_level(uistat.value); + set_level(uistat.value - setting.offset); break; case KM_DECAY: set_decay(uistat.value); From 211c236712878c88c29b016f8f3ac55ade26f4b7 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Fri, 18 Dec 2020 17:44:25 +0100 Subject: [PATCH 6/6] Improved selftest --- sa_core.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/sa_core.c b/sa_core.c index 50854d3..9a7baa6 100644 --- a/sa_core.c +++ b/sa_core.c @@ -2809,8 +2809,8 @@ static const struct { {TC_BELOW, TP_SILENT, 200, 100, -75, 0, 0}, // 5 Wide band noise floor low mode {TC_BELOW, TPH_SILENT, 600, 720, -75, 0, 0}, // 6 Wide band noise floor high mode {TC_SIGNAL, TP_10MHZEXTRA, 10, 8, -20, 27, -80 }, // 7 BPF loss and stop band - {TC_FLAT, TP_10MHZEXTRA, 10, 4, -18, 7, -60}, // 8 BPF pass band flatness - {TC_BELOW, TP_30MHZ, 430, 60, -75, 0, -75}, // 9 LPF cutoff + {TC_FLAT, TP_10MHZEXTRA, 10, 4, -18, 9, -60}, // 8 BPF pass band flatness + {TC_BELOW, TP_30MHZ, 400, 60, -75, 0, -75}, // 9 LPF cutoff {TC_SIGNAL, TP_10MHZ_SWITCH,20, 7, -39, 10, -60 }, // 10 Switch isolation using high attenuation {TC_ATTEN, TP_30MHZ, 30, 0, -25, 145, -60 }, // 11 Measure atten step accuracy #define TEST_END 11 @@ -2938,22 +2938,21 @@ int validate_below(int tc, int from, int to) { } int validate_flatness(int i) { - volatile int j; + volatile int j,k; test_fail_cause[i] = "Passband "; for (j = peakIndex; j < setting._sweep_points; j++) { if (actual_t[j] < peakLevel - 15) // Search right -3dB break; } - //shell_printf("\n\rRight width %d\n\r", j - peakIndex ); - if (j - peakIndex < W2P(test_case[i].width)) - return(TS_FAIL); - for (j = peakIndex; j > 0; j--) { - if (actual_t[j] < peakLevel - 15) // Search left -3dB + for (k = peakIndex; k > 0; k--) { + if (actual_t[k] < peakLevel - 15) // Search left -3dB break; } - //shell_printf("Left width %d\n\r", j - peakIndex ); - if (peakIndex - j < W2P(test_case[i].width)) - return(TS_FAIL); +// shell_printf("Width %d between %d and %d\n\r", j - k, 2* W2P(test_case[i].width), 3* W2P(test_case[i].width) ); + if (j - k < 2* W2P(test_case[i].width)) + return(TS_FAIL); + if (j - k > 3* W2P(test_case[i].width)) + return(TS_FAIL); test_fail_cause[i] = ""; return(TS_PASS); }