diff --git a/main.c b/main.c index 7c77006..e07b8d4 100644 --- a/main.c +++ b/main.c @@ -2903,6 +2903,7 @@ void set_freq_boundaries(void) { set_jump_freq( MAX_ABOVE_IF_FREQ, (config.harmonic_start?config.harmonic_start:ULTRA_MAX_FREQ), MIN_BELOW_IF_FREQ); } #endif + int main(void) { halInit(); diff --git a/sa_core.c b/sa_core.c index 1ec03fc..0cba891 100644 --- a/sa_core.c +++ b/sa_core.c @@ -6217,7 +6217,7 @@ enum { enum { TP_SILENT, TPH_SILENT, TP_10MHZ, TP_10MHZEXTRA, TP_30MHZ_SWITCH, TP_30MHZ, TPH_30MHZ, TPH_30MHZ_SWITCH, #ifdef TINYSA4 - TP_30MHZ_ULTRA, TP_30MHZ_DIRECT, TP_30MHZ_LNA,TP_SILENT_LNA, TP_15MHZ_LNA + TP_30MHZ_ULTRA, TP_30MHZ_DIRECT, TP_30MHZ_LNA,TP_SILENT_LNA, TP_15MHZ_LNA, TP_15MHZ_LNA2 #endif }; @@ -6258,7 +6258,7 @@ const test_case_t test_case [] = TEST_CASE_STRUCT(TC_ABOVE, TP_30MHZ_DIRECT,900, 10, -90, 0, -90), // 6 Direct path with harmonic TEST_CASE_STRUCT(TC_SIGNAL, TP_10MHZEXTRA, 30, 14, CAL_LEVEL, 26, -45), // 7 BPF loss and stop band TEST_CASE_STRUCT(TC_FLAT, TP_10MHZEXTRA, 30, 14, -28, 9, -60), // 8 BPF pass band flatness - TEST_CASE_STRUCT(TC_BELOW, TP_30MHZ, 880, 1, -95, 0, -100), // 9 LPF cutoff + TEST_CASE_STRUCT(TC_BELOW, TP_15MHZ_LNA2, 855, 1, -90, 0, -90), // 9 LPF cutoff TEST_CASE_STRUCT(TC_SIGNAL, TP_15MHZ_LNA, 30, 5, CAL_LEVEL, 10, -90), // 10 Flatness TEST_CASE_STRUCT(TC_SIGNAL, TP_30MHZ_SWITCH,30, 7, CAL_LEVEL, 10, -50), // 11 Switch isolation using high attenuation TEST_CASE_STRUCT(TC_DISPLAY, TP_30MHZ, 30, 0, CAL_LEVEL, 50, -60), // 12 test display @@ -6456,8 +6456,9 @@ int validate_signal_within(int i, float margin) test_level = lpf_test_level; margin = 5; } + if (fabsf(config.low_level_offset) > 10) + return(TS_FAIL); #endif - if (fabsf(peakLevel-test_level) > 2*margin) { return TS_FAIL; } @@ -6707,6 +6708,7 @@ void test_prepare(int i) setting.tracking = false; //Default test setup setting.atten_step = false; #ifdef TINYSA4 + force_signal_path = false; setting.frequency_IF = config.frequency_IF1; // Default frequency setting.extra_lna = false; #else @@ -6794,6 +6796,10 @@ common_silent: case TP_15MHZ_LNA: determine_lpf_test_level(); goto simple; + case TP_15MHZ_LNA2: + force_signal_path = true; + test_path = 1; + goto simple; case TP_30MHZ_DIRECT: case TP_30MHZ_ULTRA: case TP_30MHZ_LNA: @@ -6838,6 +6844,7 @@ common_silent: setting.extra_lna = true; break; case TP_15MHZ_LNA: + case TP_15MHZ_LNA2: set_refer_output(1); setting.extra_lna = true; break; @@ -6969,6 +6976,10 @@ void self_test(int test) #ifdef TINYSA4 bool old_ultra = config.ultra; config.ultra = true; + if (adc_vbat_read() < 3800) { + drawMessageBox("Battery low", "Charge before testing", 2000); + goto quit; + } #endif // set_sweep_points(POINTS_COUNT); if (test == 0) { diff --git a/ui.c b/ui.c index 046fc69..2566cfc 100644 --- a/ui.c +++ b/ui.c @@ -43,9 +43,10 @@ uistat_t uistat = { #define EVT_BUTTON_SINGLE_CLICK 0x01 #define EVT_BUTTON_DOUBLE_CLICK 0x02 #define EVT_BUTTON_DOWN_LONG 0x04 -#define EVT_UP 0x10 -#define EVT_DOWN 0x20 -#define EVT_REPEAT 0x40 +#define EVT_BUTTON_CLICK_RELEASE 0x08 +#define EVT_UP 0x10 +#define EVT_DOWN 0x20 +#define EVT_REPEAT 0x40 #define BUTTON_DOWN_LONG_TICKS MS2ST(500) // 500ms #define BUTTON_DOUBLE_TICKS MS2ST(250) // 250ms @@ -7264,18 +7265,25 @@ static void lever_search_marker(int status) { int i = -1; + int wait_count = 0; do { if (active_marker != MARKER_INVALID) { - if (status & EVT_DOWN) - i = marker_search_left_max(active_marker); - else if (status & EVT_UP) - i = marker_search_right_max(active_marker); - if (i != -1) { - markers[active_marker].index = i; - interpolate_maximum(active_marker); - markers[active_marker].mtype &= ~M_TRACKING; +#define WAIT_COUNT 3 + if (wait_count == 0) + wait_count = WAIT_COUNT; + if (wait_count == WAIT_COUNT) { + if (status & EVT_DOWN) + i = marker_search_left_max(active_marker); + else if (status & EVT_UP) + i = marker_search_right_max(active_marker); + if (i != -1) { + markers[active_marker].index = i; + interpolate_maximum(active_marker); + markers[active_marker].mtype &= ~M_TRACKING; + } + redraw_marker(active_marker); } - redraw_marker(active_marker); + wait_count --; } status = btn_wait_release(); } while (status != 0);