From ea7836a2737080e3b77188bb4dda4fe9f378c11e Mon Sep 17 00:00:00 2001 From: DiSlord Date: Tue, 14 Jul 2020 21:30:27 +0300 Subject: [PATCH] Redefine config menu colors to new gray theme Remove not used code Reverse leveler direction on on screen keyboard --- nanovna.h | 8 ++++---- ui.c | 31 ++++++++++--------------------- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/nanovna.h b/nanovna.h index f507e68..b871872 100644 --- a/nanovna.h +++ b/nanovna.h @@ -22,9 +22,9 @@ // Need enable HAL_USE_SPI in halconf.h #define __USE_DISPLAY_DMA__ // Add RTC clock support -//#define __USE_RTC__ +#define __USE_RTC__ // Add SD card support, req enable RTC (additional settings for file system see FatFS lib ffconf.h) -//#define __USE_SD_CARD__ +#define __USE_SD_CARD__ /* * main.c @@ -402,9 +402,9 @@ extern volatile uint8_t redraw_request; #define DEFAULT_FG_COLOR RGB565(255,255,255) #define DEFAULT_BG_COLOR RGB565( 0, 0, 0) #define DEFAULT_GRID_COLOR RGB565(128,128,128) -#define DEFAULT_MENU_COLOR RGB565(255,255,255) +#define DEFAULT_MENU_COLOR RGB565(230,230,230) #define DEFAULT_MENU_TEXT_COLOR RGB565( 0, 0, 0) -#define DEFAULT_MENU_ACTIVE_COLOR RGB565(180,255,180) +#define DEFAULT_MENU_ACTIVE_COLOR RGB565(210,210,210) #define DEFAULT_TRACE_1_COLOR RGB565(255,255, 0) #define DEFAULT_TRACE_2_COLOR RGB565( 0,255,255) #define DEFAULT_TRACE_3_COLOR RGB565( 0,255, 0) diff --git a/ui.c b/ui.c index 3ab6146..8a996fc 100644 --- a/ui.c +++ b/ui.c @@ -117,6 +117,7 @@ static int8_t selection = 0; #define MT_CLOSE 0x05 #define MT_ADV_CALLBACK 0x06 +// Button definition (used in MT_ADV_CALLBACK for custom) #define BUTTON_ICON_NONE -1 #define BUTTON_ICON_NOCHECK 0 #define BUTTON_ICON_CHECK 1 @@ -133,7 +134,6 @@ static int8_t selection = 0; typedef struct Button{ uint16_t bg; uint16_t fg; - uint16_t border_color; uint8_t border; int8_t icon; } button_t; @@ -165,12 +165,6 @@ static int8_t last_touch_status = EVT_TOUCH_NONE; static int16_t last_touch_x; static int16_t last_touch_y; -//int16_t touch_cal[4] = { 1000, 1000, 10*16, 12*16 }; -//int16_t touch_cal[4] = { 620, 600, 130, 180 }; - -//int awd_count; -//int touch_x, touch_y; - #define KP_CONTINUE 0 #define KP_DONE 1 #define KP_CANCEL 2 @@ -1463,13 +1457,13 @@ draw_button(uint16_t x, uint16_t y, uint16_t w, uint16_t h, button_t *b) case BUTTON_BORDER_FALLING: bcr = RGB565(196,196,196); bcd = RGB565(255,255,255); break; case BUTTON_BORDER_FLAT: default: - bcr = bcd = b->border_color; + bcr = bcd = b->fg; break; } - ili9341_fill(x, y, w, bw, bcr); // top + ili9341_fill(x, y, w, bw, bcr); // top ili9341_fill(x + w - bw, y, bw, h, bcr); // right ili9341_fill(x, y, bw, h, bcd); // left - ili9341_fill(x, y + h - bw, w, bw, bcd); // bottom + ili9341_fill(x, y + h - bw, w, bw, bcd); // bottom } static void @@ -1478,13 +1472,10 @@ draw_keypad(void) int i = 0; button_t button; button.fg = DEFAULT_MENU_TEXT_COLOR; - button.border_color = DEFAULT_GRID_COLOR; while (keypads[i].c != KP_NONE) { - - button.bg = RGB565(230,230,230);//config.menu_normal_color; - button.border_color = DEFAULT_GRID_COLOR; + button.bg = config.menu_normal_color; if (i == selection){ - button.bg = RGB565(210,210,210);//config.menu_active_color; + button.bg = config.menu_active_color; button.border = KEYBOARD_BUTTON_BORDER|BUTTON_BORDER_FALLING; } else @@ -1682,13 +1673,12 @@ draw_menu_buttons(const menuitem_t *menu) continue; button_t button; - button.bg = RGB565(230,230,230);//config.menu_normal_color; + button.bg = config.menu_normal_color; button.fg = DEFAULT_MENU_TEXT_COLOR; - button.border_color = DEFAULT_GRID_COLOR; button.icon = BUTTON_ICON_NONE; // focus only in MENU mode but not in KEYPAD mode if (ui_mode == UI_MENU && i == selection){ - button.bg = RGB565(210,210,210);//config.menu_active_color; + button.bg = config.menu_active_color; button.border = MENU_BUTTON_BORDER|BUTTON_BORDER_FALLING; } else @@ -2300,10 +2290,10 @@ ui_process_keypad(void) status = btn_check(); if (status & (EVT_UP|EVT_DOWN)) { do { - if (status & EVT_UP) + if (status & EVT_DOWN) if (--selection < 0) selection = keypads_last_index; - if (status & EVT_DOWN) + if (status & EVT_UP) if (++selection > keypads_last_index) selection = 0; draw_keypad(); @@ -2510,7 +2500,6 @@ touch_lever_mode_select(int touch_x, int touch_y) static void ui_process_touch(void) { -// awd_count++; adc_stop(); int touch_x, touch_y; int status = touch_check();