mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2025-12-06 03:31:59 +01:00
Implement color command, allow change color settings in config (enabled bu default ENABLE_COLOR_COMMAND)
Usage: usage: color {id} {rgb24}
- Grid color: id = -3
- Menu bg color: id = -2
- Selected menu: id = -1
- Trace 1-4: id = 0..3
Color in hex RGB format (but possible any type input, dec, hex, bin. oct)
This commit is contained in:
parent
6f25d0d43f
commit
8bdb650212
58
main.c
58
main.c
|
|
@ -58,10 +58,16 @@ static uint16_t shell_nargs;
|
||||||
static volatile vna_shellcmd_t shell_function = 0;
|
static volatile vna_shellcmd_t shell_function = 0;
|
||||||
|
|
||||||
//#define ENABLED_DUMP
|
//#define ENABLED_DUMP
|
||||||
|
// Allow get threads debug info
|
||||||
//#define ENABLE_THREADS_COMMAND
|
//#define ENABLE_THREADS_COMMAND
|
||||||
|
// RTC time not used
|
||||||
//#define ENABLE_TIME_COMMAND
|
//#define ENABLE_TIME_COMMAND
|
||||||
|
// Enable vbat_offset command, allow change battery voltage correction in config
|
||||||
#define ENABLE_VBAT_OFFSET_COMMAND
|
#define ENABLE_VBAT_OFFSET_COMMAND
|
||||||
|
// Info about NanoVNA, need fore soft
|
||||||
#define ENABLE_INFO_COMMAND
|
#define ENABLE_INFO_COMMAND
|
||||||
|
// Enable color command, allow change config color for traces, grid, menu
|
||||||
|
#define ENABLE_COLOR_COMMAND
|
||||||
|
|
||||||
static void apply_error_term_at(int i);
|
static void apply_error_term_at(int i);
|
||||||
static void apply_edelay_at(int i);
|
static void apply_edelay_at(int i);
|
||||||
|
|
@ -1930,6 +1936,55 @@ VNA_SHELL_FUNCTION(cmd_info)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_COLOR_COMMAND
|
||||||
|
VNA_SHELL_FUNCTION(cmd_color)
|
||||||
|
{
|
||||||
|
uint32_t color;
|
||||||
|
int i;
|
||||||
|
if (argc != 2) {
|
||||||
|
shell_printf("usage: color {id} {rgb24}\r\n");
|
||||||
|
for (i=-3; i < TRACES_MAX; i++) {
|
||||||
|
#if 0
|
||||||
|
switch(i){
|
||||||
|
case -3: color = config.grid_color; break;
|
||||||
|
case -2: color = config.menu_normal_color; break;
|
||||||
|
case -1: color = config.menu_active_color; break;
|
||||||
|
default: color = config.trace_color[i];break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// WARNING!!! Dirty hack for size, depend from config struct
|
||||||
|
color = config.trace_color[i];
|
||||||
|
#endif
|
||||||
|
color = ((color >> 3) & 0x001c00) |
|
||||||
|
((color >> 5) & 0x0000f8) |
|
||||||
|
((color << 16) & 0xf80000) |
|
||||||
|
((color << 13) & 0x00e000);
|
||||||
|
// color = (color>>8)|(color<<8);
|
||||||
|
// color = ((color<<8)&0xF80000)|((color<<5)&0x00FC00)|((color<<3)&0x0000F8);
|
||||||
|
shell_printf(" %d: 0x%06x\r\n", i, color);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
i = my_atoi(argv[0]);
|
||||||
|
if (i < -3 && i >= TRACES_MAX)
|
||||||
|
return;
|
||||||
|
color = RGBHEX(my_atoui(argv[1]));
|
||||||
|
#if 0
|
||||||
|
switch(i){
|
||||||
|
case -3: config.grid_color = color; break;
|
||||||
|
case -2: config.menu_normal_color = color; break;
|
||||||
|
case -1: config.menu_active_color = color; break;
|
||||||
|
default: config.trace_color[i] = color;break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// WARNING!!! Dirty hack for size, depend from config struct
|
||||||
|
config.trace_color[i] = color;
|
||||||
|
#endif
|
||||||
|
// Redraw all
|
||||||
|
redraw_request|= REDRAW_AREA;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_THREADS_COMMAND
|
#ifdef ENABLE_THREADS_COMMAND
|
||||||
#if CH_CFG_USE_REGISTRY == FALSE
|
#if CH_CFG_USE_REGISTRY == FALSE
|
||||||
#error "Threads Requite enabled CH_CFG_USE_REGISTRY in chconf.h"
|
#error "Threads Requite enabled CH_CFG_USE_REGISTRY in chconf.h"
|
||||||
|
|
@ -2020,6 +2075,9 @@ static const VNAShellCommand commands[] =
|
||||||
#ifdef ENABLE_INFO_COMMAND
|
#ifdef ENABLE_INFO_COMMAND
|
||||||
{"info" , cmd_info , 0},
|
{"info" , cmd_info , 0},
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ENABLE_COLOR_COMMAND
|
||||||
|
{"color" , cmd_color , 0},
|
||||||
|
#endif
|
||||||
#ifdef ENABLE_THREADS_COMMAND
|
#ifdef ENABLE_THREADS_COMMAND
|
||||||
{"threads" , cmd_threads , 0},
|
{"threads" , cmd_threads , 0},
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
8
ui.c
8
ui.c
|
|
@ -1250,9 +1250,9 @@ draw_keypad(void)
|
||||||
static void
|
static void
|
||||||
draw_numeric_area_frame(void)
|
draw_numeric_area_frame(void)
|
||||||
{
|
{
|
||||||
ili9341_fill(0, 240-NUM_INPUT_HEIGHT, 320, NUM_INPUT_HEIGHT, DEFAULT_MENU_COLOR);
|
ili9341_fill(0, 240-NUM_INPUT_HEIGHT, 320, NUM_INPUT_HEIGHT, config.menu_normal_color);
|
||||||
setForegroundColor(DEFAULT_MENU_TEXT_COLOR);
|
setForegroundColor(DEFAULT_MENU_TEXT_COLOR);
|
||||||
setBackgroundColor(DEFAULT_MENU_COLOR);
|
setBackgroundColor(config.menu_normal_color);
|
||||||
ili9341_drawstring(keypad_mode_label[keypad_mode], 10, 240-(FONT_GET_HEIGHT+NUM_INPUT_HEIGHT)/2);
|
ili9341_drawstring(keypad_mode_label[keypad_mode], 10, 240-(FONT_GET_HEIGHT+NUM_INPUT_HEIGHT)/2);
|
||||||
//ili9341_drawfont(KP_KEYPAD, 300, 216);
|
//ili9341_drawfont(KP_KEYPAD, 300, 216);
|
||||||
}
|
}
|
||||||
|
|
@ -1267,7 +1267,7 @@ draw_numeric_input(const char *buf)
|
||||||
|
|
||||||
for (i = 0, x = 64; i < 10 && buf[i]; i++, xsim<<=1) {
|
for (i = 0, x = 64; i < 10 && buf[i]; i++, xsim<<=1) {
|
||||||
uint16_t fg = DEFAULT_MENU_TEXT_COLOR;
|
uint16_t fg = DEFAULT_MENU_TEXT_COLOR;
|
||||||
uint16_t bg = DEFAULT_MENU_COLOR;
|
uint16_t bg = config.menu_normal_color;
|
||||||
int c = buf[i];
|
int c = buf[i];
|
||||||
if (c == '.')
|
if (c == '.')
|
||||||
c = KP_PERIOD;
|
c = KP_PERIOD;
|
||||||
|
|
@ -1294,7 +1294,7 @@ draw_numeric_input(const char *buf)
|
||||||
x += xsim&0x8000 ? NUM_FONT_GET_WIDTH+2+8 : NUM_FONT_GET_WIDTH+2;
|
x += xsim&0x8000 ? NUM_FONT_GET_WIDTH+2+8 : NUM_FONT_GET_WIDTH+2;
|
||||||
}
|
}
|
||||||
// erase last
|
// erase last
|
||||||
ili9341_fill(x, 240-NUM_INPUT_HEIGHT+4, NUM_FONT_GET_WIDTH+2+8, NUM_FONT_GET_WIDTH+2+8, DEFAULT_MENU_COLOR);
|
ili9341_fill(x, 240-NUM_INPUT_HEIGHT+4, NUM_FONT_GET_WIDTH+2+8, NUM_FONT_GET_WIDTH+2+8, config.menu_normal_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue