mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2025-12-06 03:31:59 +01:00
move menu_color and touch_cal to config
This commit is contained in:
parent
7943a3fe96
commit
3852f9cb21
9
main.c
9
main.c
|
|
@ -320,7 +320,10 @@ config_t config = {
|
||||||
/* magic */ CONFIG_MAGIC,
|
/* magic */ CONFIG_MAGIC,
|
||||||
/* dac_value */ 1922,
|
/* dac_value */ 1922,
|
||||||
/* grid_color */ 0x1084,
|
/* grid_color */ 0x1084,
|
||||||
/* trace_colors */ { RGB565(0,255,255), RGB565(255,0,40), RGB565(0,0,255), RGB565(50,255,0) },
|
/* menu_normal_color */ 0xffff,
|
||||||
|
/* menu_active_color */ 0x7777,
|
||||||
|
/* trace_colors[4] */ { RGB565(0,255,255), RGB565(255,0,40), RGB565(0,0,255), RGB565(50,255,0) },
|
||||||
|
/* touch_cal[4] */ { 620, 600, 130, 180 },
|
||||||
/* checksum */ 0
|
/* checksum */ 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1137,7 +1140,7 @@ static void cmd_touchcal(BaseSequentialStream *chp, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(void)argv;
|
||||||
extern int16_t touch_cal[4];
|
//extern int16_t touch_cal[4];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
chprintf(chp, "first touch upper left, then lower right...");
|
chprintf(chp, "first touch upper left, then lower right...");
|
||||||
|
|
@ -1146,7 +1149,7 @@ static void cmd_touchcal(BaseSequentialStream *chp, int argc, char *argv[])
|
||||||
|
|
||||||
chprintf(chp, "touch cal params: ");
|
chprintf(chp, "touch cal params: ");
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
chprintf(chp, "%d ", touch_cal[i]);
|
chprintf(chp, "%d ", config.touch_cal[i]);
|
||||||
}
|
}
|
||||||
chprintf(chp, "\r\n");
|
chprintf(chp, "\r\n");
|
||||||
touch_start_watchdog();
|
touch_start_watchdog();
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,10 @@ typedef struct {
|
||||||
int32_t magic;
|
int32_t magic;
|
||||||
uint16_t dac_value;
|
uint16_t dac_value;
|
||||||
uint16_t grid_color;
|
uint16_t grid_color;
|
||||||
|
uint16_t menu_normal_color;
|
||||||
|
uint16_t menu_active_color;
|
||||||
uint16_t trace_color[TRACES_MAX];
|
uint16_t trace_color[TRACES_MAX];
|
||||||
|
int16_t touch_cal[4];
|
||||||
int32_t checksum;
|
int32_t checksum;
|
||||||
} config_t;
|
} config_t;
|
||||||
|
|
||||||
|
|
|
||||||
22
ui.c
22
ui.c
|
|
@ -82,7 +82,7 @@ int8_t last_touch_status = FALSE;
|
||||||
int16_t last_touch_x;
|
int16_t last_touch_x;
|
||||||
int16_t last_touch_y;
|
int16_t last_touch_y;
|
||||||
//int16_t touch_cal[4] = { 1000, 1000, 10*16, 12*16 };
|
//int16_t touch_cal[4] = { 1000, 1000, 10*16, 12*16 };
|
||||||
int16_t touch_cal[4] = { 620, 600, 130, 180 };
|
//int16_t touch_cal[4] = { 620, 600, 130, 180 };
|
||||||
#define EVT_TOUCH_NONE 0
|
#define EVT_TOUCH_NONE 0
|
||||||
#define EVT_TOUCH_DOWN 1
|
#define EVT_TOUCH_DOWN 1
|
||||||
#define EVT_TOUCH_PRESSED 2
|
#define EVT_TOUCH_PRESSED 2
|
||||||
|
|
@ -294,17 +294,17 @@ touch_cal_exec(void)
|
||||||
x2 = last_touch_x;
|
x2 = last_touch_x;
|
||||||
y2 = last_touch_y;
|
y2 = last_touch_y;
|
||||||
|
|
||||||
touch_cal[0] = x1;
|
config.touch_cal[0] = x1;
|
||||||
touch_cal[1] = y1;
|
config.touch_cal[1] = y1;
|
||||||
touch_cal[2] = (x2 - x1) * 16 / 320;
|
config.touch_cal[2] = (x2 - x1) * 16 / 320;
|
||||||
touch_cal[3] = (y2 - y1) * 16 / 240;
|
config.touch_cal[3] = (y2 - y1) * 16 / 240;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
touch_position(int *x, int *y)
|
touch_position(int *x, int *y)
|
||||||
{
|
{
|
||||||
*x = (last_touch_x - touch_cal[0]) * 16 / touch_cal[2];
|
*x = (last_touch_x - config.touch_cal[0]) * 16 / config.touch_cal[2];
|
||||||
*y = (last_touch_y - touch_cal[1]) * 16 / touch_cal[3];
|
*y = (last_touch_y - config.touch_cal[1]) * 16 / config.touch_cal[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -800,9 +800,9 @@ draw_keypad(void)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (keypads[i].x) {
|
while (keypads[i].x) {
|
||||||
uint16_t bg = 0xffff;
|
uint16_t bg = config.menu_normal_color;
|
||||||
if (i == selection)
|
if (i == selection)
|
||||||
bg = 0x7777;
|
bg = config.menu_active_color;
|
||||||
ili9341_fill(keypads[i].x, keypads[i].y, 44, 44, bg);
|
ili9341_fill(keypads[i].x, keypads[i].y, 44, 44, bg);
|
||||||
ili9341_drawfont(keypads[i].c, &NF20x24, keypads[i].x+12, keypads[i].y+10, 0x0000, bg);
|
ili9341_drawfont(keypads[i].c, &NF20x24, keypads[i].x+12, keypads[i].y+10, 0x0000, bg);
|
||||||
i++;
|
i++;
|
||||||
|
|
@ -858,10 +858,10 @@ draw_menu_buttons(const menuitem_t *menu)
|
||||||
if (menu[i].type == MT_BLANK)
|
if (menu[i].type == MT_BLANK)
|
||||||
continue;
|
continue;
|
||||||
int y = 32*i;
|
int y = 32*i;
|
||||||
uint16_t bg = 0xffff;
|
uint16_t bg = config.menu_normal_color;
|
||||||
// focus only in MENU mode but not in KEYPAD mode
|
// focus only in MENU mode but not in KEYPAD mode
|
||||||
if (ui_mode == UI_MENU && i == selection)
|
if (ui_mode == UI_MENU && i == selection)
|
||||||
bg = 0x7777;
|
bg = config.menu_active_color;
|
||||||
ili9341_fill(320-60, y, 60, 30, bg);
|
ili9341_fill(320-60, y, 60, 30, bg);
|
||||||
if (menu_is_multiline(menu[i].label, &l1, &l2)) {
|
if (menu_is_multiline(menu[i].label, &l1, &l2)) {
|
||||||
ili9341_drawstring_5x7(l1, 320-54, y+8, 0x0000, bg);
|
ili9341_drawstring_5x7(l1, 320-54, y+8, 0x0000, bg);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue