From 4a2c18e98c22b1ced7854a14b88b0d555e37509a Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Mon, 22 Jun 2020 08:06:43 +0200 Subject: [PATCH] Selftest error screens can be captured --- main.c | 2 +- nanovna.h | 1 + sa_core.c | 83 ++++++++++++++++++++++++++++++------------------------- ui.c | 9 ++++++ 4 files changed, 57 insertions(+), 38 deletions(-) diff --git a/main.c b/main.c index f2c9181..d25d6d4 100644 --- a/main.c +++ b/main.c @@ -140,7 +140,7 @@ static THD_FUNCTION(Thread1, arg) } else if (sweep_mode & SWEEP_SELFTEST) { // call from lowest level to save stack space self_test(setting.test); - sweep_mode = SWEEP_ENABLE; +// sweep_mode = SWEEP_ENABLE; } else if (sweep_mode & SWEEP_REMOTE) { sweep_remote(); } else if (sweep_mode & SWEEP_CALIBRATE) { diff --git a/nanovna.h b/nanovna.h index ecc2f5a..71b410a 100644 --- a/nanovna.h +++ b/nanovna.h @@ -763,6 +763,7 @@ void menu_push_lowoutput(void); void menu_push_highoutput(void); void menu_move_top(void); void draw_menu(void); +int check_touched(void); // Irq operation process set #define OP_NONE 0x00 diff --git a/sa_core.c b/sa_core.c index 4ccf95f..c1ce994 100644 --- a/sa_core.c +++ b/sa_core.c @@ -2454,7 +2454,7 @@ int test_validate(int i) // draw_frequencies(); // draw_cal_status(); draw_all(TRUE); - resume_sweep(); +// resume_sweep(); return current_test_status; } @@ -2545,10 +2545,52 @@ int add_spur(int f) return 1; } +//static bool test_wait = false; +static int test_step = 0; void self_test(int test) { - if (test ==1) { + if (test == 0) { + if (test_wait ) + goto resume; + reset_settings(M_LOW); // Make sure we are in a defined state + in_selftest = true; + menu_autosettings_cb(0); + for (int i=0; i < TEST_COUNT; i++) { // All test cases waiting + if (test_case[i].kind == TC_END) + break; + test_status[i] = TS_WAITING; + test_fail_cause[i] = ""; + } + show_test_info = TRUE; + test_step=0; + if (setting.test_argument > 0) + test_step=setting.test_argument-1; + do { + test_prepare(test_step); + test_acquire(test_step); // Acquire test + test_status[test_step] = test_validate(test_step); // Validate test + if (test_status[test_step] != TS_PASS) { + test_wait = true; + resume: + if (!check_touched()) + return; +// wait_user(); + } + test_step++; + } while (test_case[test_step].kind != TC_END && setting.test_argument == 0 ); + ili9341_set_foreground(BRIGHT_COLOR_GREEN); + ili9341_drawstring_7x13("Self test complete", 50, 200); + ili9341_drawstring_7x13("Touch screen to continue", 50, 215); + wait_user(); + ili9341_clear_screen(); + + sweep_mode = SWEEP_ENABLE; + show_test_info = FALSE; + set_refer_output(-1); + reset_settings(M_LOW); + in_selftest = false; + } else if (test ==1) { in_selftest = true; // Spur search reset_settings(M_LOW); test_prepare(4); @@ -2610,7 +2652,6 @@ void self_test(int test) reference_peak_level = peakLevel; shell_printf("Target %d, actual %f, delta %f\n\r",j, peakLevel, peakLevel - reference_peak_level); } - return; } else if (test == 3) { // RBW step time search in_selftest = true; @@ -2650,40 +2691,6 @@ void self_test(int test) setting.step_delay = setting.step_delay * 5 / 4; shell_printf("End level = %f, step time = %d\n\r",peakLevel, setting.step_delay); } - } else if (test == 0) { - reset_settings(M_LOW); // Make sure we are in a defined state - in_selftest = true; - menu_autosettings_cb(0); - for (int i=0; i < TEST_COUNT; i++) { // All test cases waiting - if (test_case[i].kind == TC_END) - break; - test_status[i] = TS_WAITING; - test_fail_cause[i] = ""; - } - show_test_info = TRUE; - int i=0; - if (setting.test_argument > 0) - i=setting.test_argument-1; - do { - test_prepare(i); - test_acquire(i); // Acquire test - test_status[i] = test_validate(i); // Validate test - if (test_status[i] != TS_PASS) { - wait_user(); - } - i++; - } while (test_case[i].kind != TC_END && setting.test_argument == 0 ); - ili9341_set_foreground(BRIGHT_COLOR_GREEN); - ili9341_drawstring_7x13("Self test complete", 50, 200); - ili9341_drawstring_7x13("Touch screen to continue", 50, 215); - wait_user(); - ili9341_clear_screen(); - - sweep_mode = SWEEP_ENABLE; - show_test_info = FALSE; - set_refer_output(-1); - reset_settings(M_LOW); - in_selftest = false; } else if (test == 5) { // reset_settings(M_LOW); // Make sure we are in a defined state in_selftest = true; @@ -2722,6 +2729,8 @@ void self_test(int test) } in_selftest = false; } + test_wait = true; + sweep_mode = SWEEP_ENABLE; } void reset_calibration(void) diff --git a/ui.c b/ui.c index ce2703c..a0c27b9 100644 --- a/ui.c +++ b/ui.c @@ -2676,3 +2676,12 @@ void wait_user(void) touch_start_watchdog(); } +int check_touched(void) +{ + int touched = false; + adc_stop(); + if (touch_check() == EVT_TOUCH_RELEASED) + touched = true; + touch_start_watchdog(); + return touched; +}