From 45f04420cbacc1420deaecdd3cd300b85a1208d3 Mon Sep 17 00:00:00 2001 From: DiSlord Date: Sun, 8 Mar 2020 08:32:38 +0300 Subject: [PATCH] Implement info command, move info_about[] to main.c Command enabled by default: ENABLE_INFO_COMMAND This feature not increase flash size --- main.c | 32 ++++++++++++++++++++++++++++++-- nanovna.h | 1 + ui.c | 23 +++++++---------------- 3 files changed, 38 insertions(+), 18 deletions(-) diff --git a/main.c b/main.c index bb13344..2593545 100644 --- a/main.c +++ b/main.c @@ -58,6 +58,7 @@ static char shell_line[VNA_SHELL_MAX_LENGTH]; //#define ENABLE_THREADS_COMMAND //#define ENABLE_TIME_COMMAND #define ENABLE_VBAT_OFFSET_COMMAND +#define ENABLE_INFO_COMMAND static void apply_error_term_at(int i); static void apply_edelay_at(int i); @@ -82,6 +83,21 @@ static int8_t drive_strength = DRIVE_STRENGTH_AUTO; int8_t sweep_mode = SWEEP_ENABLE; volatile uint8_t redraw_request = 0; // contains REDRAW_XXX flags +// Version text, displayed in Config->Version menu, also send by info command +const char *info_about[]={ + BOARD_NAME, + "2016-2020 Copyright @edy555", + "Licensed under GPL. See: https://github.com/ttrftech/NanoVNA", + "Version: " VERSION, + "Build Time: " __DATE__ " - " __TIME__, + "Kernel: " CH_KERNEL_VERSION, + "Compiler: " PORT_COMPILER_NAME, + "Architecture: " PORT_ARCHITECTURE_NAME " Core Variant: " PORT_CORE_VARIANT_NAME, + "Port Info: " PORT_INFO, + "Platform: " PLATFORM_NAME, + 0 // sentinel +}; + static THD_WORKING_AREA(waThread1, 640); static THD_FUNCTION(Thread1, arg) { @@ -1949,6 +1965,17 @@ VNA_SHELL_FUNCTION(cmd_vbat_offset) } #endif +#ifdef ENABLE_INFO_COMMAND +VNA_SHELL_FUNCTION(cmd_info) +{ + (void)argc; + (void)argv; + int i=0; + while (info_about[i]) + shell_printf("%s\r\n", info_about[i++]); +} +#endif + #ifdef ENABLE_THREADS_COMMAND #if CH_CFG_USE_REGISTRY == FALSE #error "Threads Requite enabled CH_CFG_USE_REGISTRY in chconf.h" @@ -1970,8 +1997,6 @@ VNA_SHELL_FUNCTION(cmd_threads) { #else uint32_t stklimit = 0U; #endif - - shell_printf("%08x|%08x|%08x|%08x|%4u|%4u|%9s|%12s"VNA_SHELL_NEWLINE_STR, stklimit, (uint32_t)tp->ctx.sp, max_stack_use, (uint32_t)tp, (uint32_t)tp->refs - 1, (uint32_t)tp->prio, states[tp->state], @@ -2038,6 +2063,9 @@ static const VNAShellCommand commands[] = {"transform" , cmd_transform , 0}, {"threshold" , cmd_threshold , 0}, {"help" , cmd_help , 0}, +#ifdef ENABLE_INFO_COMMAND + {"info" , cmd_info , 0}, +#endif #ifdef ENABLE_THREADS_COMMAND {"threads" , cmd_threads , 0}, #endif diff --git a/nanovna.h b/nanovna.h index 58e4e4c..d5d14cc 100644 --- a/nanovna.h +++ b/nanovna.h @@ -89,6 +89,7 @@ void loadDefaultProps(void); #define SWEEP_ENABLE 0x01 #define SWEEP_ONCE 0x02 extern int8_t sweep_mode; +extern const char *info_about[]; /* * dsp.c diff --git a/ui.c b/ui.c index a3ac007..a2267da 100644 --- a/ui.c +++ b/ui.c @@ -367,30 +367,21 @@ touch_position(int *x, int *y) *y = (last_touch_y - config.touch_cal[1]) * 16 / config.touch_cal[3]; } - void show_version(void) { - int x = 5, y = 5; + int x = 5, y = 5, i = 0; adc_stop(); setForegroundColor(DEFAULT_FG_COLOR); setBackgroundColor(DEFAULT_BG_COLOR); clearScreen(); - ili9341_drawstring_size(BOARD_NAME, x, y, 4); - y += 25; - - ili9341_drawstring("2016-2020 Copyright @edy555", x, y += 10); - ili9341_drawstring("Licensed under GPL. See: https://github.com/ttrftech/NanoVNA", x, y += 10); - ili9341_drawstring("Version: " VERSION, x, y += 10); - ili9341_drawstring("Build Time: " __DATE__ " - " __TIME__, x, y += 10); - y += 5; - ili9341_drawstring("Kernel: " CH_KERNEL_VERSION, x, y += 10); - ili9341_drawstring("Compiler: " PORT_COMPILER_NAME, x, y += 10); - ili9341_drawstring("Architecture: " PORT_ARCHITECTURE_NAME " Core Variant: " PORT_CORE_VARIANT_NAME, x, y += 10); - ili9341_drawstring("Port Info: " PORT_INFO, x, y += 10); - ili9341_drawstring("Platform: " PLATFORM_NAME, x, y += 10); - + uint16_t shift = 0b0000010000111110; + ili9341_drawstring_size(info_about[i++], x , y, 4); + while (info_about[i]){ + do {shift>>=1; y+=5;} while (shift&1); + ili9341_drawstring(info_about[i++], x, y+=5); + } while (true) { if (touch_check() == EVT_TOUCH_PRESSED) break;