From 39b7fdf95eabd7aa5ea8ed25c7fbb2080c32796f Mon Sep 17 00:00:00 2001 From: cho45 Date: Thu, 5 Sep 2019 22:14:44 +0900 Subject: [PATCH] append version info screen to UI --- ili9341.c | 28 ++++++++++++++++++++++++++++ main.c | 3 --- nanovna.h | 2 ++ ui.c | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 3 deletions(-) diff --git a/ili9341.c b/ili9341.c index 6fbb2c4..e42d6de 100644 --- a/ili9341.c +++ b/ili9341.c @@ -360,6 +360,34 @@ ili9341_drawstring_5x7(const char *str, int x, int y, uint16_t fg, uint16_t bg) } } +void +ili9341_drawchar_size(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg, uint8_t size) +{ + uint16_t *buf = spi_buffer; + uint16_t bits; + int c, r; + for(c = 0; c < 7*size; c++) { + bits = x5x7_bits[(ch * 7) + (c / size)]; + for (r = 0; r < 5*size; r++) { + *buf++ = (0x8000 & bits) ? fg : bg; + if (r % size == (size-1)) { + bits <<= 1; + } + } + } + ili9341_bulk(x, y, 5*size, 7*size); +} + +void +ili9341_drawstring_size(const char *str, int x, int y, uint16_t fg, uint16_t bg, uint8_t size) +{ + while (*str) { + ili9341_drawchar_size(*str, x, y, fg, bg, size); + x += 5 * size; + str++; + } +} + #define SWAP(x,y) do { int z=x; x = y; y = z; } while(0) void diff --git a/main.c b/main.c index 7947fc6..a381155 100644 --- a/main.c +++ b/main.c @@ -390,8 +390,6 @@ static void cmd_capture(BaseSequentialStream *chp, int argc, char *argv[]) (void)argc; (void)argv; - chMtxLock(&mutex); - // pause sweep stop_the_world = TRUE; @@ -419,7 +417,6 @@ static void cmd_capture(BaseSequentialStream *chp, int argc, char *argv[]) //*/ stop_the_world = FALSE; - chMtxUnlock(&mutex); } #if 0 diff --git a/nanovna.h b/nanovna.h index ba5a947..6837ee4 100644 --- a/nanovna.h +++ b/nanovna.h @@ -254,6 +254,8 @@ void ili9341_bulk(int x, int y, int w, int h); void ili9341_fill(int x, int y, int w, int h, int color); void ili9341_drawchar_5x7(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg); void ili9341_drawstring_5x7(const char *str, int x, int y, uint16_t fg, uint16_t bg); +void ili9341_drawchar_size(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg, uint8_t size); +void ili9341_drawstring_size(const char *str, int x, int y, uint16_t fg, uint16_t bg, uint8_t size); void ili9341_drawfont(uint8_t ch, const font_t *font, int x, int y, uint16_t fg, uint16_t bg); void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t* out); void ili9341_read_memory_continue(int len, uint16_t* out); diff --git a/ui.c b/ui.c index 9e7f090..a8fbed0 100644 --- a/ui.c +++ b/ui.c @@ -383,6 +383,36 @@ touch_position(int *x, int *y) } +void +show_version(void) +{ + int status; + int x = 5, y = 5; + int i; + + adc_stop(ADC1); + ili9341_fill(0, 0, 320, 240, 0); + + ili9341_drawstring_size(BOARD_NAME, x, y, 0xffff, 0x0000, 4); + y += 25; + + ili9341_drawstring_5x7("2016-2019 Copyright @edy555", x, y += 10, 0xffff, 0x0000); + ili9341_drawstring_5x7("Licensed under GPL. See: https://github.com/ttrftech/NanoVNA", x, y += 10, 0xffff, 0x0000); + ili9341_drawstring_5x7("Version: " VERSION, x, y += 10, 0xffff, 0x0000); + ili9341_drawstring_5x7("Build Time: " __DATE__ " - " __TIME__, x, y += 10, 0xffff, 0x0000); + y += 5; + ili9341_drawstring_5x7("Kernel: " CH_KERNEL_VERSION, x, y += 10, 0xffff, 0x0000); + ili9341_drawstring_5x7("Compiler: " PORT_COMPILER_NAME, x, y += 10, 0xffff, 0x0000); + ili9341_drawstring_5x7("Architecture: " PORT_ARCHITECTURE_NAME " Core Variant: PORT_CORE_VARIANT_NAME", x, y += 10, 0xffff, 0x0000); + ili9341_drawstring_5x7("Port Info: " PORT_INFO, x, y += 10, 0xffff, 0x0000); + ili9341_drawstring_5x7("Platform: " PLATFORM_NAME, x, y += 10, 0xffff, 0x0000); + + do { + status = touch_check(); + } while(status != EVT_TOUCH_PRESSED); + + touch_start_watchdog(); +} // type of menu item @@ -490,6 +520,11 @@ menu_config_cb(int item) menu_move_back(); ui_mode_normal(); break; + case 3: + show_version(); + redraw_frame(); + request_to_redraw_grid(); + draw_menu(); } } @@ -867,6 +902,7 @@ const menuitem_t menu_config[] = { { MT_CALLBACK, "TOUCH CAL", menu_config_cb }, { MT_CALLBACK, "TOUCH TEST", menu_config_cb }, { MT_CALLBACK, "SAVE", menu_config_cb }, + { MT_CALLBACK, "VERSION", menu_config_cb }, { MT_CANCEL, S_LARROW" BACK", NULL }, { MT_NONE, NULL, NULL } // sentinel };