From d87d2a2e07ebb7e918198b89eb875d55817b006e Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Wed, 13 Jan 2021 16:46:12 +0100 Subject: [PATCH] Display test added --- nanovna.h | 1 + plot.c | 21 +++++++++++++++++++++ sa_core.c | 9 +++++++++ 3 files changed, 31 insertions(+) diff --git a/nanovna.h b/nanovna.h index c40478f..be5f0ee 100644 --- a/nanovna.h +++ b/nanovna.h @@ -540,6 +540,7 @@ float get_trace_scale(int t); float get_trace_refpos(int t); const char *get_trace_typename(int t); extern int in_selftest; +extern int display_test(void); // // Shell config functions and macros diff --git a/plot.c b/plot.c index fd4b73d..b466329 100644 --- a/plot.c +++ b/plot.c @@ -2386,6 +2386,27 @@ redraw_frame(void) draw_cal_status(); } +int display_test(void) +{ +// return true; + // write and read display, return false on fail. + for (int h = 0; h < LCD_HEIGHT; h++) { + for (int w = 0; w < LCD_WIDTH; w++) { + spi_buffer[w] = ((w*h) & 0xfff); + } + ili9341_bulk(0, h, LCD_WIDTH, 1); + for (int w = 0; w < LCD_WIDTH; w++) { + spi_buffer[w] = 0; + } + ili9341_read_memory(0, h, LCD_WIDTH, 1, LCD_WIDTH, spi_buffer); + for (int volatile w = 0; w < LCD_WIDTH; w++) { + if (spi_buffer[w] != ((w*h) & 0xfff)) + return false; + } + } + return true; +} + //#define _USE_WATERFALL_PALETTE #ifdef _USE_WATERFALL_PALETTE #include "waterfall.c" diff --git a/sa_core.c b/sa_core.c index e9bb41d..c45401e 100644 --- a/sa_core.c +++ b/sa_core.c @@ -3219,6 +3219,15 @@ void self_test(int test) if (setting.test_argument > 0) test_step=setting.test_argument-1; do { + if (test_step == 0) { + if (!display_test()) { + test_step = TEST_END; + show_test_info = FALSE; + ili9341_set_foreground(LCD_BRIGHT_COLOR_RED); + ili9341_drawstring_7x13("Display read fails", 30, 140); + goto resume2; + } + } test_prepare(test_step); test_acquire(test_step); // Acquire test test_status[test_step] = test_validate(test_step); // Validate test