mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2025-12-06 03:31:59 +01:00
Merge branch 'master' of git://github.com/ttrftech/NanoVNA
This commit is contained in:
commit
6fe5006f05
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -8,4 +8,5 @@ python
|
|||
*.py
|
||||
*.ipynb
|
||||
TAGS
|
||||
.emacs-dirvars
|
||||
.emacs-dirvars
|
||||
*png
|
||||
|
|
|
|||
20
.vscode/tasks.json
vendored
Normal file
20
.vscode/tasks.json
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "make",
|
||||
"type": "shell",
|
||||
"command": "make",
|
||||
"group": "build"
|
||||
},
|
||||
{
|
||||
"label": "flash",
|
||||
"type": "shell",
|
||||
"command": "make dfu flash",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
41
plot.c
41
plot.c
|
|
@ -442,12 +442,9 @@ float phase(float *v)
|
|||
/*
|
||||
* calculate groupdelay
|
||||
*/
|
||||
float groupdelay(float *v, float deltaf)
|
||||
float groupdelay(float *w, float *v, float deltaf)
|
||||
{
|
||||
float *w = &v[2]; // point to next coeff
|
||||
#if 1
|
||||
// w = w[0]/w[1]
|
||||
// v = v[0]/v[1]
|
||||
// atan(w)-atan(v) = atan((w-v)/(1+wv))
|
||||
float r = w[0]*v[1] - w[1]*v[0];
|
||||
float i = w[0]*v[0] + w[1]*v[1];
|
||||
|
|
@ -505,12 +502,27 @@ cartesian_scale(float re, float im, int *xp, int *yp, float scale)
|
|||
*yp = HEIGHT/2 - y;
|
||||
}
|
||||
|
||||
static float
|
||||
groupdelay_from_array(int i, float array[101][2])
|
||||
{
|
||||
if (i == 0) {
|
||||
float deltaf = frequencies[1] - frequencies[0];
|
||||
return groupdelay(array[0], array[1], deltaf);
|
||||
} else if (i == 100) {
|
||||
float deltaf = frequencies[i] - frequencies[i-1];
|
||||
return groupdelay(array[i-1], array[i], deltaf);
|
||||
} else {
|
||||
float deltaf = frequencies[i+1] - frequencies[i-1];
|
||||
return groupdelay(array[i-1], array[i+1], deltaf);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t
|
||||
trace_into_index(int x, int t, int i, float coeff[2])
|
||||
trace_into_index(int x, int t, int i, float array[101][2])
|
||||
{
|
||||
int y = 0;
|
||||
float v = 0;
|
||||
float *coeff = array[i];
|
||||
float refpos = 8 - get_trace_refpos(t);
|
||||
float scale = 1 / get_trace_scale(t);
|
||||
switch (trace[t].type) {
|
||||
|
|
@ -521,10 +533,7 @@ trace_into_index(int x, int t, int i, float coeff[2])
|
|||
v = refpos - phase(coeff) * scale;
|
||||
break;
|
||||
case TRC_DELAY:
|
||||
if (i != 100) {
|
||||
float deltaf = frequencies[i+1] - frequencies[i];
|
||||
v = refpos - groupdelay(coeff, deltaf) * scale;
|
||||
}
|
||||
v = refpos - groupdelay_from_array(i, array) * scale;
|
||||
break;
|
||||
case TRC_LINEAR:
|
||||
v = refpos + linear(coeff) * scale;
|
||||
|
|
@ -655,8 +664,9 @@ gamma2reactance(char *buf, int len, const float coeff[2])
|
|||
}
|
||||
|
||||
static void
|
||||
trace_get_value_string(int t, char *buf, int len, float coeff[2], int i)
|
||||
trace_get_value_string(int t, char *buf, int len, float array[101][2], int i)
|
||||
{
|
||||
float *coeff = array[i];
|
||||
float v;
|
||||
switch (trace[t].type) {
|
||||
case TRC_LOGMAG:
|
||||
|
|
@ -671,11 +681,8 @@ trace_get_value_string(int t, char *buf, int len, float coeff[2], int i)
|
|||
chsnprintf(buf, len, "%.1f" S_DEGREE, v);
|
||||
break;
|
||||
case TRC_DELAY:
|
||||
{
|
||||
float deltaf = frequencies[i+1] - frequencies[i];
|
||||
v = groupdelay(coeff, deltaf);
|
||||
string_value_with_prefix(buf, len, v, 's');
|
||||
}
|
||||
v = groupdelay_from_array(i, array);
|
||||
string_value_with_prefix(buf, len, v, 's');
|
||||
break;
|
||||
case TRC_LINEAR:
|
||||
v = linear(coeff);
|
||||
|
|
@ -844,7 +851,7 @@ void plot_into_index(float measured[2][101][2])
|
|||
if (!trace[t].enabled)
|
||||
continue;
|
||||
int n = trace[t].channel;
|
||||
trace_index[t][i] = trace_into_index(x, t, i, measured[n][i]);
|
||||
trace_index[t][i] = trace_into_index(x, t, i, measured[n]);
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
|
|
@ -1520,7 +1527,7 @@ cell_draw_marker_info(int m, int n, int w, int h)
|
|||
xpos += strwidthpx + 4;
|
||||
|
||||
slen = trace_get_info(t, buf, sizeof buf);
|
||||
trace_get_value_string(t, buf+slen, (sizeof(buf))-slen, measured[trace[t].channel][idx], idx);
|
||||
trace_get_value_string(t, buf+slen, (sizeof(buf))-slen, measured[trace[t].channel], idx);
|
||||
cell_drawstring_8x8_var(w, h, buf, xpos, ypos, config.trace_color[t], FALSE);
|
||||
|
||||
j++;
|
||||
|
|
|
|||
Loading…
Reference in a new issue