Binary search in spur table

tinySA
erikkaashoek 6 years ago
parent c1a266e16e
commit df524ed289

@ -6,7 +6,7 @@
# Compiler options here. # Compiler options here.
ifeq ($(USE_OPT),) ifeq ($(USE_OPT),)
# USE_OPT = -O2 -fno-inline-small-functions -ggdb -fomit-frame-pointer -falign-functions=16 --specs=nano.specs -fstack-usage # 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 endif
# C specific options here (added to USE_OPT). # C specific options here (added to USE_OPT).

@ -718,17 +718,19 @@ static const int spur_table[] =
int binary_search(int f) int binary_search(int f)
{ {
int L = 0; 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) { while (L <= R) {
int m = (L + R) / 2; int m = (L + R) / 2;
if (spur_table[m] < f) if (spur_table[m] < fmin)
L = m + 1; L = m + 1;
else if (spur_table[m] > f) else if (spur_table[m] > fplus)
R = m - 1; R = m - 1;
else else
return m; return true; // index is m
} }
return 0; return false;
} }
@ -739,15 +741,19 @@ int avoid_spur(int f)
// window = 50000; // window = 50000;
if (! setting_mode == M_LOW || frequency_IF != spur_IF || actual_rbw > 300.0) if (! setting_mode == M_LOW || frequency_IF != spur_IF || actual_rbw > 300.0)
return(false); return(false);
return binary_search(f);
#if 0
f = f + window/2; f = f + window/2;
for (unsigned int i = 0; i < (sizeof spur_table)/sizeof(int); i++) { for (unsigned int i = 0; i < (sizeof spur_table)/sizeof(int); i++) {
if (f/window == (spur_table[i] + window/2)/window) { if (f/window == (spur_table[i] + window/2)/window) {
// spur_old_stepdelay = actualStepDelay; // spur_old_stepdelay = actualStepDelay;
// actualStepDelay += 4000; // actualStepDelay += 4000;
binary_search(f);
return true; return true;
} }
} }
return false; return false;
#endif
} }
static int modulation_counter = 0; static int modulation_counter = 0;

@ -842,7 +842,7 @@ menu_marker_sel_cb(int item, uint8_t data)
active_marker_select(item); active_marker_select(item);
} }
} else { } else {
markers[item].enabled = M_TRACKING_ENABLED; // default tracking enabled markers[item].enabled = M_ENABLED; // default tracking enabled
active_marker_select(item); active_marker_select(item);
} }
if (markers[item].enabled) if (markers[item].enabled)

@ -1,4 +1,3 @@
void markmap_all_markers(void); void markmap_all_markers(void);
static void menu_marker_type_cb(int item, uint8_t data); 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, "LEVEL", menu_level},
{ MT_SUBMENU, 0, "DISPLAY", menu_display}, { MT_SUBMENU, 0, "DISPLAY", menu_display},
{ MT_SUBMENU, 0, "MARKER", menu_marker}, { MT_SUBMENU, 0, "MARKER", menu_marker},
{ MT_SUBMENU, 0, "MEASURE", menu_measure},
{ MT_SUBMENU, 0, "SETTINGS", menu_settings}, { MT_SUBMENU, 0, "SETTINGS", menu_settings},
{ MT_CANCEL, 0, S_LARROW" MODE",NULL}, { MT_CANCEL, 0, S_LARROW" MODE",NULL},
{ MT_NONE, 0, NULL, NULL } // sentinel, { MT_NONE, 0, NULL, NULL } // sentinel,
@ -907,6 +907,7 @@ const menuitem_t menu_tophigh[] = {
{ MT_SUBMENU, 0, "LEVEL", menu_levelhigh}, { MT_SUBMENU, 0, "LEVEL", menu_levelhigh},
{ MT_SUBMENU, 0, "DISPLAY", menu_display}, { MT_SUBMENU, 0, "DISPLAY", menu_display},
{ MT_SUBMENU, 0, "MARKER", menu_marker}, { MT_SUBMENU, 0, "MARKER", menu_marker},
{ MT_SUBMENU, 0, "MEASURE", menu_measure},
{ MT_SUBMENU, 0, "SETTINGS", menu_settingshigh}, { MT_SUBMENU, 0, "SETTINGS", menu_settingshigh},
{ MT_CANCEL, 0, S_LARROW" MODE",NULL}, { MT_CANCEL, 0, S_LARROW" MODE",NULL},
{ MT_NONE, 0, NULL, NULL } // sentinel, { MT_NONE, 0, NULL, NULL } // sentinel,

Loading…
Cancel
Save

Powered by TurnKey Linux.