From 7f6c9fe6093f04810333fc29c93944fd3c79b64d Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Sat, 13 Mar 2021 09:16:22 +0100 Subject: [PATCH] Moved LISTEN to main loop --- main.c | 7 +++++++ nanovna.h | 4 +++- si4432.c | 2 +- ui_sa.c | 19 +++++++++++++++++-- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index f8d3e97..73205f6 100644 --- a/main.c +++ b/main.c @@ -154,6 +154,13 @@ static THD_FUNCTION(Thread1, arg) } else if (sweep_mode & SWEEP_REMOTE) { sweep_remote(); #endif +#ifdef __LISTEN__ + } else if (sweep_mode & SWEEP_LISTEN) { + if (markers[active_marker].enabled == M_ENABLED) { + perform(false,0,frequencies[markers[active_marker].index], false); + SI4432_Listen(MODE_SELECT(setting.mode)); + } +#endif #ifdef __CALIBRATE__ } else if (sweep_mode & SWEEP_CALIBRATE) { // call from lowest level to save stack space diff --git a/nanovna.h b/nanovna.h index 4e3576e..1efa6ba 100644 --- a/nanovna.h +++ b/nanovna.h @@ -250,8 +250,10 @@ enum { #define SWEEP_CALIBRATE 0x04 #define SWEEP_SELFTEST 0x08 #define SWEEP_REMOTE 0x10 +#ifdef __LISTEN__ +#define SWEEP_LISTEN 0x20 //#define SWEEP_FACTORY 0x20 - +#endif extern uint8_t sweep_mode; extern bool completed; diff --git a/si4432.c b/si4432.c index caf15f3..dde5962 100644 --- a/si4432.c +++ b/si4432.c @@ -741,7 +741,7 @@ void SI4432_Listen(int s) count++; v = max - v; dacPutChannelX(&DACD2, 0, dBm_to_volt[v] << 4); - } while((operation_requested & OP_LEVER) != OP_LEVER); + } while(operation_requested == OP_NONE); count = 0; dacPutChannelX(&DACD2, 0, 0); } diff --git a/ui_sa.c b/ui_sa.c index 8cc876d..ff84b80 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -687,16 +687,31 @@ static UI_FUNCTION_CALLBACK(menu_dfu_cb) } #ifdef __LISTEN__ -static UI_FUNCTION_CALLBACK(menu_listen_cb) +static UI_FUNCTION_ADV_CALLBACK(menu_listen_acb) { (void)data; (void)item; + if (b){ + b->icon = (sweep_mode & SWEEP_LISTEN) ? BUTTON_ICON_CHECK : BUTTON_ICON_NOCHECK; + return; + } + if (sweep_mode & SWEEP_LISTEN) { + sweep_mode = SWEEP_ENABLE; + } else { + sweep_mode = SWEEP_LISTEN; + } + ui_mode_normal(); + redraw_frame(); + request_to_redraw_grid(); + +#if 0 if (markers[active_marker].enabled == M_ENABLED) { do { perform(false,0,frequencies[markers[active_marker].index], false); SI4432_Listen(MODE_SELECT(setting.mode)); } while (ui_process_listen_lever()); } +#endif } #endif @@ -2174,7 +2189,7 @@ static const menuitem_t menu_level[] = { #endif { MT_SUBMENU, 0, "TRIGGER", menu_trigger}, #ifdef __LISTEN__ - { MT_CALLBACK, 0, "LISTEN", menu_listen_cb}, + { MT_ADV_CALLBACK, 0, "LISTEN", menu_listen_acb}, #endif { MT_CANCEL, 0, S_LARROW" BACK",NULL }, { MT_NONE, 0, NULL, NULL } // sentinel