From 5f3aed584464432462cc98f84dae53b1d411b4f2 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Fri, 10 Apr 2020 17:49:25 +0200 Subject: [PATCH] Menu structure adapted --- main.c | 14 ++++- ui.c | 3 +- ui_sa.c | 186 ++++++++++++++++++++++++++++++++------------------------ 3 files changed, 119 insertions(+), 84 deletions(-) diff --git a/main.c b/main.c index 2c3e0e9..337a0ec 100644 --- a/main.c +++ b/main.c @@ -129,9 +129,13 @@ static THD_FUNCTION(Thread1, arg) completed = sweep(true); sweep_mode&=~SWEEP_ONCE; } else if (sweep_mode & SWEEP_SELFTEST) { - self_test(); // call from lowest level to save stack space + // call from lowest level to save stack space + self_test(); + sweep_mode = SWEEP_ENABLE; } else if (sweep_mode & SWEEP_CALIBRATE) { - calibrate(); // call from lowest level to save stack space + // call from lowest level to save stack space + calibrate(); + sweep_mode = SWEEP_ENABLE; } else { __WFI(); } @@ -168,6 +172,12 @@ static THD_FUNCTION(Thread1, arg) } } +int +is_paused(void) +{ + return !(sweep_mode & SWEEP_ENABLE); +} + static inline void pause_sweep(void) { diff --git a/ui.c b/ui.c index adbcfa0..f8bbddd 100644 --- a/ui.c +++ b/ui.c @@ -720,11 +720,12 @@ get_marker_frequency(int marker) static void menu_marker_op_cb(int item, uint8_t data) { + (void)item; uint32_t freq = get_marker_frequency(active_marker); if (freq == 0) return; // no active marker - switch (item) { + switch (data) { case 0: /* MARKER->START */ case 1: /* MARKER->STOP */ case 2: /* MARKER->CENTER */ diff --git a/ui_sa.c b/ui_sa.c index 2a17436..887cad0 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -15,7 +15,7 @@ void SetAttenuation(int); int GetAttenuation(void); void set_auto_attenuation(void); void set_auto_reflevel(void); - +int is_paused(void); void SetPowerLevel(int); void SetGenerate(int); void SetRBW(int); @@ -488,7 +488,7 @@ int menu_dBper_value[]={1,2,5,10,20}; static void menu_dBper_cb(int item, uint8_t data) { (void)item; - SetScale(menu_dBper_value[data]); + SetScale(data); menu_move_back(); ui_mode_normal(); // draw_cal_status(); @@ -542,8 +542,8 @@ static void menu_pause_cb(int item, uint8_t data) (void) data; (void) item; toggle_sweep(); - menu_move_back(); - ui_mode_normal(); +// menu_move_back(); +// ui_mode_normal(); draw_menu(); // draw_cal_status(); } @@ -652,11 +652,11 @@ static const menuitem_t menu_rbw[] = { static const menuitem_t menu_dBper[] = { - { MT_CALLBACK, 0, " 1dB/", menu_dBper_cb}, - { MT_CALLBACK, 1, " 2dB/", menu_dBper_cb}, - { MT_CALLBACK, 2, " 5dB/", menu_dBper_cb}, - { MT_CALLBACK, 3, " 10dB/", menu_dBper_cb}, - { MT_CALLBACK, 4, " 20dB/", menu_dBper_cb}, + { MT_CALLBACK, 1, " 1dB/", menu_dBper_cb}, + { MT_CALLBACK, 2, " 2dB/", menu_dBper_cb}, + { MT_CALLBACK, 5, " 5dB/", menu_dBper_cb}, + { MT_CALLBACK, 10," 10dB/", menu_dBper_cb}, + { MT_CALLBACK, 20," 20dB/", menu_dBper_cb}, { MT_CANCEL, 0, S_LARROW" BACK", NULL }, { MT_NONE, 0, NULL, NULL } // sentinel }; @@ -688,22 +688,6 @@ static const menuitem_t menu_atten[] = { { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; -static const menuitem_t menu_acquire[] = { - { MT_CALLBACK, 0, "RESET", menu_autosettings_cb}, - { MT_SUBMENU, 0, "ATTEN", menu_atten}, - { MT_SUBMENU,0, "RBW", menu_rbw}, - { MT_SUBMENU,0, "AVER", menu_average}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel -}; - -static const menuitem_t menu_acquirehigh[] = { - { MT_CALLBACK, 0, "RESET", menu_autosettings_cb}, - { MT_SUBMENU,0, "RBW", menu_rbw}, - { MT_SUBMENU,0, "AVER", menu_average}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel -}; static const menuitem_t menu_reflevel[] = { { MT_CALLBACK,0, "AUTO", menu_reflevel_cb}, @@ -713,29 +697,6 @@ static const menuitem_t menu_reflevel[] = { }; -static const menuitem_t menu_display[] = { - { MT_SUBMENU, 0, "\2REF\0LEVEL", menu_reflevel}, - { MT_SUBMENU, 0, "\2SCALE/\0DIV",menu_dBper}, - { MT_CALLBACK,0, "STORE", menu_storage_cb}, - { MT_CALLBACK,1, "CLEAR", menu_storage_cb}, - { MT_CALLBACK,2, "SUBTRACT", menu_storage_cb}, - { MT_CALLBACK,3, "WATERFALL", menu_storage_cb}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel -}; - -static const menuitem_t menu_stimulus[8] = { - { MT_KEYPAD, KM_START, "START", NULL}, - { MT_KEYPAD, KM_STOP, "STOP", NULL}, - { MT_KEYPAD, KM_CENTER, "CENTER", NULL}, - { MT_KEYPAD, KM_SPAN, "SPAN", NULL}, - { MT_KEYPAD, KM_CW, "CW FREQ", NULL}, - { MT_CALLBACK,0, "\2PAUSE\0SWEEP", menu_pause_cb}, - { MT_SUBMENU,0, "RBW", menu_rbw}, - { MT_CANCEL, 0, S_LARROW" BACK", NULL }, - { MT_NONE, 0, NULL, NULL } // sentinel -}; - static const menuitem_t menu_marker_type[] = { { MT_CALLBACK, M_REFERENCE, "REFERENCE", menu_marker_type_cb}, @@ -771,10 +732,10 @@ static const menuitem_t menu_marker_sel[] = { static const menuitem_t menu_marker[] = { { MT_SUBMENU, 0, "\2SELECT\0MARKER", menu_marker_sel}, { MT_SUBMENU, 0, "\2MARKER\0TYPE", menu_marker_type}, - { MT_CALLBACK, 0, S_RARROW"START", menu_marker_op_cb}, - { MT_CALLBACK, 0, S_RARROW"STOP", menu_marker_op_cb}, - { MT_CALLBACK, 0, S_RARROW"CENTER", menu_marker_op_cb}, - { MT_CALLBACK, 0, S_RARROW"SPAN", menu_marker_op_cb}, + { MT_CALLBACK, ST_START, S_RARROW"START", menu_marker_op_cb}, + { MT_CALLBACK, ST_STOP, S_RARROW"STOP", menu_marker_op_cb}, + { MT_CALLBACK, ST_CENTER, S_RARROW"CENTER", menu_marker_op_cb}, + { MT_CALLBACK, ST_SPAN, S_RARROW"SPAN", menu_marker_op_cb}, { MT_CANCEL, 0, S_LARROW" BACK", NULL }, { MT_NONE, 0, NULL, NULL } // sentinel }; @@ -857,6 +818,65 @@ static const menuitem_t menu_config[] = { { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; +static const menuitem_t menu_acquire[] = { + { MT_CALLBACK, 0, "RESET", menu_autosettings_cb}, + { MT_SUBMENU, 0, "ATTEN", menu_atten}, + { MT_SUBMENU,0, "RBW", menu_rbw}, + { MT_SUBMENU,0, "AVER", menu_average}, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel +}; + +static const menuitem_t menu_acquirehigh[] = { + { MT_CALLBACK, 0, "RESET", menu_autosettings_cb}, + { MT_SUBMENU,0, "RBW", menu_rbw}, + { MT_SUBMENU,0, "AVER", menu_average}, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel +}; + +static const menuitem_t menu_display[] = { + { MT_CALLBACK,0, "\2PAUSE\0SWEEP", menu_pause_cb}, +// { MT_SUBMENU, 0, "\2REF\0LEVEL", menu_reflevel}, +// { MT_SUBMENU, 0, "\2SCALE/\0DIV",menu_dBper}, + { MT_CALLBACK,0, "STORE", menu_storage_cb}, + { MT_CALLBACK,1, "CLEAR", menu_storage_cb}, + { MT_CALLBACK,2, "SUBTRACT", menu_storage_cb}, + { MT_CALLBACK,3, "WATERFALL", menu_storage_cb}, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel +}; + +static const menuitem_t menu_levelhigh[] = { + { MT_SUBMENU, 0, "\2REF\0LEVEL", menu_reflevel}, + { MT_SUBMENU, 0, "\2SCALE/\0DIV",menu_dBper}, + { MT_SUBMENU,0, "AVER", menu_average}, + { MT_CANCEL, 0, S_LARROW" BACK",NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel +}; + +static const menuitem_t menu_level[] = { + { MT_SUBMENU, 0, "\2REF\0LEVEL", menu_reflevel}, + { MT_SUBMENU, 0, "\2SCALE/\0DIV",menu_dBper}, + { MT_SUBMENU, 0, "ATTEN", menu_atten}, + { MT_SUBMENU,0, "AVER", menu_average}, + { MT_CANCEL, 0, S_LARROW" BACK",NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel +}; + +static const menuitem_t menu_stimulus[] = { + { MT_KEYPAD, KM_START, "START", NULL}, + { MT_KEYPAD, KM_STOP, "STOP", NULL}, + { MT_KEYPAD, KM_CENTER, "CENTER", NULL}, + { MT_KEYPAD, KM_SPAN, "SPAN", NULL}, + { MT_KEYPAD, KM_CW, "CW FREQ", NULL}, + { MT_SUBMENU,0, "RBW", menu_rbw}, + { MT_CANCEL, 0, S_LARROW" BACK", NULL }, + { MT_NONE, 0, NULL, NULL } // sentinel +}; + + + static const menuitem_t menu_mode[] = { { MT_FORM | MT_TITLE, 0, "MODE", NULL}, { MT_FORM | MT_CALLBACK, 0, "LOW INPUT", menu_mode_cb}, @@ -869,6 +889,30 @@ static const menuitem_t menu_mode[] = { { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; #if 1 +const menuitem_t menu_top[] = { + { MT_CALLBACK, 0, "RESET", menu_autosettings_cb}, + { MT_SUBMENU, 0, "FREQ", menu_stimulus}, + { MT_SUBMENU, 0, "LEVEL", menu_level}, + { MT_SUBMENU, 0, "DISPLAY", menu_display}, + { MT_SUBMENU, 0, "MARKER", menu_marker}, + { MT_SUBMENU, 0, "SETTINGS", menu_settings}, + { MT_CANCEL, 0, S_LARROW" MODE",NULL}, + { MT_NONE, 0, NULL, NULL } // sentinel, + // MENUITEM_CLOSE, +}; + +const menuitem_t menu_tophigh[] = { + { MT_CALLBACK, 0, "RESET", menu_autosettings_cb}, + { MT_SUBMENU, 0, "FREQ", menu_stimulus}, + { MT_SUBMENU, 0, "LEVEL", menu_levelhigh}, + { MT_SUBMENU, 0, "DISPLAY", menu_display}, + { MT_SUBMENU, 0, "MARKER", menu_marker}, + { MT_SUBMENU, 0, "SETTINGS", menu_settingshigh}, + { MT_CANCEL, 0, S_LARROW" MODE",NULL}, + { MT_NONE, 0, NULL, NULL } // sentinel, + // MENUITEM_CLOSE, +}; +#else const menuitem_t menu_top[] = { { MT_SUBMENU, 0, "ACQUIRE", menu_acquire}, { MT_SUBMENU, 0, "FREQ", menu_stimulus}, @@ -893,30 +937,6 @@ const menuitem_t menu_tophigh[] = { MT_NONE, 0, NULL, NULL } // sentinel, // MENUITEM_CLOSE, }; -#else -const menuitem_t menu_top[] = { - { MT_CALLBACK, 0, "AUTO", menu_autosettings_cb}, - { MT_SUBMENU, 0, "SCAN", menu_stimulus}, - { MT_SUBMENU, 0, "MARKER", menu_marker}, - { MT_SUBMENU, 0, "DISPLAY", menu_scale}, - { MT_SUBMENU, 0, "STORAGE", menu_storage}, - { MT_SUBMENU, 0, "SETTINGS", menu_settings}, - { MT_CANCEL, 0, S_LARROW" MODE",NULL}, - { MT_NONE, 0, NULL, NULL } // sentinel, - // MENUITEM_CLOSE, -}; - -const menuitem_t menu_tophigh[] = { - { MT_CALLBACK, 0, "AUTO", menu_autosettings_cb}, - { MT_SUBMENU, 0, "SCAN", menu_stimulus}, - { MT_SUBMENU, 0, "MARKER", menu_marker}, - { MT_SUBMENU, 0, "DISPLAY", menu_scalehigh}, - { MT_SUBMENU, 0, "STORAGE", menu_storage}, - { MT_SUBMENU, 0, "SETTINGS", menu_settingshigh}, - { MT_CANCEL, 0, S_LARROW" MODE",NULL}, - { MT_NONE, 0, NULL, NULL } // sentinel, - // MENUITEM_CLOSE, -}; #endif // ===[MENU DEFINITION END]====================================================== @@ -941,6 +961,7 @@ static void menu_item_modify_attribute( const menuitem_t *menu, int item, uint16_t *fg, uint16_t *bg) { int mark = false; + int data = menu[item].data; if (menu == menu_mode) { if (item == GetMode()+1) { mark = true; @@ -970,7 +991,7 @@ static void menu_item_modify_attribute( mark = true; } } else if (menu == menu_dBper) { - if (menu_dBper_value[item] == get_trace_scale(1)){ + if (data == get_trace_scale(1)){ mark = true; } } else if (menu == menu_rbw) { @@ -979,18 +1000,21 @@ static void menu_item_modify_attribute( } } else if (menu == menu_drive || menu == menu_drive_wide || menu == menu_drive_wide2|| menu == menu_drive_wide3) { - if (menu[item].data == setting_drive){ + if (data == setting_drive){ mark = true; } } else if (menu == menu_display) { - if (item ==2 && GetStorage()){ + if (item ==0 && is_paused()){ + mark = true; + } + if (item ==1 && GetStorage()){ mark = true; } - if (item == 4 && GetSubtractStorage()){ + if (item == 3 && GetSubtractStorage()){ mark = true; } - if (item == 5 && get_waterfall()){ + if (item == 4 && get_waterfall()){ mark = true; } } else if (menu == menu_settings2 || menu == menu_settingshigh2) {