From df524ed2897f893384666d019ed364993d2aea9b Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Sat, 11 Apr 2020 07:51:29 +0200 Subject: [PATCH] Binary search in spur table --- Makefile | 2 +- sa_core.c | 16 +++++++++++----- ui.c | 2 +- ui_sa.c | 3 ++- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index e16ea2e..770ad95 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # Compiler options here. ifeq ($(USE_OPT),) # USE_OPT = -O2 -fno-inline-small-functions -ggdb -fomit-frame-pointer -falign-functions=16 --specs=nano.specs -fstack-usage - USE_OPT = -fno-inline-small-functions -ggdb -fomit-frame-pointer -falign-functions=16 --specs=nano.specs -fstack-usage + USE_OPT = -fdce -fdse -fmerge-constants -fstore-merging -fno-inline-small-functions -ggdb -fomit-frame-pointer -falign-functions=16 --specs=nano.specs -fstack-usage endif # C specific options here (added to USE_OPT). diff --git a/sa_core.c b/sa_core.c index 7f16767..fcfdf72 100644 --- a/sa_core.c +++ b/sa_core.c @@ -718,17 +718,19 @@ static const int spur_table[] = int binary_search(int f) { int L = 0; - int R = (sizeof spur_table)/sizeof(int); + int R = (sizeof spur_table)/sizeof(int) - 1; + int fmin = f - ((int)actual_rbw ) * 1000; + int fplus = f + ((int)actual_rbw ) * 1000; while (L <= R) { int m = (L + R) / 2; - if (spur_table[m] < f) + if (spur_table[m] < fmin) L = m + 1; - else if (spur_table[m] > f) + else if (spur_table[m] > fplus) R = m - 1; else - return m; + return true; // index is m } - return 0; + return false; } @@ -739,15 +741,19 @@ int avoid_spur(int f) // window = 50000; if (! setting_mode == M_LOW || frequency_IF != spur_IF || actual_rbw > 300.0) return(false); + return binary_search(f); +#if 0 f = f + window/2; for (unsigned int i = 0; i < (sizeof spur_table)/sizeof(int); i++) { if (f/window == (spur_table[i] + window/2)/window) { // spur_old_stepdelay = actualStepDelay; // actualStepDelay += 4000; + binary_search(f); return true; } } return false; +#endif } static int modulation_counter = 0; diff --git a/ui.c b/ui.c index 87c3e60..35a7b30 100644 --- a/ui.c +++ b/ui.c @@ -842,7 +842,7 @@ menu_marker_sel_cb(int item, uint8_t data) active_marker_select(item); } } else { - markers[item].enabled = M_TRACKING_ENABLED; // default tracking enabled + markers[item].enabled = M_ENABLED; // default tracking enabled active_marker_select(item); } if (markers[item].enabled) diff --git a/ui_sa.c b/ui_sa.c index 887cad0..a721dbd 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -1,4 +1,3 @@ - void markmap_all_markers(void); static void menu_marker_type_cb(int item, uint8_t data); @@ -895,6 +894,7 @@ const menuitem_t menu_top[] = { { MT_SUBMENU, 0, "LEVEL", menu_level}, { MT_SUBMENU, 0, "DISPLAY", menu_display}, { MT_SUBMENU, 0, "MARKER", menu_marker}, + { MT_SUBMENU, 0, "MEASURE", menu_measure}, { MT_SUBMENU, 0, "SETTINGS", menu_settings}, { MT_CANCEL, 0, S_LARROW" MODE",NULL}, { MT_NONE, 0, NULL, NULL } // sentinel, @@ -907,6 +907,7 @@ const menuitem_t menu_tophigh[] = { { MT_SUBMENU, 0, "LEVEL", menu_levelhigh}, { MT_SUBMENU, 0, "DISPLAY", menu_display}, { MT_SUBMENU, 0, "MARKER", menu_marker}, + { MT_SUBMENU, 0, "MEASURE", menu_measure}, { MT_SUBMENU, 0, "SETTINGS", menu_settingshigh}, { MT_CANCEL, 0, S_LARROW" MODE",NULL}, { MT_NONE, 0, NULL, NULL } // sentinel,