mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2026-01-20 15:20:19 +01:00
chore: store velocity factor in float
This commit is contained in:
parent
c4495b6d58
commit
e1ba0c77f0
3
main.c
3
main.c
|
|
@ -618,7 +618,8 @@ properties_t current_props = {
|
|||
._markers = {
|
||||
{ 1, 30, 0 }, { 0, 40, 0 }, { 0, 60, 0 }, { 0, 80, 0 }
|
||||
},
|
||||
._velocity_factor = 70,
|
||||
._velocity_factor = 0.7,
|
||||
._marker_smith_format = MS_RLC
|
||||
};
|
||||
properties_t *active_props = ¤t_props;
|
||||
|
||||
|
|
|
|||
18
nanovna.h
18
nanovna.h
|
|
@ -295,8 +295,8 @@ void ili9341_read_memory_continue(int len, uint16_t* out);
|
|||
|
||||
typedef struct {
|
||||
uint32_t magic;
|
||||
uint32_t _frequency0; // start or center
|
||||
uint32_t _frequency1; // stop or span
|
||||
uint32_t _frequency0;
|
||||
uint32_t _frequency1;
|
||||
int16_t _sweep_points;
|
||||
uint16_t _cal_status;
|
||||
|
||||
|
|
@ -306,14 +306,18 @@ typedef struct {
|
|||
|
||||
trace_t _trace[TRACES_MAX];
|
||||
marker_t _markers[MARKERS_MAX];
|
||||
int _active_marker;
|
||||
uint8_t _domain_mode; /* 0bxxxxxffm : where ff: TD_FUNC m: DOMAIN_MODE */
|
||||
uint8_t _velocity_factor; // %
|
||||
|
||||
uint8_t _reserved[54];
|
||||
float _velocity_factor; // %
|
||||
int8_t _active_marker;
|
||||
uint8_t _domain_mode; /* 0bxxxxxffm : where ff: TD_FUNC m: DOMAIN_MODE */
|
||||
uint8_t _marker_smith_format;
|
||||
|
||||
uint8_t _reserved[50];
|
||||
int32_t checksum;
|
||||
} properties_t;
|
||||
|
||||
//sizeof(properties_t) == 0x1200
|
||||
|
||||
#define CONFIG_MAGIC 0x434f4e45 /* 'CONF' */
|
||||
|
||||
extern int16_t lastsaveid;
|
||||
|
|
@ -335,6 +339,7 @@ extern int8_t previous_marker;
|
|||
#define active_marker current_props._active_marker
|
||||
#define domain_mode current_props._domain_mode
|
||||
#define velocity_factor current_props._velocity_factor
|
||||
#define marker_smith_format current_props._marker_smith_format
|
||||
|
||||
int caldata_save(int id);
|
||||
int caldata_recall(int id);
|
||||
|
|
@ -367,7 +372,6 @@ typedef struct {
|
|||
uint32_t previous_value;
|
||||
uint8_t lever_mode;
|
||||
bool marker_delta;
|
||||
uint8_t marker_smith_format;
|
||||
} uistat_t;
|
||||
|
||||
extern uistat_t uistat;
|
||||
|
|
|
|||
6
plot.c
6
plot.c
|
|
@ -636,7 +636,7 @@ format_smith_value(char *buf, int len, const float coeff[2], uint32_t frequency)
|
|||
float zi = 2*coeff[1] * d;
|
||||
int n;
|
||||
|
||||
switch (uistat.marker_smith_format) {
|
||||
switch (marker_smith_format) {
|
||||
case MS_LIN:
|
||||
chsnprintf(buf, len, "%.2f %.1f" S_DEGREE, linear(coeff), phase(coeff));
|
||||
break;
|
||||
|
|
@ -829,7 +829,7 @@ static float time_of_index(int idx) {
|
|||
static float distance_of_index(int idx) {
|
||||
#define SPEED_OF_LIGHT 299792458
|
||||
float distance = ((float)idx * (float)SPEED_OF_LIGHT) / ( (float)(frequencies[1] - frequencies[0]) * (float)FFT_SIZE * 2.0);
|
||||
return distance * (velocity_factor / 100.0);
|
||||
return distance * velocity_factor;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1687,7 +1687,7 @@ cell_draw_marker_info(int m, int n, int w, int h)
|
|||
cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff);
|
||||
xpos += n * 5 + 5;
|
||||
float light_speed_ps = 299792458e-12; //(m/ps)
|
||||
string_value_with_prefix(buf, sizeof buf, electrical_delay * light_speed_ps * velocity_factor / 100.0, 'm');
|
||||
string_value_with_prefix(buf, sizeof buf, electrical_delay * light_speed_ps * velocity_factor, 'm');
|
||||
cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
9
ui.c
9
ui.c
|
|
@ -31,7 +31,6 @@ uistat_t uistat = {
|
|||
current_trace: 0,
|
||||
lever_mode: LM_MARKER,
|
||||
marker_delta: FALSE,
|
||||
marker_smith_format: MS_RLC
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -888,7 +887,7 @@ menu_marker_search_cb(int item)
|
|||
static void
|
||||
menu_marker_smith_cb(int item)
|
||||
{
|
||||
uistat.marker_smith_format = item;
|
||||
marker_smith_format = item;
|
||||
redraw_marker(active_marker, TRUE);
|
||||
draw_menu();
|
||||
}
|
||||
|
|
@ -1421,7 +1420,7 @@ menu_item_modify_attribute(const menuitem_t *menu, int item,
|
|||
}
|
||||
}
|
||||
} else if (menu == menu_marker_smith) {
|
||||
if (uistat.marker_smith_format == item) {
|
||||
if (marker_smith_format == item) {
|
||||
*bg = 0x0000;
|
||||
*fg = 0xffff;
|
||||
}
|
||||
|
|
@ -1590,7 +1589,7 @@ fetch_numeric_target(void)
|
|||
uistat.value = get_electrical_delay();
|
||||
break;
|
||||
case KM_VELOCITY_FACTOR:
|
||||
uistat.value = velocity_factor;
|
||||
uistat.value = velocity_factor * 100;
|
||||
break;
|
||||
case KM_SCALEDELAY:
|
||||
uistat.value = get_trace_scale(uistat.current_trace) * 1e12;
|
||||
|
|
@ -1894,7 +1893,7 @@ keypad_click(int key)
|
|||
set_electrical_delay(value); // pico seconds
|
||||
break;
|
||||
case KM_VELOCITY_FACTOR:
|
||||
velocity_factor = value;
|
||||
velocity_factor = value / 100.0;
|
||||
break;
|
||||
case KM_SCALEDELAY:
|
||||
set_trace_scale(uistat.current_trace, value * 1e-12); // pico second
|
||||
|
|
|
|||
Loading…
Reference in a new issue