Menu update

tinySA
erikkaashoek 6 years ago
parent ae326020e3
commit 4683b88d0c

@ -117,7 +117,7 @@ const char *info_about[]={
0 // sentinel 0 // sentinel
}; };
static THD_WORKING_AREA(waThread1, 750); static THD_WORKING_AREA(waThread1, 730);
static THD_FUNCTION(Thread1, arg) static THD_FUNCTION(Thread1, arg)
{ {
(void)arg; (void)arg;
@ -2140,7 +2140,7 @@ VNA_SHELL_FUNCTION(cmd_threads)
thread_t *tp; thread_t *tp;
(void)argc; (void)argc;
(void)argv; (void)argv;
shell_printf("stklimit| stack|stk free| addr|refs|prio| state| name"VNA_SHELL_NEWLINE_STR); shell_printf("stklimit| |stk free| addr|refs|prio| state| name"VNA_SHELL_NEWLINE_STR);
tp = chRegFirstThread(); tp = chRegFirstThread();
do { do {
uint32_t max_stack_use = 0U; uint32_t max_stack_use = 0U;

36
ui.c

@ -434,10 +434,13 @@ enum {
MT_CALLBACK, MT_CALLBACK,
MT_CANCEL, MT_CANCEL,
MT_TITLE, MT_TITLE,
MT_CLOSE MT_CLOSE,
MT_KEYPAD
}; };
#define MT_FORM 0x80 // Or with menu type to get large button with current value #define MT_FORM 0x80 // Or with menu type to get large button with current value
#define MT_MASK(x) (0x7F & (x)) #define MT_BACK 0x40
#define MT_LEAVE 0x20
#define MT_MASK(x) (0xF & (x))
typedef void (*menuaction_cb_t)(int item, uint8_t data); typedef void (*menuaction_cb_t)(int item, uint8_t data);
@ -767,15 +770,15 @@ menu_marker_op_cb(int item, uint8_t data)
static void static void
menu_marker_search_cb(int item, uint8_t data) menu_marker_search_cb(int item, uint8_t data)
{ {
(void)data; (void)item;
int i = -1; int i = -1;
if (active_marker == -1) if (active_marker == -1)
return; return;
switch (item) { switch (data) {
case 0: /* maximum */ case 0: /* maximum */
case 1: /* minimum */ case 1: /* minimum */
set_marker_search(item); set_marker_search(data);
i = marker_search(); i = marker_search();
break; break;
case 2: /* search Left */ case 2: /* search Left */
@ -1145,10 +1148,11 @@ menu_move_top(void)
static void static void
menu_invoke(int item) menu_invoke(int item)
{ {
int status;
const menuitem_t *menu = menu_stack[menu_current_level]; const menuitem_t *menu = menu_stack[menu_current_level];
menu = &menu[item]; menu = &menu[item];
switch (menu->type & 0x0f) { switch (MT_MASK(menu->type)) {
case MT_NONE: case MT_NONE:
case MT_BLANK: case MT_BLANK:
case MT_CLOSE: case MT_CLOSE:
@ -1164,12 +1168,30 @@ menu_invoke(int item)
if (cb == NULL) if (cb == NULL)
return; return;
(*cb)(item, menu->data); (*cb)(item, menu->data);
if (!(menu->type & MT_FORM))
draw_cal_status();
break; break;
} }
case MT_SUBMENU: case MT_SUBMENU:
menu_push_submenu((const menuitem_t*)menu->reference); menu_push_submenu((const menuitem_t*)menu->reference);
break; break;
case MT_KEYPAD:
status = btn_wait_release();
if (status & EVT_BUTTON_DOWN_LONG) {
ui_mode_numeric(menu->data);
// ui_process_numeric();
} else {
if (menu->type & MT_FORM) {
area_width = AREA_WIDTH_NORMAL - MENU_BUTTON_WIDTH;
redraw_frame(); // Remove form numbers
}
ui_mode_keypad(menu->data);
ui_process_keypad();
}
draw_cal_status();
break;
} }
} }
@ -1482,7 +1504,7 @@ draw_menu_buttons(const menuitem_t *menu)
if (menu[i].type & MT_FORM) { if (menu[i].type & MT_FORM) {
active_button_start = 320 - MENU_FORM_WIDTH; active_button_start = 320 - MENU_FORM_WIDTH;
active_button_width = MENU_FORM_WIDTH - 30; // Shorten at the right active_button_width = MENU_FORM_WIDTH - 30; // Shorten at the right
if (MT_MASK(menu[i].type) == MT_CALLBACK) { // Only callback can have value if (MT_MASK(menu[i].type) == MT_KEYPAD) { // Only keypad retrieves value
keypad_mode = menu[i].data; keypad_mode = menu[i].data;
fetch_numeric_target(); fetch_numeric_target();
} }

@ -228,7 +228,7 @@ void menu_autosettings_cb(int item, uint8_t data)
dirty = true; dirty = true;
// menu_move_back(); // stay in input menu // menu_move_back(); // stay in input menu
ui_mode_normal(); ui_mode_normal();
draw_cal_status(); // draw_cal_status();
} }
static void menu_calibrate_cb(int item, uint8_t data) static void menu_calibrate_cb(int item, uint8_t data)
@ -285,16 +285,18 @@ static void menu_dfu_cb(int item, uint8_t data)
} }
} }
int menu_modulation_value[]={0, MO_NONE,MO_AM, MO_NFM, MO_WFM};
char *menu_modulation_text[]={"NONE","AM","NARROW FM","WIDE FM"}; const int menu_modulation_value[]={MO_NONE,MO_AM, MO_NFM, MO_WFM};
const char *menu_modulation_text[]={"NONE","AM","NARROW FM","WIDE FM"};
static void menu_modulation_cb(int item, uint8_t data) static void menu_modulation_cb(int item, uint8_t data)
{ {
(void)data; (void)item;
//Serial.println(item); //Serial.println(item);
SetModulation(menu_modulation_value[item]); SetModulation(menu_modulation_value[data]);
menu_move_back(); menu_move_back();
// ui_mode_normal(); // Stay in menu mode // ui_mode_normal(); // Stay in menu mode
draw_cal_status(); // draw_cal_status();
} }
@ -302,24 +304,29 @@ const int menu_reffer_value[]={-1,0,1,2,3,4,5,6};
const char *menu_reffer_text[]={"OFF","30MHz","15MHz","10MHz","4MHz","3MHz","2MHz","1MHz"}; const char *menu_reffer_text[]={"OFF","30MHz","15MHz","10MHz","4MHz","3MHz","2MHz","1MHz"};
static void menu_reffer_cb(int item, uint8_t data) static void menu_reffer_cb(int item, uint8_t data)
{ {
(void)data; (void)item;
//Serial.println(item); //Serial.println(item);
set_refer_output(menu_reffer_value[item]); set_refer_output(menu_reffer_value[data]);
menu_move_back(); menu_move_back();
// ui_mode_normal(); // Stay in menu mode // ui_mode_normal(); // Stay in menu mode
draw_cal_status(); // draw_cal_status();
} }
static void menu_reffer_cb2(int item, uint8_t data) const int menu_drive_value[]={5,10,15,20};
const char *menu_drive_text[]={"5dBm","10dBm","15dBm","20dBm"};
static void menu_drive_cb(int item, uint8_t data)
{ {
(void)data; (void)item;
//Serial.println(item); //Serial.println(item);
set_refer_output(menu_reffer_value[item+5]); SetDrive(data);
menu_move_back(); menu_move_back();
// ui_mode_normal(); // Stay in menu mode // ui_mode_normal();
draw_cal_status(); // draw_cal_status();
} }
static void menu_spur_cb(int item, uint8_t data) static void menu_spur_cb(int item, uint8_t data)
{ {
(void)data; (void)data;
@ -337,8 +344,8 @@ static void menu_spur_cb(int item, uint8_t data)
static void menu_storage_cb(int item, uint8_t data) static void menu_storage_cb(int item, uint8_t data)
{ {
(void)data; (void)item;
switch(item) { switch(data) {
case 0: case 0:
SetStorage(); SetStorage();
break; break;
@ -354,7 +361,7 @@ static void menu_storage_cb(int item, uint8_t data)
} }
menu_move_back(); menu_move_back();
ui_mode_normal(); ui_mode_normal();
draw_cal_status(); // draw_cal_status();
} }
static void menu_average_cb(int item, uint8_t data) static void menu_average_cb(int item, uint8_t data)
@ -368,16 +375,16 @@ static void menu_average_cb(int item, uint8_t data)
static void menu_marker_type_cb(int item, uint8_t data) static void menu_marker_type_cb(int item, uint8_t data)
{ {
(void)data; (void)item;
if (markers[active_marker].enabled) if (markers[active_marker].enabled)
{ {
if (item == M_REFERENCE) { if (data == M_REFERENCE) {
for (int i = 0; i<MARKER_COUNT; i++ ) { for (int i = 0; i<MARKER_COUNT; i++ ) {
if (markers[i].mtype ==M_REFERENCE) if (markers[i].mtype ==M_REFERENCE)
markers[i].mtype = M_NORMAL; markers[i].mtype = M_NORMAL;
} }
} }
markers[active_marker].mtype = item; markers[active_marker].mtype = data;
} }
markmap_all_markers(); markmap_all_markers();
// redraw_marker(active_marker, TRUE); // redraw_marker(active_marker, TRUE);
@ -390,22 +397,22 @@ const int rbwsel[]={0,3,10,30,100,300};
static void menu_rbw_cb(int item, uint8_t data) static void menu_rbw_cb(int item, uint8_t data)
{ {
(void)data; (void)item;
SetRBW(rbwsel[item]); SetRBW(rbwsel[data]);
menu_move_back(); menu_move_back();
ui_mode_normal(); ui_mode_normal();
draw_cal_status(); // draw_cal_status();
} }
int menu_dBper_value[]={1,2,5,10,20}; int menu_dBper_value[]={1,2,5,10,20};
static void menu_dBper_cb(int item, uint8_t data) static void menu_dBper_cb(int item, uint8_t data)
{ {
(void)data; (void)item;
SetScale(menu_dBper_value[item]); SetScale(menu_dBper_value[data]);
menu_move_back(); menu_move_back();
ui_mode_normal(); ui_mode_normal();
draw_cal_status(); // draw_cal_status();
} }
#if 0 #if 0
@ -433,87 +440,6 @@ static void choose_active_marker(void)
active_marker = -1; active_marker = -1;
} }
static void menu_scale_cb(int item, uint8_t data)
{
(void)item;
int status;
status = btn_wait_release();
if (status & EVT_BUTTON_DOWN_LONG) {
ui_mode_numeric(data);
// ui_process_numeric();
} else {
ui_mode_keypad(data);
ui_process_keypad();
}
draw_cal_status();
}
static void menu_lowoutputmode_cb(int item, uint8_t data)
{
int status;
int km = data;
(void) item;
// if (km == KM_SCALE && trace[uistat.current_trace].type == TRC_DELAY) {
// km = KM_SCALEDELAY;
// }
status = btn_wait_release();
if (item == 3) {
menu_push_submenu(menu_modulation);
} else
{
if (status & EVT_BUTTON_DOWN_LONG) {
ui_mode_numeric(km);
// ui_process_numeric();
} else {
area_width = AREA_WIDTH_NORMAL - MENU_BUTTON_WIDTH;
redraw_frame(); // Remove form numbers
ui_mode_keypad(km);
ui_process_keypad();
}
}
draw_cal_status();
}
#if 0
static void menu_highoutputmode_cb(int item, uint8_t data)
{
int status;
int km = data;
(void) item;
// if (km == KM_SCALE && trace[uistat.current_trace].type == TRC_DELAY) {
// km = KM_SCALEDELAY;
// }
status = btn_wait_release();
if (status & EVT_BUTTON_DOWN_LONG) {
ui_mode_numeric(km);
// ui_process_numeric();
} else {
area_width = AREA_WIDTH_NORMAL - MENU_BUTTON_WIDTH;
redraw_frame(); // Remove form numbers
ui_mode_keypad(km);
ui_process_keypad();
}
draw_cal_status();
}
#endif
static void menu_settings_cb(int item, uint8_t data)
{
(void)item;
int status;
status = btn_wait_release();
if (status & EVT_BUTTON_DOWN_LONG) {
ui_mode_numeric(data);
// ui_process_numeric();
} else {
ui_mode_keypad(data);
ui_process_keypad();
}
draw_cal_status();
}
static void menu_settings2_cb(int item, uint8_t data) static void menu_settings2_cb(int item, uint8_t data)
{ {
(void)data; (void)data;
@ -528,65 +454,64 @@ static void menu_settings2_cb(int item, uint8_t data)
toggle_tracking(); toggle_tracking();
break; break;
} }
draw_cal_status();
draw_menu(); draw_menu();
// draw_cal_status();
} }
static void menu_stimulus_cb(int item, uint8_t data) static void menu_pause_cb(int item, uint8_t data)
{ {
(void) data; (void) data;
int status; (void) item;
int km = item+KM_START;
switch (km) {
case KM_START: /* START */
case KM_STOP: /* STOP */
case KM_CENTER: /* CENTER */
case KM_SPAN: /* SPAN */
case KM_CW: /* CW */
status = btn_wait_release();
if (status & EVT_BUTTON_DOWN_LONG) {
ui_mode_numeric(km);
// ui_process_numeric();
} else {
ui_mode_keypad(km);
ui_process_keypad();
}
break;
case KM_CW+1: /* PAUSE */
toggle_sweep(); toggle_sweep();
menu_move_back(); menu_move_back();
ui_mode_normal(); ui_mode_normal();
draw_menu(); draw_menu();
break; // draw_cal_status();
}
draw_cal_status();
} }
// ===[MENU DEFINITION]========================================================= // ===[MENU DEFINITION]=========================================================
static const menuitem_t menu_drive[] = {
{ MT_CALLBACK, 0, " 5dBm", menu_drive_cb},
{ MT_CALLBACK, 1, " 10dBm", menu_drive_cb},
{ MT_CALLBACK, 2, " 15dBm", menu_drive_cb},
{ MT_CALLBACK, 3, " 20dBm", menu_drive_cb},
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel
};
static const menuitem_t menu_drive_wide[] = {
{ MT_FORM | MT_CALLBACK, 0, " 5dBm", menu_drive_cb},
{ MT_FORM | MT_CALLBACK, 1, " 10dBm", menu_drive_cb},
{ MT_FORM | MT_CALLBACK, 2, " 15dBm", menu_drive_cb},
{ MT_FORM | MT_CALLBACK, 3, " 20dBm", menu_drive_cb},
{ MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel
};
const menuitem_t menu_modulation[] = { const menuitem_t menu_modulation[] = {
{ MT_FORM | MT_TITLE, 0, "MODULATION",NULL}, { MT_FORM | MT_TITLE, 0, "MODULATION",NULL},
{ MT_FORM | MT_CALLBACK, 0, "NONE", menu_modulation_cb}, { MT_FORM | MT_CALLBACK, 0, "NONE", menu_modulation_cb},
{ MT_FORM | MT_CALLBACK, 0, "AM", menu_modulation_cb}, { MT_FORM | MT_CALLBACK, 1, "AM", menu_modulation_cb},
{ MT_FORM | MT_CALLBACK, 0, "NARROW FM", menu_modulation_cb}, { MT_FORM | MT_CALLBACK, 2, "NARROW FM", menu_modulation_cb},
{ MT_FORM | MT_CALLBACK, 0, "WIDE FM", menu_modulation_cb}, { MT_FORM | MT_CALLBACK, 3, "WIDE FM", menu_modulation_cb},
{ MT_FORM | MT_CANCEL, 0, S_LARROW" BACK",NULL }, { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK",NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
const menuitem_t menu_lowoutputmode[] = { const menuitem_t menu_lowoutputmode[] = {
{ MT_FORM | MT_TITLE, 0, "LOW OUTPUT", NULL}, { MT_FORM | MT_TITLE, 0, "LOW OUTPUT", NULL},
{ MT_FORM | MT_CALLBACK, KM_CENTER, "FREQ: %s", menu_lowoutputmode_cb}, { MT_FORM | MT_KEYPAD, KM_CENTER, "FREQ: %s", NULL},
{ MT_FORM | MT_CALLBACK, KM_LOWOUTLEVEL, "LEVEL: %s", menu_lowoutputmode_cb}, { MT_FORM | MT_KEYPAD, KM_LOWOUTLEVEL, "LEVEL: %s", NULL},
{ MT_FORM | MT_SUBMENU, 0, "MODULATION: %s", menu_modulation}, { MT_FORM | MT_SUBMENU, 0, "MODULATION: %s", menu_modulation},
{ MT_FORM | MT_CANCEL, 0, S_LARROW" BACK",NULL }, { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
const menuitem_t menu_highoutputmode[] = { const menuitem_t menu_highoutputmode[] = {
{ MT_FORM | MT_TITLE, 0, "HIGH OUTPUT", NULL}, { MT_FORM | MT_TITLE, 0, "HIGH OUTPUT", NULL},
{ MT_FORM | MT_CALLBACK, KM_CENTER, "FREQ: %s", menu_lowoutputmode_cb}, // same menu as low mode { MT_FORM | MT_KEYPAD, KM_CENTER, "FREQ: %s", NULL},
{ MT_FORM | MT_CALLBACK, KM_HIGHOUTLEVEL, "LEVEL: %s", menu_lowoutputmode_cb}, { MT_FORM | MT_SUBMENU, 0, "LEVEL: %s", menu_drive_wide},
{ MT_FORM | MT_SUBMENU, 0, "MODULATION: %s", menu_modulation}, { MT_FORM | MT_SUBMENU, 0, "MODULATION: %s", menu_modulation},
{ MT_FORM | MT_CANCEL, 0, S_LARROW" BACK",NULL }, { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK",NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
@ -594,31 +519,31 @@ const menuitem_t menu_highoutputmode[] = {
static const menuitem_t menu_average[] = { static const menuitem_t menu_average[] = {
{ MT_CALLBACK, 0, " OFF", menu_average_cb}, { MT_CALLBACK, 0, " OFF", menu_average_cb},
{ MT_CALLBACK, 0, "\2 MIN\0 HOLD", menu_average_cb}, { MT_CALLBACK, 1, "\2 MIN\0 HOLD", menu_average_cb},
{ MT_CALLBACK, 0, "\2 MAX\0 HOLD", menu_average_cb}, { MT_CALLBACK, 2, "\2 MAX\0 HOLD", menu_average_cb},
{ MT_CALLBACK, 0, "\2 MAX\0 DECAY", menu_average_cb}, { MT_CALLBACK, 3, "\2 MAX\0 DECAY", menu_average_cb},
{ MT_CALLBACK, 0, " 4 ", menu_average_cb}, { MT_CALLBACK, 4, " 4 ", menu_average_cb},
{ MT_CALLBACK, 0, " 16 ", menu_average_cb}, { MT_CALLBACK, 5, " 16 ", menu_average_cb},
{ 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
}; };
static const menuitem_t menu_storage[] = { static const menuitem_t menu_storage[] = {
{ MT_CALLBACK, 0, "STORE", menu_storage_cb}, { MT_CALLBACK, 0, "STORE", menu_storage_cb},
{ MT_CALLBACK, 0, "CLEAR", menu_storage_cb}, { MT_CALLBACK, 1, "CLEAR", menu_storage_cb},
{ MT_CALLBACK, 0, "SUBTRACT", menu_storage_cb}, { MT_CALLBACK, 2, "SUBTRACT", menu_storage_cb},
{ MT_CALLBACK, 0, "WATERFALL",menu_storage_cb}, { MT_CALLBACK, 3, "WATERFALL",menu_storage_cb},
{ 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
}; };
static const menuitem_t menu_rbw[] = { static const menuitem_t menu_rbw[] = {
{ MT_CALLBACK, 0, " AUTO", menu_rbw_cb}, { MT_CALLBACK, 0, " AUTO", menu_rbw_cb},
{ MT_CALLBACK, 0, " 3kHz", menu_rbw_cb}, { MT_CALLBACK, 1, " 3kHz", menu_rbw_cb},
{ MT_CALLBACK, 0, " 10kHz", menu_rbw_cb}, { MT_CALLBACK, 2, " 10kHz", menu_rbw_cb},
{ MT_CALLBACK, 0, " 30kHz", menu_rbw_cb}, { MT_CALLBACK, 3, " 30kHz", menu_rbw_cb},
{ MT_CALLBACK, 0, "100kHz", menu_rbw_cb}, { MT_CALLBACK, 4, "100kHz", menu_rbw_cb},
{ MT_CALLBACK, 0, "300kHz", menu_rbw_cb}, { MT_CALLBACK, 5, "300kHz", menu_rbw_cb},
{ 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
}; };
@ -626,72 +551,71 @@ static const menuitem_t menu_rbw[] = {
static const menuitem_t menu_dBper[] = { static const menuitem_t menu_dBper[] = {
{ MT_CALLBACK, 0, " 1dB/", menu_dBper_cb}, { MT_CALLBACK, 0, " 1dB/", menu_dBper_cb},
{ MT_CALLBACK, 0, " 2dB/", menu_dBper_cb}, { MT_CALLBACK, 1, " 2dB/", menu_dBper_cb},
{ MT_CALLBACK, 0, " 5dB/", menu_dBper_cb}, { MT_CALLBACK, 2, " 5dB/", menu_dBper_cb},
{ MT_CALLBACK, 0, " 10dB/", menu_dBper_cb}, { MT_CALLBACK, 3, " 10dB/", menu_dBper_cb},
{ MT_CALLBACK, 0, " 20dB/", menu_dBper_cb}, { MT_CALLBACK, 4, " 20dB/", menu_dBper_cb},
{ 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
}; };
static const menuitem_t menu_reffer2[] = { static const menuitem_t menu_reffer2[] = {
{ MT_FORM | MT_CALLBACK, 0, "3MHz" , menu_reffer_cb2}, { MT_FORM | MT_CALLBACK, 5, "3MHz" , menu_reffer_cb},
{ MT_FORM | MT_CALLBACK, 0, "2MHz" , menu_reffer_cb2}, { MT_FORM | MT_CALLBACK, 6, "2MHz" , menu_reffer_cb},
{ MT_FORM | MT_CALLBACK, 0, "1MHz" , menu_reffer_cb2}, { MT_FORM | MT_CALLBACK, 7, "1MHz" , menu_reffer_cb},
{ MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL }, { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
static const menuitem_t menu_reffer[] = { static const menuitem_t menu_reffer[] = {
{ MT_FORM | MT_CALLBACK, 0, "OFF" , menu_reffer_cb}, { MT_FORM | MT_CALLBACK, 0, "OFF" , menu_reffer_cb},
{ MT_FORM | MT_CALLBACK, 0, "30MHz", menu_reffer_cb}, { MT_FORM | MT_CALLBACK, 1, "30MHz", menu_reffer_cb},
{ MT_FORM | MT_CALLBACK, 0, "15MHz", menu_reffer_cb}, { MT_FORM | MT_CALLBACK, 2, "15MHz", menu_reffer_cb},
{ MT_FORM | MT_CALLBACK, 0, "10MHz", menu_reffer_cb}, { MT_FORM | MT_CALLBACK, 3, "10MHz", menu_reffer_cb},
{ MT_FORM | MT_CALLBACK, 0, "4MHz" , menu_reffer_cb}, { MT_FORM | MT_CALLBACK, 4, "4MHz" , menu_reffer_cb},
{ MT_FORM | MT_SUBMENU, 0, S_RARROW" MORE", menu_reffer2}, { MT_FORM | MT_SUBMENU, 0, S_RARROW" MORE", menu_reffer2},
{ MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL }, { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
static const menuitem_t menu_scale[] = { static const menuitem_t menu_scale[] = {
{ MT_CALLBACK, KM_REFPOS, "\2REF\0LEVEL", menu_scale_cb}, { MT_KEYPAD, KM_REFPOS, "\2REF\0LEVEL", NULL},
{ MT_SUBMENU, 0, "\2SCALE/\0DIV", menu_dBper}, { MT_SUBMENU,0, "\2SCALE/\0DIV", menu_dBper},
{ MT_CALLBACK, KM_ATTENUATION, "ATTEN", menu_scale_cb}, { MT_KEYPAD, KM_ATTENUATION, "ATTEN", NULL},
{ MT_SUBMENU, 0, "AVERAGE", menu_average}, { MT_SUBMENU,0, "AVERAGE", menu_average},
{ MT_CALLBACK, 0, "\2SPUR\0REDUCT.",menu_spur_cb}, { MT_KEYPAD, 0, "\2SPUR\0REDUCT.", menu_spur_cb},
{ MT_SUBMENU, 0, "RBW", menu_rbw}, { MT_SUBMENU,0, "RBW", menu_rbw},
{ 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
}; };
static const menuitem_t menu_scalehigh[] = { static const menuitem_t menu_scalehigh[] = {
{ MT_CALLBACK, KM_REFPOS, "\2REF\0LEVEL", menu_scale_cb}, { MT_KEYPAD, KM_REFPOS, "\2REF\0LEVEL", NULL},
{ MT_SUBMENU, 0, "\2SCALE/\0DIV", menu_dBper}, { MT_SUBMENU,0, "\2SCALE/\0DIV", menu_dBper},
{ MT_SUBMENU, 0, "AVERAGE", menu_average}, { MT_SUBMENU,0, "AVERAGE", menu_average},
{ MT_SUBMENU, 0, "RBW", menu_rbw}, { MT_SUBMENU,0, "RBW", menu_rbw},
{ 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
}; };
static const menuitem_t menu_stimulus[] = { static const menuitem_t menu_stimulus[8] = {
{ MT_CALLBACK, 0, "START", menu_stimulus_cb}, { MT_KEYPAD, KM_START, "START", NULL},
{ MT_CALLBACK, 0, "STOP", menu_stimulus_cb}, { MT_KEYPAD, KM_STOP, "STOP", NULL},
{ MT_CALLBACK, 0, "CENTER", menu_stimulus_cb}, { MT_KEYPAD, KM_CENTER, "CENTER", NULL},
{ MT_CALLBACK, 0, "SPAN", menu_stimulus_cb}, { MT_KEYPAD, KM_SPAN, "SPAN", NULL},
{ MT_CALLBACK, 0, "CW FREQ", menu_stimulus_cb}, { MT_KEYPAD, KM_CW, "CW FREQ", NULL},
// { MT_SUBMENU, 0, "RBW", menu_rbw}, { MT_CALLBACK,0, "\2PAUSE\0SWEEP", menu_pause_cb},
{ MT_CALLBACK, 0, "\2PAUSE\0SWEEP", menu_stimulus_cb},
{ 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
}; };
static const menuitem_t menu_marker_type[] = { static const menuitem_t menu_marker_type[] = {
{ MT_CALLBACK, 0, "REFERENCE", menu_marker_type_cb}, { MT_CALLBACK, M_REFERENCE, "REFERENCE", menu_marker_type_cb},
{ MT_CALLBACK, 0, "NORMAL", menu_marker_type_cb}, { MT_CALLBACK, M_NORMAL, "NORMAL", menu_marker_type_cb},
{ MT_CALLBACK, 0, "DELTA", menu_marker_type_cb}, { MT_CALLBACK, M_DELTA, "DELTA", menu_marker_type_cb},
{ 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
}; };
@ -699,10 +623,10 @@ static const menuitem_t menu_marker_type[] = {
const menuitem_t menu_marker_search[] = { const menuitem_t menu_marker_search[] = {
//{ MT_CALLBACK, "OFF", menu_marker_search_cb }, //{ MT_CALLBACK, "OFF", menu_marker_search_cb },
{ MT_CALLBACK, 0, "MAXIMUM", menu_marker_search_cb }, { MT_CALLBACK, 0, "MAXIMUM", menu_marker_search_cb },
{ MT_CALLBACK, 0, "MINIMUM", menu_marker_search_cb }, { MT_CALLBACK, 1, "MINIMUM", menu_marker_search_cb },
{ MT_CALLBACK, 0, "\2SEARCH\0" S_LARROW" LEFT", menu_marker_search_cb }, { MT_CALLBACK, 2, "\2SEARCH\0" S_LARROW" LEFT", menu_marker_search_cb },
{ MT_CALLBACK, 0, "\2SEARCH\0" S_RARROW" RIGHT", menu_marker_search_cb }, { MT_CALLBACK, 3, "\2SEARCH\0" S_RARROW" RIGHT", menu_marker_search_cb },
{ MT_CALLBACK, 0, "TRACKING", menu_marker_search_cb }, { MT_CALLBACK, 4, "TRACKING", menu_marker_search_cb },
{ 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
}; };
@ -746,10 +670,10 @@ static const menuitem_t menu_settings2[] =
static const menuitem_t menu_settings[] = static const menuitem_t menu_settings[] =
{ {
{ MT_CALLBACK, KM_ACTUALPOWER, "\2ACTUAL\0POWER", menu_settings_cb}, { MT_KEYPAD, KM_ACTUALPOWER, "\2ACTUAL\0POWER", NULL},
{ MT_CALLBACK, KM_IF, "\2IF\0FREQ", menu_settings_cb}, { MT_KEYPAD, KM_IF, "\2IF\0FREQ", NULL},
{ MT_CALLBACK, KM_SAMPLETIME, "\2SAMPLE\0TIME", menu_settings_cb}, { MT_KEYPAD, KM_SAMPLETIME, "\2SAMPLE\0TIME", NULL},
{ MT_CALLBACK, KM_DRIVE, "\2LO\0DRIVE", menu_settings_cb}, { MT_SUBMENU,0, "\2LO\0DRIVE", menu_drive},
{ MT_SUBMENU, 0, S_RARROW" MORE", menu_settings2}, { MT_SUBMENU, 0, S_RARROW" MORE", menu_settings2},
{ 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
@ -766,8 +690,8 @@ static const menuitem_t menu_settingshigh2[] =
static const menuitem_t menu_settingshigh[] = static const menuitem_t menu_settingshigh[] =
{ {
{ MT_CALLBACK, KM_ACTUALPOWER, "\2ACTUAL\0POWER", menu_settings_cb}, { MT_KEYPAD, KM_ACTUALPOWER, "\2ACTUAL\0POWER", NULL},
{ MT_CALLBACK, KM_SAMPLETIME, "\2SAMPLE\0TIME", menu_settings_cb}, { MT_KEYPAD, KM_SAMPLETIME, "\2SAMPLE\0TIME", NULL},
{ MT_SUBMENU, 0, S_RARROW" MORE", menu_settingshigh2}, { MT_SUBMENU, 0, S_RARROW" MORE", menu_settingshigh2},
{ 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
@ -853,6 +777,7 @@ int menu_is_form(const menuitem_t *menu)
static void menu_item_modify_attribute( static void menu_item_modify_attribute(
const menuitem_t *menu, int item, uint16_t *fg, uint16_t *bg) const menuitem_t *menu, int item, uint16_t *fg, uint16_t *bg)
{ {
int mark = false;
if (menu == menu_mode) { if (menu == menu_mode) {
if (item == GetMode()+1) { if (item == GetMode()+1) {
*bg = DEFAULT_MENU_TEXT_COLOR; *bg = DEFAULT_MENU_TEXT_COLOR;
@ -860,6 +785,8 @@ static void menu_item_modify_attribute(
} else if (item == 5) { } else if (item == 5) {
plot_printf(uistat.text, sizeof uistat.text, menu_reffer_text[get_refer_output()+1]); plot_printf(uistat.text, sizeof uistat.text, menu_reffer_text[get_refer_output()+1]);
} }
} else if (menu == menu_highoutputmode && item == 2) {
plot_printf(uistat.text, sizeof uistat.text, menu_drive_text[setting_drive]);
} else if (menu == menu_lowoutputmode || menu == menu_highoutputmode) { } else if (menu == menu_lowoutputmode || menu == menu_highoutputmode) {
if (item == 3) { if (item == 3) {
plot_printf(uistat.text, sizeof uistat.text, menu_modulation_text[setting_modulation]); plot_printf(uistat.text, sizeof uistat.text, menu_modulation_text[setting_modulation]);
@ -902,6 +829,12 @@ static void menu_item_modify_attribute(
*fg = config.menu_normal_color; *fg = config.menu_normal_color;
} }
} else if (menu == menu_drive || menu == menu_drive_wide) {
if (item == setting_drive){
*bg = DEFAULT_MENU_TEXT_COLOR;
*fg = config.menu_normal_color;
}
} else if (menu == menu_storage) { } else if (menu == menu_storage) {
if (item ==0 && GetStorage()){ if (item ==0 && GetStorage()){
*bg = DEFAULT_MENU_TEXT_COLOR; *bg = DEFAULT_MENU_TEXT_COLOR;
@ -929,46 +862,15 @@ static void menu_item_modify_attribute(
*fg = config.menu_normal_color; *fg = config.menu_normal_color;
} }
} }
if (mark) {
*bg = DEFAULT_MENU_TEXT_COLOR;
*fg = config.menu_normal_color;
}
if (ui_mode == UI_MENU && menu_is_form(menu)) { if (ui_mode == UI_MENU && menu_is_form(menu)) {
// if (item == 0) // if (item == 0)
// redraw_frame(); // redraw_frame();
if (item <= 1) { if (item <= 1) {
area_width = 0; area_width = 0;
#if 0
// area_height = HEIGHT - 32;
int y = MENU_BUTTON_HEIGHT*item;
uint16_t bg = config.menu_normal_color;
uint16_t fg = DEFAULT_MENU_TEXT_COLOR;
// ili9341_fill(320-MENU_BUTTON_WIDTH, y, MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT-2, bg);
ili9341_set_foreground(fg);
ili9341_set_background(bg);
char buf[15];
ili9341_fill(50+25, y, 170, MENU_BUTTON_HEIGHT-2, bg);
if (menu == menu_lowoutputmode) {
switch (item) {
case 0:
set_sweep_frequency(ST_SPAN, 0); // For CW sweep mode
plot_printf(buf, sizeof buf, "%3.3fMHz", frequency0 / 1000000.0);
break;
case 1:
plot_printf(buf, sizeof buf, "%ddB", -10 - setting_attenuate);
break;
}
}
if (menu == menu_highoutputmode) {
switch (item) {
case 0:
set_sweep_frequency(ST_SPAN, 0); // For CW sweep mode
plot_printf(buf, sizeof buf, "%3.3fMHz", frequency0 / 1000000.0);
break;
case 1:
plot_printf(buf, sizeof buf, "%ddB", -10 - setting_drive);
break;
}
}
ili9341_drawstring_size(buf, 130, y+6, 2);
#endif
} }
}else{ }else{
area_width = AREA_WIDTH_NORMAL - MENU_BUTTON_WIDTH; area_width = AREA_WIDTH_NORMAL - MENU_BUTTON_WIDTH;

Loading…
Cancel
Save

Powered by TurnKey Linux.