Marker search repaired

tinySA
erikkaashoek 6 years ago
parent 01f7fb629e
commit c259ca4727

@ -1144,7 +1144,7 @@ marker_position(int m, int t, int *x, int *y)
static int greater(int x, int y) { return x > y; } static int greater(int x, int y) { return x > y; }
static int lesser(int x, int y) { return x < y; } static int lesser(int x, int y) { return x < y; }
static int (*compare)(int x, int y) = lesser; static int (*compare)(int x, int y) = greater;
int int
marker_search(void) marker_search(void)
@ -1157,9 +1157,9 @@ marker_search(void)
int value = CELL_Y(trace_index[TRACE_ACTUAL][0]); int value = CELL_Y(trace_index[TRACE_ACTUAL][0]);
for (i = 0; i < sweep_points; i++) { for (i = 0; i < sweep_points; i++) {
index_t index = trace_index[TRACE_ACTUAL][i]; int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
if ((*compare)(value, CELL_Y(index))) { if ((*compare)(value, new_value)) {
value = CELL_Y(index); value = new_value;
found = i; found = i;
} }
} }
@ -1173,30 +1173,36 @@ set_marker_search(int mode)
compare = (mode == 0) ? greater : lesser; compare = (mode == 0) ? greater : lesser;
} }
int
search_is_greater(void)
{
return(compare == greater);
}
int int
marker_search_left(int from) marker_search_left(int from)
{ {
int i; int i;
int found = -1; int found = -1;
#define MINMAX_DELTA -10 #define MINMAX_DELTA -5
if (uistat.current_trace == -1) if (uistat.current_trace == -1)
return -1; return -1;
int value = CELL_Y(trace_index[TRACE_ACTUAL][from]); int value = CELL_Y(trace_index[TRACE_ACTUAL][from]);
for (i = from - 1; i >= 0; i--) { for (i = from - 1; i >= 0; i--) {
index_t index = trace_index[TRACE_ACTUAL][i]; int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
if ((*compare)(value - MINMAX_DELTA, CELL_Y(index))) if ((*compare)(value + MINMAX_DELTA, new_value))
break; break;
value = CELL_Y(index); value = new_value;
} }
for (; i >= 0; i--) { for (; i >= 0; i--) {
index_t index = trace_index[TRACE_ACTUAL][i]; int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
if ((*compare)(CELL_Y(index), value + MINMAX_DELTA)) { if ((*compare)(new_value, value - MINMAX_DELTA)) {
break; break;
} }
found = i; found = i;
value = CELL_Y(index); value = new_value;
} }
return found; return found;
} }
@ -1211,19 +1217,19 @@ marker_search_right(int from)
return -1; return -1;
int value = CELL_Y(trace_index[TRACE_ACTUAL][from]); int value = CELL_Y(trace_index[TRACE_ACTUAL][from]);
for (i = from + 1; i < sweep_points; i++) { for (i = from + 1; i < sweep_points; i++) {
index_t index = trace_index[TRACE_ACTUAL][i]; int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
if ((*compare)(value, CELL_Y(index))) if ((*compare)(value+MINMAX_DELTA, new_value))
break; break;
value = CELL_Y(index); value = new_value;
} }
for (; i < sweep_points; i++) { for (; i < sweep_points; i++) {
index_t index = trace_index[TRACE_ACTUAL][i]; int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
if ((*compare)(CELL_Y(index), value)) { if ((*compare)(new_value, value-MINMAX_DELTA)) {
break; break;
} }
found = i; found = i;
value = CELL_Y(index); value = new_value;
} }
return found; return found;
} }

@ -752,6 +752,7 @@ static void menu_marker_type_cb(int item, uint8_t data)
markers[i].mtype &= ~M_REFERENCE; markers[i].mtype &= ~M_REFERENCE;
} }
markers[active_marker].mtype |= M_REFERENCE; markers[active_marker].mtype |= M_REFERENCE;
markers[active_marker].mtype &= ~M_DELTA;
} else { } else {
if (data == M_DELTA && (markers[active_marker].mtype & M_REFERENCE)) if (data == M_DELTA && (markers[active_marker].mtype & M_REFERENCE))
markers[active_marker].mtype &= ~M_REFERENCE; markers[active_marker].mtype &= ~M_REFERENCE;
@ -1357,9 +1358,13 @@ static void menu_item_modify_attribute(
} else if (menu == menu_marker_type && active_marker >= 0 && markers[active_marker].enabled == M_ENABLED) { } else if (menu == menu_marker_type && active_marker >= 0 && markers[active_marker].enabled == M_ENABLED) {
if (data & markers[active_marker].mtype) if (data & markers[active_marker].mtype)
mark = true; mark = true;
else if (data==markers[active_marker].mtype) // This catches the M_NORMAL case else if (item < 5 && data==markers[active_marker].mtype) // This catches the M_NORMAL case
mark = true; mark = true;
} else if (menu == menu_marker_search) { } else if (menu == menu_marker_search) {
if (item == 0 && search_is_greater())
mark = true;
if (item == 1 && !search_is_greater())
mark = true;
if (item == 4 && markers[active_marker].mtype & M_TRACKING) if (item == 4 && markers[active_marker].mtype & M_TRACKING)
mark = true; mark = true;
} else if (menu == menu_marker_sel) { } else if (menu == menu_marker_sel) {

Loading…
Cancel
Save

Powered by TurnKey Linux.