feat: add marker tracking

This commit is contained in:
TT 2020-01-18 22:27:56 +09:00
parent 2d8be205d0
commit 18a1ca4e6e
4 changed files with 37 additions and 18 deletions

8
main.c
View file

@ -90,6 +90,14 @@ static THD_FUNCTION(Thread1, arg)
if (completed) { if (completed) {
plot_into_index(measured); plot_into_index(measured);
redraw_request |= REDRAW_CELLS; redraw_request |= REDRAW_CELLS;
if (marker_tracking) {
int i = marker_search();
if (i != -1 && active_marker != -1) {
markers[active_marker].index = i;
redraw_request |= REDRAW_MARKER;
}
}
} }
} }

View file

@ -221,8 +221,8 @@ typedef struct {
uint32_t frequency; uint32_t frequency;
} marker_t; } marker_t;
//extern marker_t markers[4]; extern int8_t previous_marker;
//extern int active_marker; extern int8_t marker_tracking;
void plot_init(void); void plot_init(void);
void update_grid(void); void update_grid(void);
@ -244,7 +244,8 @@ void markmap_all_markers(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);
int marker_search(int mode); void set_marker_search(int mode);
int marker_search(void);
int marker_search_left(int from); int marker_search_left(int from);
int marker_search_right(int from); int marker_search_right(int from);
@ -311,7 +312,6 @@ typedef struct {
int8_t _active_marker; int8_t _active_marker;
uint8_t _domain_mode; /* 0bxxxxxffm : where ff: TD_FUNC m: DOMAIN_MODE */ uint8_t _domain_mode; /* 0bxxxxxffm : where ff: TD_FUNC m: DOMAIN_MODE */
uint8_t _marker_smith_format; uint8_t _marker_smith_format;
uint8_t _reserved[50]; uint8_t _reserved[50];
int32_t checksum; int32_t checksum;
} properties_t; } properties_t;
@ -324,8 +324,6 @@ extern int16_t lastsaveid;
extern properties_t *active_props; extern properties_t *active_props;
extern properties_t current_props; extern properties_t current_props;
extern int8_t previous_marker;
#define frequency0 current_props._frequency0 #define frequency0 current_props._frequency0
#define frequency1 current_props._frequency1 #define frequency1 current_props._frequency1
#define sweep_points current_props._sweep_points #define sweep_points current_props._sweep_points
@ -380,8 +378,6 @@ void ui_init(void);
void ui_show(void); void ui_show(void);
void ui_hide(void); void ui_hide(void);
extern uint8_t operation_requested;
void touch_start_watchdog(void); void touch_start_watchdog(void);
void touch_position(int *x, int *y); void touch_position(int *x, int *y);
void handle_touch_interrupt(void); void handle_touch_interrupt(void);

21
plot.c
View file

@ -658,7 +658,8 @@ format_smith_value(char *buf, int len, const float coeff[2], uint32_t frequency)
case MS_RX: case MS_RX:
n = string_value_with_prefix(buf, len, zr, S_OHM[0]); n = string_value_with_prefix(buf, len, zr, S_OHM[0]);
buf[n++] = ' '; if (zi >= 0)
buf[n++] = ' ';
string_value_with_prefix(buf+n, len-n, zi, 'j'); string_value_with_prefix(buf+n, len-n, zi, 'j');
break; break;
@ -1161,19 +1162,14 @@ 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) = lesser;
int8_t marker_tracking = false;
int int
marker_search(int mode) marker_search(void)
{ {
int i; int i;
int found = 0; int found = 0;
if (mode == 0)
compare = greater;
else
compare = lesser;
if (uistat.current_trace == -1) if (uistat.current_trace == -1)
return -1; return -1;
@ -1189,6 +1185,15 @@ marker_search(int mode)
return found; return found;
} }
void
set_marker_search(int mode)
{
if (mode == 0)
compare = greater;
else
compare = lesser;
}
int int
marker_search_left(int from) marker_search_left(int from)
{ {

14
ui.c
View file

@ -862,7 +862,8 @@ menu_marker_search_cb(int item)
switch (item) { switch (item) {
case 0: /* maximum */ case 0: /* maximum */
case 1: /* minimum */ case 1: /* minimum */
i = marker_search(item); set_marker_search(item);
i = marker_search();
if (i != -1) if (i != -1)
markers[active_marker].index = i; markers[active_marker].index = i;
draw_menu(); draw_menu();
@ -879,6 +880,10 @@ menu_marker_search_cb(int item)
markers[active_marker].index = i; markers[active_marker].index = i;
draw_menu(); draw_menu();
break; break;
case 4: /* tracking */
marker_tracking = !marker_tracking;
draw_menu();
break;
} }
redraw_marker(active_marker, TRUE); redraw_marker(active_marker, TRUE);
uistat.lever_mode = LM_SEARCH; uistat.lever_mode = LM_SEARCH;
@ -1085,7 +1090,7 @@ const menuitem_t menu_marker_search[] = {
{ MT_CALLBACK, "MINIMUM", menu_marker_search_cb }, { MT_CALLBACK, "MINIMUM", menu_marker_search_cb },
{ MT_CALLBACK, "\2SEARCH\0" S_LARROW" LEFT", menu_marker_search_cb }, { MT_CALLBACK, "\2SEARCH\0" S_LARROW" LEFT", menu_marker_search_cb },
{ MT_CALLBACK, "\2SEARCH\0" S_RARROW" RIGHT", menu_marker_search_cb }, { MT_CALLBACK, "\2SEARCH\0" S_RARROW" RIGHT", menu_marker_search_cb },
//{ MT_CALLBACK, "TRACKING", menu_marker_search_cb }, { MT_CALLBACK, "TRACKING", menu_marker_search_cb },
{ MT_CANCEL, S_LARROW" BACK", NULL }, { MT_CANCEL, S_LARROW" BACK", NULL },
{ MT_NONE, NULL, NULL } // sentinel { MT_NONE, NULL, NULL } // sentinel
}; };
@ -1419,6 +1424,11 @@ menu_item_modify_attribute(const menuitem_t *menu, int item,
*fg = 0xffff; *fg = 0xffff;
} }
} }
} else if (menu == menu_marker_search) {
if (item == 4 && marker_tracking) {
*bg = 0x0000;
*fg = 0xffff;
}
} else if (menu == menu_marker_smith) { } else if (menu == menu_marker_smith) {
if (marker_smith_format == item) { if (marker_smith_format == item) {
*bg = 0x0000; *bg = 0x0000;