mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2025-12-06 03:31:59 +01:00
Add comments to hanovna.h defines
Add message box function Use defines from nanovna.h for enable/disable some UI menus Move edge color to nanovna.h
This commit is contained in:
parent
bed63ca84b
commit
55ff194b90
23
nanovna.h
23
nanovna.h
|
|
@ -36,9 +36,10 @@
|
||||||
#define STOP_MAX 2700000000U
|
#define STOP_MAX 2700000000U
|
||||||
// Frequency threshold (max frequency for si5351, harmonic mode after)
|
// Frequency threshold (max frequency for si5351, harmonic mode after)
|
||||||
#define FREQUENCY_THRESHOLD 300000100U
|
#define FREQUENCY_THRESHOLD 300000100U
|
||||||
// Frequency offset (sin_cos table in dsp.c generated for 6k, 8k, 10k, if change need create new table )
|
// See AUDIO_ADC_FREQ settings, on change possible need adjust sweep timings in si5351.c for better speed
|
||||||
|
// Frequency offset for 96k ADC (sin_cos table in dsp.c generated for 6k, 8k, 10k, 12k if change need create new table )
|
||||||
#define FREQUENCY_OFFSET 8000
|
#define FREQUENCY_OFFSET 8000
|
||||||
//For 48kHz
|
// Frequency offset for 48k ADC (sin_cos table in dsp.c generated for 3k, 4k, 5k, 6k, if change need create new table )
|
||||||
//#define FREQUENCY_OFFSET 5000
|
//#define FREQUENCY_OFFSET 5000
|
||||||
// Use real time build table (undef for use constant)
|
// Use real time build table (undef for use constant)
|
||||||
//#define USE_VARIABLE_OFFSET
|
//#define USE_VARIABLE_OFFSET
|
||||||
|
|
@ -47,12 +48,15 @@
|
||||||
// pi const
|
// pi const
|
||||||
#define VNA_PI 3.14159265358979323846
|
#define VNA_PI 3.14159265358979323846
|
||||||
|
|
||||||
// Optional sweep point
|
// Maximum sweep point count (limit by flash and RAM size)
|
||||||
|
#define POINTS_COUNT 101
|
||||||
|
|
||||||
|
// Optional sweep point (in UI menu)
|
||||||
#define POINTS_SET_51 51
|
#define POINTS_SET_51 51
|
||||||
#define POINTS_SET_101 101
|
#define POINTS_SET_101 101
|
||||||
//#define POINTS_SET_201 201
|
#if POINTS_COUNT >= 201
|
||||||
// Maximum sweep point count
|
#define POINTS_SET_201 201
|
||||||
#define POINTS_COUNT 101
|
#endif
|
||||||
|
|
||||||
extern float measured[2][POINTS_COUNT][2];
|
extern float measured[2][POINTS_COUNT][2];
|
||||||
extern uint32_t frequencies[POINTS_COUNT];
|
extern uint32_t frequencies[POINTS_COUNT];
|
||||||
|
|
@ -128,7 +132,7 @@ extern const char *info_about[];
|
||||||
// Define aic3204 source clock frequency (for 8MHz used fractional multiplier, and possible little phase error)
|
// Define aic3204 source clock frequency (for 8MHz used fractional multiplier, and possible little phase error)
|
||||||
#define AUDIO_CLOCK_REF ( 8000000U)
|
#define AUDIO_CLOCK_REF ( 8000000U)
|
||||||
//#define AUDIO_CLOCK_REF (10752000U)
|
//#define AUDIO_CLOCK_REF (10752000U)
|
||||||
// Disable AIC PLL clock, use input as CODEC_CLKIN
|
// Disable AIC PLL clock, use input as CODEC_CLKIN (not stable on some devices, on long work)
|
||||||
//#define AUDIO_CLOCK_REF (86016000U)
|
//#define AUDIO_CLOCK_REF (86016000U)
|
||||||
|
|
||||||
// Define ADC sample rate
|
// Define ADC sample rate
|
||||||
|
|
@ -241,6 +245,9 @@ extern int16_t area_height;
|
||||||
#define MENU_BUTTON_BORDER 1
|
#define MENU_BUTTON_BORDER 1
|
||||||
#define KEYBOARD_BUTTON_BORDER 2
|
#define KEYBOARD_BUTTON_BORDER 2
|
||||||
|
|
||||||
|
// Define message box width
|
||||||
|
#define MESSAGE_BOX_WIDTH 180
|
||||||
|
|
||||||
// Height of numerical input field (at bottom)
|
// Height of numerical input field (at bottom)
|
||||||
#define NUM_INPUT_HEIGHT 32
|
#define NUM_INPUT_HEIGHT 32
|
||||||
|
|
||||||
|
|
@ -422,6 +429,8 @@ extern volatile uint8_t redraw_request;
|
||||||
#define DEFAULT_NORMAL_BAT_COLOR RGB565( 31,227, 0)
|
#define DEFAULT_NORMAL_BAT_COLOR RGB565( 31,227, 0)
|
||||||
#define DEFAULT_LOW_BAT_COLOR RGB565(255, 0, 0)
|
#define DEFAULT_LOW_BAT_COLOR RGB565(255, 0, 0)
|
||||||
#define DEFAULT_SPEC_INPUT_COLOR RGB565(128,255,128);
|
#define DEFAULT_SPEC_INPUT_COLOR RGB565(128,255,128);
|
||||||
|
#define DEFAULT_RISE_EDGE_COLOR RGB565(255,255,255);
|
||||||
|
#define DEFAULT_FALLEN_EDGE_COLOR RGB565(196,196,196);
|
||||||
|
|
||||||
extern uint16_t foreground_color;
|
extern uint16_t foreground_color;
|
||||||
extern uint16_t background_color;
|
extern uint16_t background_color;
|
||||||
|
|
|
||||||
65
ui.c
65
ui.c
|
|
@ -188,6 +188,7 @@ static void ui_process_numeric(void);
|
||||||
static void touch_position(int *x, int *y);
|
static void touch_position(int *x, int *y);
|
||||||
static void menu_move_back(bool leave_ui);
|
static void menu_move_back(bool leave_ui);
|
||||||
static void menu_push_submenu(const menuitem_t *submenu);
|
static void menu_push_submenu(const menuitem_t *submenu);
|
||||||
|
void drawMessageBox(char *header, char *text, uint32_t delay);
|
||||||
|
|
||||||
static int btn_check(void)
|
static int btn_check(void)
|
||||||
{
|
{
|
||||||
|
|
@ -197,7 +198,7 @@ static int btn_check(void)
|
||||||
ticks = chVTGetSystemTimeX();
|
ticks = chVTGetSystemTimeX();
|
||||||
if(ticks - last_button_down_ticks > BUTTON_DEBOUNCE_TICKS)
|
if(ticks - last_button_down_ticks > BUTTON_DEBOUNCE_TICKS)
|
||||||
break;
|
break;
|
||||||
chThdSleepMilliseconds(10);
|
chThdSleepMilliseconds(1);
|
||||||
}
|
}
|
||||||
int status = 0;
|
int status = 0;
|
||||||
uint16_t cur_button = READ_PORT() & BUTTON_MASK;
|
uint16_t cur_button = READ_PORT() & BUTTON_MASK;
|
||||||
|
|
@ -1019,12 +1020,7 @@ static UI_FUNCTION_CALLBACK(menu_sdcard_cb)
|
||||||
// shell_printf("Total time: %dms (write %d byte/sec)\r\n", time/10, total_size*10000/time);
|
// shell_printf("Total time: %dms (write %d byte/sec)\r\n", time/10, total_size*10000/time);
|
||||||
}
|
}
|
||||||
|
|
||||||
ili9341_fill(LCD_WIDTH/2-96, LCD_HEIGHT/2-30, 96*2, 60, config.menu_normal_color);
|
drawMessageBox("SAVE TRACE", res == FR_OK ? fs_filename : " Fail write ", 2000);
|
||||||
ili9341_set_foreground(DEFAULT_MENU_TEXT_COLOR);
|
|
||||||
ili9341_set_background(config.menu_normal_color);
|
|
||||||
ili9341_drawstring("SAVE TRACE", LCD_WIDTH/2-5*FONT_WIDTH, LCD_HEIGHT/2-20);
|
|
||||||
ili9341_drawstring(res == FR_OK ? fs_filename : " Fail write ", LCD_WIDTH/2-76, LCD_HEIGHT/2);
|
|
||||||
chThdSleepMilliseconds(2000);
|
|
||||||
request_to_redraw_grid();
|
request_to_redraw_grid();
|
||||||
ui_mode_normal();
|
ui_mode_normal();
|
||||||
}
|
}
|
||||||
|
|
@ -1054,6 +1050,12 @@ const menuitem_t menu_save[] = {
|
||||||
{ MT_CALLBACK, 2, "SAVE 2", menu_save_cb },
|
{ MT_CALLBACK, 2, "SAVE 2", menu_save_cb },
|
||||||
{ MT_CALLBACK, 3, "SAVE 3", menu_save_cb },
|
{ MT_CALLBACK, 3, "SAVE 3", menu_save_cb },
|
||||||
{ MT_CALLBACK, 4, "SAVE 4", menu_save_cb },
|
{ MT_CALLBACK, 4, "SAVE 4", menu_save_cb },
|
||||||
|
#if SAVEAREA_MAX > 5
|
||||||
|
{ MT_CALLBACK, 5, "SAVE 5", menu_save_cb },
|
||||||
|
#endif
|
||||||
|
#if SAVEAREA_MAX > 6
|
||||||
|
{ MT_CALLBACK, 6, "SAVE 6", menu_save_cb },
|
||||||
|
#endif
|
||||||
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
||||||
{ MT_NONE, 0, NULL, NULL } // sentinel
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
||||||
};
|
};
|
||||||
|
|
@ -1162,6 +1164,9 @@ const menuitem_t menu_display[] = {
|
||||||
const menuitem_t menu_sweep_points[] = {
|
const menuitem_t menu_sweep_points[] = {
|
||||||
{ MT_ADV_CALLBACK, POINTS_SET_51, " 51 pt", menu_points_acb },
|
{ MT_ADV_CALLBACK, POINTS_SET_51, " 51 pt", menu_points_acb },
|
||||||
{ MT_ADV_CALLBACK, POINTS_SET_101, "101 pt", menu_points_acb },
|
{ MT_ADV_CALLBACK, POINTS_SET_101, "101 pt", menu_points_acb },
|
||||||
|
#ifdef POINTS_SET_201
|
||||||
|
{ MT_ADV_CALLBACK, POINTS_SET_201, "201 pt", menu_points_acb },
|
||||||
|
#endif
|
||||||
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
||||||
{ MT_NONE, 0, NULL, NULL } // sentinel
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
||||||
};
|
};
|
||||||
|
|
@ -1234,6 +1239,12 @@ const menuitem_t menu_recall[] = {
|
||||||
{ MT_CALLBACK, 2, "RECALL 2", menu_recall_cb },
|
{ MT_CALLBACK, 2, "RECALL 2", menu_recall_cb },
|
||||||
{ MT_CALLBACK, 3, "RECALL 3", menu_recall_cb },
|
{ MT_CALLBACK, 3, "RECALL 3", menu_recall_cb },
|
||||||
{ MT_CALLBACK, 4, "RECALL 4", menu_recall_cb },
|
{ MT_CALLBACK, 4, "RECALL 4", menu_recall_cb },
|
||||||
|
#if SAVEAREA_MAX > 5
|
||||||
|
{ MT_CALLBACK, 5, "RECALL 5", menu_recall_cb },
|
||||||
|
#endif
|
||||||
|
#if SAVEAREA_MAX > 6
|
||||||
|
{ MT_CALLBACK, 6, "RECALL 6", menu_recall_cb },
|
||||||
|
#endif
|
||||||
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
||||||
{ MT_NONE, 0, NULL, NULL } // sentinel
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
||||||
};
|
};
|
||||||
|
|
@ -1459,8 +1470,8 @@ draw_button(uint16_t x, uint16_t y, uint16_t w, uint16_t h, button_t *b)
|
||||||
uint16_t bw = b->border&BUTTON_BORDER_WIDTH_MASK;
|
uint16_t bw = b->border&BUTTON_BORDER_WIDTH_MASK;
|
||||||
ili9341_fill(x + bw, y + bw, w - (bw * 2), h - (bw * 2), b->bg);
|
ili9341_fill(x + bw, y + bw, w - (bw * 2), h - (bw * 2), b->bg);
|
||||||
if (bw==0) return;
|
if (bw==0) return;
|
||||||
uint16_t br = RGB565(255,255,255);
|
uint16_t br = DEFAULT_RISE_EDGE_COLOR;
|
||||||
uint16_t bd = RGB565(196,196,196);
|
uint16_t bd = DEFAULT_FALLEN_EDGE_COLOR;
|
||||||
uint16_t type = b->border;
|
uint16_t type = b->border;
|
||||||
ili9341_fill(x, y, w, bw, type&BUTTON_BORDER_TOP ? br : bd); // top
|
ili9341_fill(x, y, w, bw, type&BUTTON_BORDER_TOP ? br : bd); // top
|
||||||
ili9341_fill(x + w - bw, y, bw, h, type&BUTTON_BORDER_RIGHT ? br : bd); // right
|
ili9341_fill(x + w - bw, y, bw, h, type&BUTTON_BORDER_RIGHT ? br : bd); // right
|
||||||
|
|
@ -1468,6 +1479,21 @@ draw_button(uint16_t x, uint16_t y, uint16_t w, uint16_t h, button_t *b)
|
||||||
ili9341_fill(x, y + h - bw, w, bw, type&BUTTON_BORDER_BOTTOM ? br : bd); // bottom
|
ili9341_fill(x, y + h - bw, w, bw, type&BUTTON_BORDER_BOTTOM ? br : bd); // bottom
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void drawMessageBox(char *header, char *text, uint32_t delay){
|
||||||
|
button_t b;
|
||||||
|
b.bg = config.menu_normal_color;
|
||||||
|
b.fg = DEFAULT_MENU_TEXT_COLOR;
|
||||||
|
b.border = BUTTON_BORDER_FLAT|1;
|
||||||
|
draw_button((LCD_WIDTH-MESSAGE_BOX_WIDTH)/2, LCD_HEIGHT/2-40, MESSAGE_BOX_WIDTH, 60, &b);
|
||||||
|
ili9341_fill((LCD_WIDTH-MESSAGE_BOX_WIDTH)/2+3, LCD_HEIGHT/2-40+FONT_STR_HEIGHT+8, MESSAGE_BOX_WIDTH-6, 60-FONT_STR_HEIGHT-8-3, DEFAULT_FG_COLOR);
|
||||||
|
ili9341_set_foreground(b.fg);
|
||||||
|
ili9341_set_background(b.bg);
|
||||||
|
ili9341_drawstring(header, (LCD_WIDTH-MESSAGE_BOX_WIDTH)/2 + 10, LCD_HEIGHT/2-40 + 5);
|
||||||
|
ili9341_set_background(DEFAULT_FG_COLOR);
|
||||||
|
ili9341_drawstring(text, (LCD_WIDTH-MESSAGE_BOX_WIDTH)/2 + 20, LCD_HEIGHT/2-40 + FONT_STR_HEIGHT + 8 + 14);
|
||||||
|
chThdSleepMilliseconds(delay);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
draw_keypad(void)
|
draw_keypad(void)
|
||||||
{
|
{
|
||||||
|
|
@ -1651,19 +1677,7 @@ static const uint16_t check_box[] = {
|
||||||
0b0000100000010000,
|
0b0000100000010000,
|
||||||
0b0000010000100000,
|
0b0000010000100000,
|
||||||
0b0000001111000000,
|
0b0000001111000000,
|
||||||
/*
|
|
||||||
0b0000000000000000,
|
|
||||||
0b0000001111000000,
|
|
||||||
0b0000010000100000,
|
|
||||||
0b0000100000010000,
|
|
||||||
0b0001000110001000,
|
|
||||||
0b0001001111001000,
|
|
||||||
0b0001001111001000,
|
|
||||||
0b0001000110001000,
|
|
||||||
0b0000100000010000,
|
|
||||||
0b0000010000100000,
|
|
||||||
0b0000001111000000,
|
|
||||||
*/
|
|
||||||
0b0000000000000000,
|
0b0000000000000000,
|
||||||
0b0000001111000000,
|
0b0000001111000000,
|
||||||
0b0000010000100000,
|
0b0000010000100000,
|
||||||
|
|
@ -2484,13 +2498,8 @@ made_screenshot(int touch_x, int touch_y)
|
||||||
}
|
}
|
||||||
// time = chVTGetSystemTimeX() - time;
|
// time = chVTGetSystemTimeX() - time;
|
||||||
// shell_printf("Total time: %dms (write %d byte/sec)\r\n", time/10, (LCD_WIDTH*LCD_HEIGHT*sizeof(uint16_t)+sizeof(bmp_header_v4))*10000/time);
|
// shell_printf("Total time: %dms (write %d byte/sec)\r\n", time/10, (LCD_WIDTH*LCD_HEIGHT*sizeof(uint16_t)+sizeof(bmp_header_v4))*10000/time);
|
||||||
ili9341_fill(LCD_WIDTH/2-96, LCD_HEIGHT/2-30, 96*2, 60, config.menu_normal_color);
|
drawMessageBox("SCREENSHOT", res == FR_OK ? fs_filename : " Fail write ", 2000);
|
||||||
ili9341_set_foreground(DEFAULT_MENU_TEXT_COLOR);
|
|
||||||
ili9341_set_background(config.menu_normal_color);
|
|
||||||
ili9341_drawstring("SCREENSHOT", LCD_WIDTH/2-5*FONT_WIDTH, LCD_HEIGHT/2-20);
|
|
||||||
ili9341_drawstring(res == FR_OK ? fs_filename : " Fail write ", LCD_WIDTH/2-76, LCD_HEIGHT/2);
|
|
||||||
request_to_redraw_grid();
|
request_to_redraw_grid();
|
||||||
chThdSleepMilliseconds(2000);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue