mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2025-12-06 03:31:59 +01:00
Add REAL IMAG R X trace format
This commit is contained in:
parent
973de1d7c0
commit
f9a5d2e3ef
4
main.c
4
main.c
|
|
@ -1273,10 +1273,10 @@ static void cmd_recall(BaseSequentialStream *chp, int argc, char *argv[])
|
|||
|
||||
|
||||
const char *trc_type_name[] = {
|
||||
"LOGMAG", "PHASE", "DELAY", "SMITH", "POLAR", "LINEAR", "SWR"
|
||||
"LOGMAG", "PHASE", "DELAY", "SMITH", "POLAR", "LINEAR", "SWR", "REAL", "IMAG", "R", "X"
|
||||
};
|
||||
const uint8_t default_refpos[] = {
|
||||
7, 4, 4, 0, 0, 0, 0
|
||||
7, 4, 4, 0, 0, 0, 0, 4, 4, 0, 4
|
||||
};
|
||||
|
||||
const char *trc_channel_name[] = {
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ extern const uint32_t numfont20x24[][24];
|
|||
#define TRACES_MAX 4
|
||||
|
||||
enum {
|
||||
TRC_LOGMAG, TRC_PHASE, TRC_DELAY, TRC_SMITH, TRC_POLAR, TRC_LINEAR, TRC_SWR, TRC_OFF
|
||||
TRC_LOGMAG, TRC_PHASE, TRC_DELAY, TRC_SMITH, TRC_POLAR, TRC_LINEAR, TRC_SWR, TRC_REAL, TRC_IMAG, TRC_R, TRC_X, TRC_OFF
|
||||
};
|
||||
|
||||
extern const char *trc_type_name[];
|
||||
|
|
|
|||
56
plot.c
56
plot.c
|
|
@ -459,6 +459,20 @@ float swr(float *v)
|
|||
return (1 + x)/(1 - x);
|
||||
}
|
||||
|
||||
float resitance(float *v) {
|
||||
float z0 = 50;
|
||||
float d = z0 / ((1-v[0])*(1-v[0])+v[1]*v[1]);
|
||||
float zr = ((1+v[0])*(1-v[0]) - v[1]*v[1]) * d;
|
||||
return zr;
|
||||
}
|
||||
|
||||
float reactance(float *v) {
|
||||
float z0 = 50;
|
||||
float d = z0 / ((1-v[0])*(1-v[0])+v[1]*v[1]);
|
||||
float zi = 2*v[1] * d;
|
||||
return zi;
|
||||
}
|
||||
|
||||
#define RADIUS ((HEIGHT-1)/2)
|
||||
void
|
||||
cartesian_scale(float re, float im, int *xp, int *yp, float scale)
|
||||
|
|
@ -495,6 +509,18 @@ trace_into_index(int x, int t, int i, float coeff[2])
|
|||
case TRC_SWR:
|
||||
v = refpos+ (1 - swr(coeff)) * scale;
|
||||
break;
|
||||
case TRC_REAL:
|
||||
v = refpos - coeff[0] * 8 * scale;
|
||||
break;
|
||||
case TRC_IMAG:
|
||||
v = refpos - coeff[1] * 8 * scale;
|
||||
break;
|
||||
case TRC_R:
|
||||
v = refpos - resitance(coeff) * scale;
|
||||
break;
|
||||
case TRC_X:
|
||||
v = refpos - reactance(coeff) * scale;
|
||||
break;
|
||||
case TRC_SMITH:
|
||||
//case TRC_ADMIT:
|
||||
case TRC_POLAR:
|
||||
|
|
@ -587,6 +613,24 @@ gamma2imp(char *buf, int len, const float coeff[2], uint32_t frequency)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
gamma2resistance(char *buf, int len, const float coeff[2], uint32_t frequency)
|
||||
{
|
||||
float z0 = 50;
|
||||
float d = z0 / ((1-coeff[0])*(1-coeff[0])+coeff[1]*coeff[1]);
|
||||
float zr = ((1+coeff[0])*(1-coeff[0]) - coeff[1]*coeff[1]) * d;
|
||||
string_value_with_prefix(buf, len, zr, S_OHM[0]);
|
||||
}
|
||||
|
||||
void
|
||||
gamma2reactance(char *buf, int len, const float coeff[2], uint32_t frequency)
|
||||
{
|
||||
float z0 = 50;
|
||||
float d = z0 / ((1-coeff[0])*(1-coeff[0])+coeff[1]*coeff[1]);
|
||||
float zi = 2*coeff[1] * d;
|
||||
string_value_with_prefix(buf, len, zi, S_OHM[0]);
|
||||
}
|
||||
|
||||
void
|
||||
trace_get_value_string(int t, char *buf, int len, float coeff[2], uint32_t frequency)
|
||||
{
|
||||
|
|
@ -614,6 +658,18 @@ trace_get_value_string(int t, char *buf, int len, float coeff[2], uint32_t frequ
|
|||
case TRC_SMITH:
|
||||
gamma2imp(buf, len, coeff, frequency);
|
||||
break;
|
||||
case TRC_REAL:
|
||||
chsnprintf(buf, len, "%.2f", coeff[0]);
|
||||
break;
|
||||
case TRC_IMAG:
|
||||
chsnprintf(buf, len, "%.2fj", coeff[1]);
|
||||
break;
|
||||
case TRC_R:
|
||||
gamma2resistance(buf, len, coeff, frequency);
|
||||
break;
|
||||
case TRC_X:
|
||||
gamma2reactance(buf, len, coeff, frequency);
|
||||
break;
|
||||
//case TRC_ADMIT:
|
||||
case TRC_POLAR:
|
||||
chsnprintf(buf, len, "%.2f %.2fj", coeff[0], coeff[1]);
|
||||
|
|
|
|||
16
ui.c
16
ui.c
|
|
@ -546,6 +546,18 @@ menu_format2_cb(int item)
|
|||
case 1:
|
||||
set_trace_type(uistat.current_trace, TRC_LINEAR);
|
||||
break;
|
||||
case 2:
|
||||
set_trace_type(uistat.current_trace, TRC_REAL);
|
||||
break;
|
||||
case 3:
|
||||
set_trace_type(uistat.current_trace, TRC_IMAG);
|
||||
break;
|
||||
case 4:
|
||||
set_trace_type(uistat.current_trace, TRC_R);
|
||||
break;
|
||||
case 5:
|
||||
set_trace_type(uistat.current_trace, TRC_X);
|
||||
break;
|
||||
}
|
||||
|
||||
request_to_redraw_grid();
|
||||
|
|
@ -735,6 +747,10 @@ const menuitem_t menu_trace[] = {
|
|||
const menuitem_t menu_format2[] = {
|
||||
{ MT_CALLBACK, "POLAR", menu_format2_cb },
|
||||
{ MT_CALLBACK, "LINEAR", menu_format2_cb },
|
||||
{ MT_CALLBACK, "REAL", menu_format2_cb },
|
||||
{ MT_CALLBACK, "IMAG", menu_format2_cb },
|
||||
{ MT_CALLBACK, "RESISTANCE", menu_format2_cb },
|
||||
{ MT_CALLBACK, "REACTANCE", menu_format2_cb },
|
||||
{ MT_CANCEL, S_LARROW" BACK", NULL },
|
||||
{ MT_NONE, NULL, NULL } // sentinel
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue