Hyperbolic interpolation of tracking marker frequencies (OneOfEleven)

pull/4/head
erikkaashoek 5 years ago
parent d6b63c0f75
commit 1167bdec16

@ -845,13 +845,10 @@ extern const char *unit_string[];
static void trace_get_value_string(
int t, char *buf, int len,
int i, float coeff[POINTS_COUNT],
uint32_t freq[POINTS_COUNT],
int point_count,
int ri, int mtype)
int ri, int mtype,
uint32_t i_freq, uint32_t ref_freq)
{
(void) t;
(void)freq;
(void) point_count;
float v;
char buf2[16];
char buf3[8];
@ -864,17 +861,17 @@ static void trace_get_value_string(
*ptr2++ = S_DELTA[0];
unit_index = setting.unit+5;
if (ri > i) {
dfreq = frequencies[ri] - frequencies[i];
dfreq = ref_freq - i_freq;
ii = ri - i;
*ptr2++ = '-';
} else {
dfreq = frequencies[i] - frequencies[ri];
dfreq = i_freq - ref_freq;
ii = i - ri;
*ptr2++ = '+';
}
rlevel = value(coeff[ri]);
} else {
dfreq = frequencies[i];
dfreq = i_freq;
}
if (FREQ_IS_CW()) {
float t = ii*(setting.actual_sweep_time_us)/(sweep_points - 1);
@ -2112,7 +2109,7 @@ static void cell_draw_marker_info(int x0, int y0)
// cell_drawstring_7x13(buf, xpos, ypos);
trace_get_value_string(
t, &buf[k], (sizeof buf) - k,
idx, measured[trace[t].channel], frequencies, sweep_points, ridx, markers[i].mtype);
idx, measured[trace[t].channel], ridx, markers[i].mtype,markers[i].frequency, markers[ref_marker].frequency);
if (/* strlen(buf)*7> WIDTH/2 && */active > 1)
cell_drawstring(buf, xpos, ypos);
else

@ -2073,6 +2073,19 @@ sweep_again: // stay in sweep loop when output mo
if (markers[m].enabled && markers[m].mtype & M_TRACKING) { // Available marker found
markers[m].index = max_index[i];
markers[m].frequency = frequencies[markers[m].index];
#if 1 // Hyperbolic interpolation, can be removed to save memory
const int idx = markers[m].index;
if (idx > 0 && idx < sweep_points-1)
{
const float y1 = actual_t[idx - 1];
const float y2 = actual_t[idx + 0];
const float y3 = actual_t[idx + 1];
const float d = 0.5f * (y1 - y3) / ((y1 - (2 * y2) + y3) + 1e-12f);
//const float bin = (float)idx + d;
const int32_t delta_Hz = abs((int64_t)frequencies[idx + 0] - frequencies[idx + 1]);
markers[m].frequency += (int32_t)(delta_Hz * d);
}
#endif
m++;
break; // Next maximum
}

Loading…
Cancel
Save

Powered by TurnKey Linux.