Add define for MARKER_INVALID and TRACE_INVALID

Remove obsolete marker search functions
Removed_REF_marker
DiSlord 5 years ago
parent a15c0b43ef
commit c6fc9a5d80

@ -194,8 +194,8 @@ static THD_FUNCTION(Thread1, arg)
redraw_request |= REDRAW_CELLS | REDRAW_BATTERY; redraw_request |= REDRAW_CELLS | REDRAW_BATTERY;
if (uistat.marker_tracking) { if (uistat.marker_tracking) {
int i = marker_search(); int i = marker_search_max();
if (i != -1 && active_marker != -1) { if (i != -1 && active_marker != MARKER_INVALID) {
markers[active_marker].index = i; markers[active_marker].index = i;
markers[active_marker].frequency = frequencies[i]; markers[active_marker].frequency = frequencies[i];
@ -2025,7 +2025,7 @@ VNA_SHELL_FUNCTION(cmd_marker)
} }
redraw_request |= REDRAW_MARKER; redraw_request |= REDRAW_MARKER;
if (strcmp(argv[0], "off") == 0) { if (strcmp(argv[0], "off") == 0) {
active_marker = -1; active_marker = MARKER_INVALID;
for (t = 0; t < MARKERS_MAX; t++) for (t = 0; t < MARKERS_MAX; t++)
markers[t].enabled = FALSE; markers[t].enabled = FALSE;
return; return;
@ -2044,7 +2044,7 @@ VNA_SHELL_FUNCTION(cmd_marker)
static const char cmd_marker_list[] = "on|off|peak"; static const char cmd_marker_list[] = "on|off|peak";
switch (get_str_index(argv[1], cmd_marker_list)) { switch (get_str_index(argv[1], cmd_marker_list)) {
case 0: markers[t].enabled = TRUE; active_marker = t; return; case 0: markers[t].enabled = TRUE; active_marker = t; return;
case 1: markers[t].enabled =FALSE; if (active_marker == t) active_marker = -1; return; case 1: markers[t].enabled =FALSE; if (active_marker == t) active_marker = MARKER_INVALID; return;
case 2: markers[t].enabled = TRUE; active_marker = t; case 2: markers[t].enabled = TRUE; active_marker = t;
int i = marker_search_max(); int i = marker_search_max();
if (i == -1) i = 0; if (i == -1) i = 0;

@ -107,6 +107,8 @@
#define TRACE_ACTUAL 2 #define TRACE_ACTUAL 2
#define TRACE_STORED 1 #define TRACE_STORED 1
#define TRACE_TEMP 0 #define TRACE_TEMP 0
#define TRACE_INVALID -1
// #define age_t measured[TRACE_AGE] // #define age_t measured[TRACE_AGE]
#define stored_t measured[TRACE_STORED] #define stored_t measured[TRACE_STORED]
#define actual_t measured[TRACE_ACTUAL] #define actual_t measured[TRACE_ACTUAL]
@ -672,6 +674,7 @@ typedef struct {
} marker_t; } marker_t;
#define MARKERS_MAX 4 #define MARKERS_MAX 4
#define MARKER_INVALID -1
extern int8_t previous_marker; extern int8_t previous_marker;
extern int8_t marker_tracking; extern int8_t marker_tracking;
@ -696,11 +699,8 @@ void draw_cal_status(void);
void marker_position(int m, int t, int *x, int *y); void marker_position(int m, int t, int *x, int *y);
int search_nearest_index(int x, int y, int t); int search_nearest_index(int x, int y, int t);
void set_marker_search(int mode);
int marker_search(void);
int marker_search_max(void); int marker_search_max(void);
int marker_search_left(int from);
int marker_search_right(int from);
int marker_search_left_max(int from); int marker_search_left_max(int from);
int marker_search_right_max(int from); int marker_search_right_max(int from);
int marker_search_left_min(int from); int marker_search_left_min(int from);

@ -1377,102 +1377,6 @@ marker_position(int m, int t, int *x, int *y)
*y = CELL_Y(index); *y = CELL_Y(index);
} }
static int greater(int x, int y, int d) { return x - d > y; }
static int lesser(int x, int y, int d) { return x - d < y; }
static int (*compare)(int x, int y, int d) = greater;
int
marker_search(void)
{
int i;
int found = 0;
if (uistat.current_trace == -1)
return -1;
int value = CELL_Y(trace_index[TRACE_ACTUAL][0]);
for (i = 0; i < sweep_points; i++) {
int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
if ((*compare)(value, new_value, 0)) {
value = new_value;
found = i;
}
}
return found;
}
void
set_marker_search(int mode)
{
compare = (mode == 0) ? greater : lesser;
}
int
search_is_greater(void)
{
return(compare == greater);
}
#define MINMAX_DELTA 10
int
marker_search_left(int from)
{
int i;
int found = -1;
if (uistat.current_trace == -1)
return -1;
int value = CELL_Y(trace_index[TRACE_ACTUAL][from]);
for (i = from - 1; i >= 0; i--) {
int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
if ((*compare)(value, new_value, MINMAX_DELTA))
break;
}
for (; i >= 0; i--) {
int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
if ((*compare)(new_value, value, -MINMAX_DELTA)) {
break;
}
if ((*compare)(value, new_value, 0)) {
found = i;
value = new_value;
}
}
return found;
}
int
marker_search_right(int from)
{
int i;
int found = -1;
if (uistat.current_trace == -1)
return -1;
int value = CELL_Y(trace_index[TRACE_ACTUAL][from]);
for (i = from + 1; i < sweep_points; i++) {
int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
if ((*compare)(value, new_value, MINMAX_DELTA))
break;
value = new_value;
}
for (; i < sweep_points; i++) {
int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
if ((*compare)(new_value, value, -MINMAX_DELTA)) {
break;
}
if ((*compare)(value, new_value, 0)) {
found = i;
value = new_value;
}
}
return found;
}
int int
search_nearest_index(int x, int y, int t) search_nearest_index(int x, int y, int t)
{ {

@ -3550,7 +3550,7 @@ marker_search_left_max(int from)
{ {
int i; int i;
int found = -1; int found = -1;
if (uistat.current_trace == -1) if (uistat.current_trace == TRACE_INVALID)
return -1; return -1;
float value = actual_t[from]; float value = actual_t[from];
@ -3580,7 +3580,7 @@ marker_search_right_max(int from)
int i; int i;
int found = -1; int found = -1;
if (uistat.current_trace == -1) if (uistat.current_trace == TRACE_INVALID)
return -1; return -1;
float value = actual_t[from]; float value = actual_t[from];
for (i = from + 1; i < sweep_points; i++) { for (i = from + 1; i < sweep_points; i++) {
@ -3626,7 +3626,7 @@ marker_search_left_min(int from)
{ {
int i; int i;
int found = from; int found = from;
if (uistat.current_trace == -1) if (uistat.current_trace == TRACE_INVALID)
return -1; return -1;
int value_x10 = actual_t[from]*10; int value_x10 = actual_t[from]*10;
@ -3656,7 +3656,7 @@ marker_search_right_min(int from)
int i; int i;
int found = from; int found = from;
if (uistat.current_trace == -1) if (uistat.current_trace == TRACE_INVALID)
return -1; return -1;
int value_x10 = actual_t[from]*10; int value_x10 = actual_t[from]*10;
for (i = from + 1; i < sweep_points; i++) { for (i = from + 1; i < sweep_points; i++) {

21
ui.c

@ -858,7 +858,7 @@ static UI_FUNCTION_CALLBACK(menu_marker_op_cb)
break; break;
case 3: /* MARKERS->SPAN */ case 3: /* MARKERS->SPAN */
{ {
if (previous_marker == -1 || active_marker == previous_marker) { if (previous_marker == MARKER_INVALID || active_marker == previous_marker) {
// if only 1 marker is active, keep center freq and make span the marker comes to the edge // if only 1 marker is active, keep center freq and make span the marker comes to the edge
freq_t center = get_sweep_frequency(ST_CENTER); freq_t center = get_sweep_frequency(ST_CENTER);
freq_t span = center > freq ? center - freq : freq - center; freq_t span = center > freq ? center - freq : freq - center;
@ -905,7 +905,7 @@ static UI_FUNCTION_CALLBACK(menu_marker_search_cb)
{ {
(void)item; (void)item;
int i = -1; int i = -1;
if (active_marker == -1) if (active_marker == MARKER_INVALID)
return; return;
markers[active_marker].mtype &= ~M_TRACKING; markers[active_marker].mtype &= ~M_TRACKING;
switch (data) { switch (data) {
@ -915,13 +915,6 @@ static UI_FUNCTION_CALLBACK(menu_marker_search_cb)
case 1: /* search right */ case 1: /* search right */
i = marker_search_right_min(markers[active_marker].index); i = marker_search_right_min(markers[active_marker].index);
break; break;
#if 0
case 0: /* maximum */
case 1: /* minimum */
set_marker_search(data);
i = marker_search();
break;
#endif
case 2: /* search Left */ case 2: /* search Left */
i = marker_search_left_max(markers[active_marker].index); i = marker_search_left_max(markers[active_marker].index);
break; break;
@ -950,7 +943,7 @@ static UI_FUNCTION_CALLBACK(menu_marker_search_cb)
static UI_FUNCTION_ADV_CALLBACK(menu_marker_tracking_acb){ static UI_FUNCTION_ADV_CALLBACK(menu_marker_tracking_acb){
(void)item; (void)item;
(void)data; (void)data;
if (active_marker == -1) return; if (active_marker == MARKER_INVALID) return;
if(b){ if(b){
b->icon = markers[active_marker].mtype & M_TRACKING ? BUTTON_ICON_CHECK : BUTTON_ICON_NOCHECK; b->icon = markers[active_marker].mtype & M_TRACKING ? BUTTON_ICON_CHECK : BUTTON_ICON_NOCHECK;
return; return;
@ -975,8 +968,8 @@ active_marker_select(int item) // used only to select an active marker from the
{ {
if (item == -1) { if (item == -1) {
active_marker = previous_marker; active_marker = previous_marker;
previous_marker = -1; previous_marker = MARKER_INVALID;
if (active_marker == -1) { if (active_marker == MARKER_INVALID) {
choose_active_marker(); choose_active_marker();
} }
} else { } else {
@ -2391,7 +2384,7 @@ lever_move_marker(int status)
} }
status = btn_wait_release(); status = btn_wait_release();
} while (status != 0); } while (status != 0);
if (active_marker >= 0) if (active_marker != MARKER_INVALID)
redraw_marker(active_marker); redraw_marker(active_marker);
} }
@ -2399,7 +2392,7 @@ static void
lever_search_marker(int status) lever_search_marker(int status)
{ {
int i = -1; int i = -1;
if (active_marker >= 0) { if (active_marker != MARKER_INVALID) {
if (status & EVT_DOWN) if (status & EVT_DOWN)
i = marker_search_left_max(markers[active_marker].index); i = marker_search_left_max(markers[active_marker].index);
else if (status & EVT_UP) else if (status & EVT_UP)

@ -1154,7 +1154,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_marker_select_acb)
static UI_FUNCTION_ADV_CALLBACK(menu_marker_modify_acb) static UI_FUNCTION_ADV_CALLBACK(menu_marker_modify_acb)
{ {
(void)item; (void)item;
if (active_marker == -1) return; if (active_marker == MARKER_INVALID) return;
if(b){ if(b){
if (markers[active_marker].enabled == M_ENABLED) { if (markers[active_marker].enabled == M_ENABLED) {
b->icon = BUTTON_ICON_NOCHECK; b->icon = BUTTON_ICON_NOCHECK;
@ -1303,7 +1303,7 @@ static void choose_active_marker(void)
active_marker = i; active_marker = i;
return; return;
} }
active_marker = -1; active_marker = MARKER_INVALID;
} }
#ifdef __HARMONIC__ #ifdef __HARMONIC__

Loading…
Cancel
Save

Powered by TurnKey Linux.