Skip to content

Commit

Permalink
feat: add marker operation groupdelay->edelay
Browse files Browse the repository at this point in the history
  • Loading branch information
edy555 committed Nov 23, 2019
1 parent 421c1be commit a3eb29e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions nanovna.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ void draw_battery_status(void);

void set_electrical_delay(float picoseconds);
float get_electrical_delay(void);
float groupdelay_from_array(int i, float array[101][2]);

// marker

Expand Down
2 changes: 1 addition & 1 deletion plot.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ cartesian_scale(float re, float im, int *xp, int *yp, float scale)
*yp = HEIGHT/2 - y;
}

static float
float
groupdelay_from_array(int i, float array[101][2])
{
if (i == 0) {
Expand Down
10 changes: 10 additions & 0 deletions ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -818,11 +818,13 @@ menu_marker_op_cb(int item)
case 3: /* MARKERS->SPAN */
{
if (previous_marker == -1 || active_marker == previous_marker) {
// if only 1 marker is active, keep center freq and make span the marker comes to the edge
int32_t center = get_sweep_frequency(ST_CENTER);
int32_t span = center - freq;
if (span < 0) span = -span;
set_sweep_frequency(ST_SPAN, span * 2);
} else {
// if 2 or more marker active, set start and stop freq to each marker
int32_t freq2 = get_marker_frequency(previous_marker);
if (freq2 < 0)
return;
Expand All @@ -835,6 +837,13 @@ menu_marker_op_cb(int item)
}
}
break;
case 4: /* MARKERS->EDELAY */
{
float (*array)[2] = measured[trace[uistat.current_trace].channel];
float v = groupdelay_from_array(markers[active_marker].index, array);
set_electrical_delay(electrical_delay + (v / 1e-12));
}
break;
}
ui_mode_normal();
draw_cal_status();
Expand Down Expand Up @@ -1052,6 +1061,7 @@ const menuitem_t menu_marker_ops[] = {
{ MT_CALLBACK, S_RARROW"STOP", menu_marker_op_cb },
{ MT_CALLBACK, S_RARROW"CENTER", menu_marker_op_cb },
{ MT_CALLBACK, S_RARROW"SPAN", menu_marker_op_cb },
{ MT_CALLBACK, S_RARROW"EDELAY", menu_marker_op_cb },
{ MT_CANCEL, S_LARROW" BACK", NULL },
{ MT_NONE, NULL, NULL } // sentinel
};
Expand Down

0 comments on commit a3eb29e

Please sign in to comment.