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

@ -752,6 +752,7 @@ static void menu_marker_type_cb(int item, uint8_t data)
markers[i].mtype &= ~M_REFERENCE;
}
markers[active_marker].mtype |= M_REFERENCE;
markers[active_marker].mtype &= ~M_DELTA;
} else {
if (data == M_DELTA && (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) {
if (data & markers[active_marker].mtype)
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;
} 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)
mark = true;
} else if (menu == menu_marker_sel) {

Loading…
Cancel
Save

Powered by TurnKey Linux.