multi_trace
erikkaashoek 5 years ago
parent 9ecd1a78ba
commit 95f64ae07f

@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1672673687719504" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="300448615141682" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
@ -17,7 +17,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1672673687719504" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="300448615141682" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>

@ -921,10 +921,10 @@ config_t config = {
static const marker_t def_markers[MARKERS_MAX] = {
{ M_ENABLED, M_TRACKING, 0, 30, 0 },
{ M_DISABLED, M_NORMAL, 0, 40, 0 },
{ M_DISABLED, M_NORMAL, 0, 60, 0 },
{ M_DISABLED, M_NORMAL, 0, 80, 0 }
{M_TRACKING, M_ENABLED, 0, TRACE_ACTUAL, 30, 0 },
{M_NORMAL, M_DISABLED, 0, TRACE_ACTUAL, 40, 0 },
{M_NORMAL, M_DISABLED, 0, TRACE_ACTUAL, 60, 0 },
{M_NORMAL, M_DISABLED, 0, TRACE_ACTUAL, 80, 0 }
};
// Load propeties default settings
@ -1341,10 +1341,10 @@ VNA_SHELL_FUNCTION(cmd_recall)
shell_printf("recall {id}\r\n");
}
const char * const trc_channel_name[] = {
[TRACE_ACTUAL] = "ACTUAL",
const char * const trc_channel_name[TRACES_MAX] = {
[TRACE_ACTUAL] = "MEASURED",
[TRACE_STORED] = "STORED",
[TRACE_TEMP] = "COMPUTED",
[TRACE_TEMP] = "RAW",
};
void set_trace_scale(float scale)
@ -1404,7 +1404,7 @@ VNA_SHELL_FUNCTION(cmd_trace)
if (type >= 0) {
switch(type) {
case 0:
set_storage();
store_trace(0,2);
goto update;
case 1:
set_clear_storage();

@ -76,6 +76,7 @@
#define __CHANNEL_POWER__
#define __LIMITS__
#define __MCU_CLOCK_SHIFT__
#define __TRACE_MENU__
#ifdef TINYSA4
#define __USE_RTC__ // Enable RTC clock
#define __USE_SD_CARD__ // Enable SD card support
@ -133,14 +134,15 @@
#endif
#ifdef TINYSA4
#define MARKER_COUNT 8
#define TRACES_MAX 3
#else
#define MARKER_COUNT 4
#define TRACES_MAX 3
#endif
#define TRACES_MAX 3
#define TRACE_ACTUAL 0 // order linked to redraw_request flags!!!!!
#define TRACE_STORED 1
#define TRACE_TEMP 2
#define TRACE_ACTUAL 0 // order linked to colors in palette!!!!!
#define TRACE_TEMP (LCD_TRACE_2_COLOR - LCD_TRACE_1_COLOR)
#define TRACE_STORED (LCD_TRACE_3_COLOR - LCD_TRACE_1_COLOR)
//#define TRACE_AGE 3
#define TRACE_INVALID -1
@ -149,6 +151,8 @@
#define temp_t measured[TRACE_TEMP]
// #define age_t measured[TRACE_AGE]
extern const char * const trc_channel_name[];
#ifdef TINYSA3
typedef uint32_t freq_t;
typedef int32_t long_t;
@ -301,7 +305,8 @@ void set_attenuation(float);
float get_attenuation(void);
float get_level(void);
void set_harmonic(int);
void set_storage(void);
void store_trace(int f, int t);
void subtract_trace(int t, int f);
//extern int setting.harmonic;
int search_is_greater(void);
void set_auto_attenuation(void);
@ -330,8 +335,7 @@ void set_spur(int v);
void toggle_spur(void);
void toggle_mirror_masking(void);
#endif
void set_average(int);
int GetAverage(void);
void set_average(int t, int);
//extern int setting.average;
void set_storage(void);
void set_clear_storage(void);
@ -720,6 +724,7 @@ typedef struct {
uint8_t mtype;
uint8_t enabled;
uint8_t ref;
uint8_t trace;
int16_t index;
freq_t frequency;
} marker_t;
@ -862,8 +867,8 @@ typedef uint16_t pixel_t;
[LCD_MENU_TEXT_COLOR ] = RGB565( 0, 0, 0), \
[LCD_MENU_ACTIVE_COLOR] = RGB565(210,210,210), \
[LCD_TRACE_1_COLOR ] = RGB565(255,255, 0), \
[LCD_TRACE_2_COLOR ] = RGB565( 0,255, 0), \
[LCD_TRACE_3_COLOR ] = RGB565(255, 0, 0), \
[LCD_TRACE_2_COLOR ] = RGB565(255, 0, 0), \
[LCD_TRACE_3_COLOR ] = RGB565( 0,255, 0), \
[LCD_TRACE_4_COLOR ] = RGB565(255, 0,255), \
[LCD_NORMAL_BAT_COLOR ] = RGB565( 31,227, 0), \
[LCD_LOW_BAT_COLOR ] = RGB565(255, 0, 0), \
@ -945,13 +950,13 @@ typedef struct setting
bool auto_reflevel; // bool
bool auto_attenuation; // bool
bool mirror_masking; // bool
bool subtract_stored; // bool
bool show_stored; // bool
bool tracking_output; // bool
bool mute; // bool
bool auto_IF; // bool
bool sweep; // bool
bool pulse; // bool
bool stored[TRACES_MAX]; // enum
uint8_t mode; // enum
uint8_t below_IF; // enum
@ -964,7 +969,8 @@ typedef struct setting
uint8_t trigger_direction; // enum
uint8_t step_delay_mode; // enum
uint8_t waterfall; // enum
uint8_t average; // enum
uint8_t average[TRACES_MAX]; // enum
uint8_t subtract[TRACES_MAX];// index
uint8_t measurement; // enum
uint8_t spur_removal; // enum
@ -1159,7 +1165,7 @@ typedef struct properties {
//sizeof(properties_t) == 0x1200
#define CONFIG_MAGIC 0x434f4e53 /* 'CONF' */
#define CONFIG_MAGIC 0x434f4e54 /* 'CONF' */
extern int16_t lastsaveid;
//extern properties_t *active_props;

@ -88,17 +88,9 @@ typedef uint16_t index_y_t;
static index_x_t trace_index_x[POINTS_COUNT];
static index_y_t trace_index_y[TRACES_MAX][POINTS_COUNT];
uint16_t marker_color(int mtype)
uint16_t marker_color(int m_i)
{
// if (mtype & M_REFERENCE)
// return LCD_M_REFERENCE;
if (mtype & M_STORED)
return LCD_M_DELTA;
// if (mtype & M_DELTA)
// return LCD_BRIGHT_COLOR_RED;
// if (mtype & M_NOISE)
// return LCD_M_NOISE;
return LCD_M_DEFAULT;
return LCD_TRACE_1_COLOR + markers[m_i].trace;
}
#if 1
@ -303,10 +295,7 @@ marker_to_value(const int i)
return marker_cache[i];
#endif
float *ref_marker_levels;
if (markers[i].mtype & M_STORED )
ref_marker_levels = stored_t;
else
ref_marker_levels = actual_t;
ref_marker_levels = measured[markers[i].trace];
float v = value(ref_marker_levels[markers[i].index]);
if (markers[i].mtype & M_AVER) {
int old_unit = setting.unit;
@ -1143,17 +1132,13 @@ draw_cell(int m, int n)
// PULSE;
// draw marker symbols on each trace (<10 system ticks for all screen calls)
#if 1
for (int t = TRACE_ACTUAL; t <= TRACE_STORED; t++ ) {
for (int t = TRACE_ACTUAL; t < TRACES_MAX; t++ ) {
if (IS_TRACE_ENABLE(t)) {
for (i = 0; i < MARKERS_MAX; i++) {
if (!markers[i].enabled)
continue;
if (markers[i].mtype & M_STORED) {
if (t == TRACE_ACTUAL)
continue;
} else {
if (t == TRACE_STORED)
continue;
if (markers[i].trace != t) {
continue;
}
int idx = markers[i].index;
int x = trace_index_x[idx] - x0 - X_MARKER_OFFSET;
@ -1636,7 +1621,7 @@ static void cell_draw_marker_info(int x0, int y0)
}
float thd = 100.0 * sa_sqrtf(h/p);
setting.unit = old_unit;
ili9341_set_foreground(marker_color(markers[0].mtype));
ili9341_set_foreground(marker_color(0));
// j = 1;
int xpos = 1 + (j%2)*(WIDTH/2) + CELLOFFSETX - x0;
int ypos = 1 + (j/2)*(16) - y0;
@ -1659,7 +1644,7 @@ static void cell_draw_marker_info(int x0, int y0)
// log10f(x) = logf(x)/logf(10)
ili9341_set_foreground(marker_color(markers[0].mtype));
ili9341_set_foreground(marker_color(0));
// j = 1;
int xpos = 1 + (j%2)*(WIDTH/2) + CELLOFFSETX - x0;
int ypos = 1 + (j/2)*(16) - y0;
@ -1705,26 +1690,22 @@ static void cell_draw_marker_info(int x0, int y0)
#endif
if (!markers[i].enabled)
continue;
for (t = TRACE_ACTUAL; t <= TRACE_STORED; t++) { // Only show info on actual trace
for (t = TRACE_ACTUAL; t < TRACES_MAX; t++) { // Only show info on actual trace
if (IS_TRACE_DISABLE(t))
continue;
if (markers[i].mtype & M_STORED) {
if (t == TRACE_ACTUAL)
continue;
} else {
if (t == TRACE_STORED)
continue;
if (markers[i].trace != t) {
continue;
}
uint16_t color;
int level = temppeakLevel - get_attenuation() + setting.external_gain;
if ((!setting.subtract_stored) && // Disabled when normalized
if ((!setting.subtract[t]) && // Disabled when normalized
((setting.mode == M_LOW && level > -10)
|| (setting.mode == M_HIGH && level > -29)
|| (setting.mode == M_LOW && (markers[i].mtype & M_NOISE) && vbwSteps > 1)) //MAXPEAK increases noise marker, should reduce span.
)
color = LCD_BRIGHT_COLOR_RED;
else
color = marker_color(markers[i].mtype);
color = marker_color(i);
ili9341_set_foreground(color);
ili9341_set_background(LCD_BG_COLOR);
#if 1
@ -1934,11 +1915,15 @@ static void update_waterfall(void){
ili9341_read_memory(OFFSETX, i, w_width, 1, spi_buffer);
ili9341_bulk(OFFSETX, i+1, w_width, 1);
}
index_y_t *index;
if (setting.average == AV_OFF)
index = trace_index_y[TRACE_ACTUAL];
else
index = trace_index_y[TRACE_TEMP];
index_y_t *index = NULL;
for (int t=0;t<TRACES_MAX;t++) { // Find trace with active measurement
if (IS_TRACE_ENABLE(t) && setting.average[t] == AV_OFF) {
index = trace_index_y[t];
break;
}
}
if (index == NULL)
return;
int j = 0;
for (i=0; i< sweep_points; i++) { // Add new topline
uint16_t color;

@ -97,7 +97,7 @@ VNA_SHELL_FUNCTION(cmd_calc )
linear_averaging = (m == 9);
} else
#endif
set_average(m);
set_average(0, m);
}
int generic_option_cmd( const char *cmd, const char *cmd_list, int argc, char *argv)

@ -237,7 +237,11 @@ void reset_settings(int m)
setting.rx_drive=MAX_DRIVE; // And this
setting.atten_step = 0; // And this, only used in low output mode
setting.rbw_x10 = 0;
setting.average = 0;
for (int t=0;t<TRACES_MAX;t++) {
setting.average[t] = 0;
setting.stored[t] = false;
setting.subtract[t] = 0;
}
#ifdef TINYSA4
setting.harmonic = 3; // Automatically used when above ULTRA_MAX_FREQ
#else
@ -245,7 +249,6 @@ void reset_settings(int m)
#endif
setting.show_stored = 0;
setting.auto_attenuation = false;
setting.subtract_stored = false;
setting.normalize_level = 0.0;
#ifdef TINYSA4
setting.lo_drive=5;
@ -930,28 +933,29 @@ void limits_update(void)
}
#endif
void set_storage(void)
void store_trace(int f, int t)
{
for (int i=0; i<POINTS_COUNT;i++)
stored_t[i] = actual_t[i];
setting.show_stored = true;
enableTracesAtComplete(TRACE_STORED_FLAG);
measured[t][i] = measured[f][i];
setting.stored[t] = true;
enableTracesAtComplete(1<<t);
//dirty = true; // No HW update required, only status panel refresh
}
void set_clear_storage(void)
{
setting.show_stored = false;
setting.subtract_stored = false;
// setting.subtract = false;
TRACE_DISABLE(TRACE_STORED_FLAG);
// dirty = true; // No HW update required, only status panel refresh
}
void set_subtract_storage(void)
{
/*
if (!setting.subtract_stored) {
if (!setting.show_stored)
set_storage();
store_trace(0,2);
setting.subtract_stored = true;
setting.normalize_level = 0.0;
// setting.auto_attenuation = false;
@ -959,12 +963,21 @@ void set_subtract_storage(void)
setting.subtract_stored = false;
}
//dirty = true; // No HW update required, only status panel refresh
*/
}
void subtract_trace(int t, int f)
{
if (!setting.subtract[t]) {
setting.subtract[t] = f;
setting.normalize_level = 0.0;
} else
setting.subtract[t] = 0;
}
void toggle_normalize(void)
{
if (!setting.subtract_stored) {
/* if (!setting.subtract_stored) {
for (int i=0; i<POINTS_COUNT;i++)
stored_t[i] = actual_t[i];
setting.subtract_stored = true;
@ -973,6 +986,7 @@ void toggle_normalize(void)
} else {
setting.subtract_stored = false;
}
*/
//dirty = true; // No HW update required, only status panel refresh
}
@ -1143,21 +1157,23 @@ void set_offset_delay(int d) // override RSSI measurement delay
}
void set_average(int v)
void set_average(int t, int v)
{
if (setting.average == v) // Clear calc on second click
if (setting.average[t] == v) // Clear calc on second click
dirty = true;
setting.average = v;
setting.average[t] = v;
bool enable = ((v != 0)
#ifdef __QUASI_PEAK__
&& (v != AV_QUASI)
#endif
);
#ifndef __TRACES_MENU__
if (enable) {
enableTracesAtComplete(TRACE_TEMP_FLAG);
scan_after_dirty = 0;
} else
TRACE_DISABLE(TRACE_TEMP_FLAG);
#endif
//dirty = true; // No HW update required, only status panel refresh
}
@ -2220,11 +2236,7 @@ int index_of_frequency(freq_t f) // Search which index in the frequency tab
void interpolate_maximum(int m)
{
float *ref_marker_levels;
if (markers[m].mtype & M_STORED )
ref_marker_levels = stored_t;
else
ref_marker_levels = actual_t;
float *ref_marker_levels = measured[markers[m].trace];
const int idx = markers[m].index;
markers[m].frequency = getFrequency(idx);
if (idx > 0 && idx < sweep_points-1)
@ -2248,12 +2260,7 @@ void interpolate_maximum(int m)
int
search_maximum(int m, freq_t center, int span)
{
float *ref_marker_levels;
if (markers[m].mtype & M_STORED )
ref_marker_levels = stored_t;
else
ref_marker_levels = actual_t;
float *ref_marker_levels = measured[markers[m].trace];
#ifdef TINYSA4
int center_index = index_of_frequency(center);
#else
@ -3544,7 +3551,7 @@ again: // Spur redu
}
#endif
#ifdef __SI4463__
if (i == 0 && setting.frequency_step == 0 && setting.trigger == T_AUTO && S_STATE(setting.spur_removal) == 0 && SI4432_step_delay == 0 && setting.repeat == 1 && setting.sweep_time_us < 100*ONE_MS_TIME) {
if (i == 0 && setting.frequency_step == 0 && setting.trigger == T_AUTO && S_STATE(setting.spur_removal) == 0 && SI4432_step_delay == 0 && setting.repeat == 1 && setting.sweep_time_us < 100*ONE_MS_TIME && setting.exp_aver == 1) {
SI446x_Fill(MODE_SELECT(setting.mode), -1); // First get_RSSI will fail
}
#endif
@ -3803,6 +3810,10 @@ static bool sweep(bool break_on_operation)
sweep_again: // stay in sweep loop when output mode and modulation on.
temppeakLevel = -150;
float temp_min_level = 100; // Initialize the peak search algorithm
int16_t downslope = true;
// ------------------------- start sweep loop -----------------------------------
for (int i = 0; i < sweep_points; i++) {
debug_avoid_second = false;
@ -3903,18 +3914,13 @@ static bool sweep(bool break_on_operation)
debug_avoid_second = false;
}
}
temp_t[i] = RSSI;
#ifdef __DOUBLE_LOOP__
}
// -------------------------------- Scan finished, do all postprocessing --------------------
float temp_min_level = 100;
if (MODE_INPUT(setting.mode)) {
int16_t downslope = true; // Initialize the peak search algorithm
temppeakLevel = -150;
// #ifdef __VBW__
#if 0
#ifdef __FFT_VBW__
@ -4075,16 +4081,22 @@ static volatile int dummy;
#endif
#endif
// ------------------------ do all RSSI calculations from CALC menu -------------------
#ifdef __FFT_DECONV__
#ifdef __FFT_DECONV__
if (setting.average == AV_DECONV)
RSSI = actual_t[i];
else
#endif
RSSI = temp_t[i];
if (setting.subtract_stored) {
RSSI = RSSI - stored_t[i] + setting.normalize_level;
#else
for (int t=0; t<TRACES_MAX;t++) {
if (setting.stored[t])
continue;
float *trace_data = measured[t];
#endif // __DOUBLE_LOOP__
// ------------------------ do all RSSI calculations from CALC menu -------------------
if (setting.subtract[t]) {
RSSI = RSSI - measured[setting.subtract[t]-1][i] + setting.normalize_level;
}
#ifdef __SI4432__
//#define __DEBUG_AGC__
@ -4101,26 +4113,26 @@ static volatile int dummy;
last_AGC_value = AGC_value;
}
#endif
if (scandirty || setting.average == AV_OFF) { // Level calculations
if (setting.average == AV_MAX_DECAY) age[i] = 0;
actual_t[i] = RSSI;
if (scandirty || setting.average[t] == AV_OFF) { // Level calculations
if (setting.average[t] == AV_MAX_DECAY) age[i] = 0;
trace_data[i] = RSSI;
} else {
switch(setting.average) {
case AV_MIN: if (actual_t[i] > RSSI) actual_t[i] = RSSI; break;
case AV_MAX_HOLD: if (actual_t[i] < RSSI) actual_t[i] = RSSI; break;
switch(setting.average[t] ) {
case AV_MIN: if (trace_data[i] > RSSI) trace_data[i] = RSSI; break;
case AV_MAX_HOLD: if (trace_data[i] < RSSI) trace_data[i] = RSSI; break;
case AV_MAX_DECAY:
if (actual_t[i] < RSSI) {
if (trace_data[i] < RSSI) {
age[i] = 0;
actual_t[i] = RSSI;
trace_data[i] = RSSI;
} else {
if (age[i] > setting.decay)
actual_t[i] -= 0.5;
trace_data[i] -= 0.5;
else
age[i] += 1;
}
break;
case AV_4: actual_t[i] = (actual_t[i]*3.0 + RSSI) / 4.0; break;
case AV_16: actual_t[i] = (actual_t[i]*15.0 + RSSI) / 16.0; break;
case AV_4: trace_data[i] = (trace_data[i]*3.0 + RSSI) / 4.0; break;
case AV_16: trace_data[i] = (trace_data[i]*15.0 + RSSI) / 16.0; break;
case AV_100:
#ifdef TINYSA4
if (linear_averaging)
@ -4128,46 +4140,45 @@ static volatile int dummy;
#if 0
int old_unit = setting.unit;
setting.unit = U_WATT; // Power averaging should always be done in Watts
actual_t[i] = to_dBm((value(actual_t[i])*(scan_after_dirty-1) + value(RSSI)) / scan_after_dirty );
trace_data[i] = to_dBm((value(trace_data[i])*(scan_after_dirty-1) + value(RSSI)) / scan_after_dirty );
setting.unit = old_unit;
#else
float v = (expf(actual_t[i]*(logf(10.0)/10.0)) * (scan_after_dirty-1) + expf(RSSI * (logf(10.0)/10.0))) / scan_after_dirty;
actual_t[i] = logf(v)*(10.0/logf(10.0));
float v = (expf(trace_data[i]*(logf(10.0)/10.0)) * (scan_after_dirty-1) + expf(RSSI * (logf(10.0)/10.0))) / scan_after_dirty;
trace_data[i] = logf(v)*(10.0/logf(10.0));
#endif
}
else
actual_t[i] = (actual_t[i]*(scan_after_dirty-1) + RSSI)/ scan_after_dirty;
trace_data[i] = (trace_data[i]*(scan_after_dirty-1) + RSSI)/ scan_after_dirty;
#else
actual_t[i] = (actual_t[i]*(scan_after_dirty-1) + RSSI)/ scan_after_dirty;
trace_data[i] = (trace_data[i]*(scan_after_dirty-1) + RSSI)/ scan_after_dirty;
#endif
break;
#ifdef __QUASI_PEAK__
case AV_QUASI:
{ static float old_RSSI = -150.0;
if (i == 0) old_RSSI = actual_t[sweep_points-1];
if (i == 0) old_RSSI = trace_data[sweep_points-1];
if (RSSI > old_RSSI && setting.attack > 1)
old_RSSI += (RSSI - old_RSSI)/setting.attack;
else if (RSSI < old_RSSI && setting.decay > 1)
old_RSSI += (RSSI - old_RSSI)/setting.decay;
else
old_RSSI = RSSI;
actual_t[i] = old_RSSI;
trace_data[i] = old_RSSI;
}
break;
#endif
#if 0
case AV_DECONV:
actual_t[i] = temp_t[i] - temp_t[0];
trace_data[i] = temp_t[i] - temp_t[0];
int lower = ( i - d_width + 1 < 0 ? 0 : i - d_width + 1);
for (int k = lower; k < i; k++)
actual_t[i] -= actual_t[k] * (stored_t[d_start + i - k] - d_offset) / d_scale;
// actual_t[i] /= (stored_t[d_start] - d_offset ) /d_scale;
trace_data[i] -= trace_data[k] * (stored_t[d_start + i - k] - d_offset) / d_scale;
// trace_data[i] /= (stored_t[d_start] - d_offset ) /d_scale;
break;
#endif
}
}
if ( actual_t[i] > -174.0 && temp_min_level > actual_t[i]) // Remember minimum
temp_min_level = actual_t[i];
@ -4686,11 +4697,7 @@ int
marker_search_left_max(int m)
{
int i;
float *ref_marker_levels;
if (markers[m].mtype & M_STORED )
ref_marker_levels = stored_t;
else
ref_marker_levels = actual_t;
float *ref_marker_levels = measured[markers[m].trace];
int from = markers[m].index;
int found = -1;
@ -4722,11 +4729,7 @@ int
marker_search_right_max(int m)
{
int i;
float *ref_marker_levels;
if (markers[m].mtype & M_STORED )
ref_marker_levels = stored_t;
else
ref_marker_levels = actual_t;
float *ref_marker_levels = measured[markers[m].trace];
int from = markers[m].index;
int found = -1;
@ -4768,11 +4771,7 @@ void markers_reset()
int marker_search_max(int m)
{
int i = 0;
float *ref_marker_levels;
if (markers[m].mtype & M_STORED )
ref_marker_levels = stored_t;
else
ref_marker_levels = actual_t;
float *ref_marker_levels = measured[markers[m].trace];
int found = 0;
float value = ref_marker_levels[i];
@ -4793,11 +4792,7 @@ int
marker_search_left_min(int m)
{
int i;
float *ref_marker_levels;
if (markers[m].mtype & M_STORED )
ref_marker_levels = stored_t;
else
ref_marker_levels = actual_t;
float *ref_marker_levels = measured[markers[m].trace];
int from = markers[m].index;
int found = from;
if (uistat.current_trace == TRACE_INVALID)
@ -4828,11 +4823,7 @@ int
marker_search_right_min(int m)
{
int i;
float *ref_marker_levels;
if (markers[m].mtype & M_STORED )
ref_marker_levels = stored_t;
else
ref_marker_levels = actual_t;
float *ref_marker_levels = measured[markers[m].trace];
int from = markers[m].index;
int found = from;
@ -5781,7 +5772,7 @@ quit:
osalThreadSleepMilliseconds(200);
// setting.spur_removal = S_ON;
setting.R = 3;
set_average(AV_100);
set_average(0,AV_100);
test_acquire(TEST_LEVEL); // Acquire test
test_acquire(TEST_LEVEL); // Acquire test
test_acquire(TEST_LEVEL); // Acquire test
@ -5806,7 +5797,7 @@ quit:
set_repeat(5);
setting.rbw_x10 = force_rbw(j);
set_sweep_frequency(ST_SPAN, (freq_t)(setting.rbw_x10 * (1000 << k)));
set_average(AV_100);
set_average(0,AV_100);
test_acquire(TEST_RBW); // Acquire test
test_acquire(TEST_RBW); // Acquire test
test_acquire(TEST_RBW); // Acquire test
@ -5845,7 +5836,7 @@ abort:
setting.rbw_x10 = force_rbw(j);
setting.extra_lna = true;
osalThreadSleepMilliseconds(200);
set_average(AV_100);
set_average(0,AV_100);
for (int w=0; w<50; w++) {
test_acquire(TC_LEVEL); // Acquire test
}
@ -5876,7 +5867,7 @@ abort:
osalThreadSleepMilliseconds(200);
markers[0].mtype = M_NOISE | M_AVER;
set_sweep_frequency(ST_SPAN, (freq_t)(setting.rbw_x10 * (1000 << k)));
set_average(AV_100);
set_average(0,AV_100);
test_acquire(TC_LEVEL); // Acquire test
test_acquire(TC_LEVEL); // Acquire test
test_acquire(TC_LEVEL); // Acquire test
@ -6003,7 +5994,7 @@ again:
#ifdef TINYSA4
set_extra_lna(calibrate_lna);
#endif
set_average(AV_100);
set_average(0, AV_100);
for (int m=1; m<20; m++) {
test_acquire(test_case); // Acquire test
local_test_status = test_validate(test_case);
@ -6026,7 +6017,7 @@ again:
set_attenuation(10);
set_repeat(5);
setting.spur_removal = S_OFF;
set_average(AV_100);
set_average(0,AV_100);
test_acquire(test_case); // Acquire test
test_acquire(test_case); // Acquire test
test_acquire(test_case); // Acquire test
@ -6040,7 +6031,7 @@ again:
test_prepare(test_case);
set_RBW(3000);
set_attenuation(10);
set_average(AV_100);
set_average(0,AV_100);
test_acquire(test_case); // Acquire test
test_acquire(test_case); // Acquire test
test_acquire(test_case); // Acquire test
@ -6112,7 +6103,7 @@ quit:
// set_refer_output(-1);
#ifdef TINYSA4
set_extra_lna(false);
set_average(AV_OFF);
set_average(0,AV_OFF);
// set_refer_output(-1);
#else
reset_settings(M_LOW);

@ -515,6 +515,8 @@ static const menuitem_t menu_lowoutputmode[];
static const menuitem_t menu_highoutputmode[];
static const menuitem_t menu_modulation[];
static const menuitem_t menu_top[];
static const menuitem_t menu_trace[];
static const menuitem_t menu_subtract_trace[];
static const menuitem_t menu_reffer[];
static const menuitem_t menu_sweep_points[];
static const menuitem_t menu_sweep_points_form[];
@ -826,7 +828,7 @@ UI_FUNCTION_CALLBACK(menu_autosettings_cb)
// set_refer_output(1);
// SetPowerLevel(100); // Reset
set_clear_storage();
// set_clear_storage();
dirty = true;
// menu_move_back(true); // stay in input menu
ui_mode_normal();
@ -1227,7 +1229,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb)
if (setting.measurement == M_LINEARITY) {
TRACE_DISABLE(TRACE_STORED_FLAG);
}
set_average(AV_OFF);
set_average(0,AV_OFF);
set_external_gain(0.0);
#ifdef TINYSA4
set_extra_lna(false);
@ -1246,7 +1248,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb)
ui_mode_keypad(KM_CENTER);
set_sweep_frequency(ST_START, 0);
set_sweep_frequency(ST_STOP, uistat.value*(MARKERS_MAX+1));
set_average(AV_4);
set_average(0,AV_4);
// set_measurement(M_IMD);
break;
case M_OIP3: // OIP3
@ -1263,7 +1265,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb)
int right = uistat.value;
set_sweep_frequency(ST_CENTER, (left+right)/2);
set_sweep_frequency(ST_SPAN, (right - left)*5);
set_average(AV_4);
set_average(0,AV_4);
// set_measurement(M_OIP3);
break;
case M_PHASE_NOISE: // Phase noise
@ -1276,7 +1278,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb)
ui_mode_keypad(KM_SPAN);
set_sweep_frequency(ST_SPAN, uistat.value*4);
// set_measurement(M_PHASE_NOISE);
set_average(AV_4);
set_average(0,AV_4);
break;
case M_SNR: // STop band measurement
@ -1287,7 +1289,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb)
ui_mode_keypad(KM_SPAN);
set_sweep_frequency(ST_SPAN, uistat.value*3);
// set_measurement(M_SNR);
set_average(AV_4);
set_average(0,AV_4);
break;
case M_PASS_BAND: // pass band measurement
@ -1323,7 +1325,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb)
freq_t span;
#else
freq_t center, span;
markers[0].mtype = M_REFERENCE;// | M_TRACKING; // Not M_TRACKING!!!!
markers[0].mtype = M_NORMAL; // M_REFERENCE | M_TRACKING; // Not M_TRACKING!!!!
#endif
kp_help_text = "Frequency of signal";
ui_mode_keypad(KM_CENTER);
@ -1346,7 +1348,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb)
set_marker_frequency(1, center-span);
set_marker_frequency(2, center+span);
#endif
set_average(AV_4);
set_average(0,AV_4);
break;
case M_FM: // FM
reset_settings(setting.mode);
@ -1379,7 +1381,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb)
// set_measurement(M_FM);
break;
case M_THD:
set_average(AV_4);
set_average(0,AV_4);
// set_measurement(M_THD);
break;
#ifdef __CHANNEL_POWER__
@ -1441,7 +1443,7 @@ validate:
}
// set_sweep_frequency(ST_SPAN, 0);
set_average(AV_100);
set_average(0,AV_100);
if (data == M_NF_TINYSA || data == M_NF_VALIDATE ) {
menu_push_submenu(menu_measure_noise_figure);
goto leave;
@ -1450,7 +1452,7 @@ validate:
#endif
#ifdef __FFT_DECONV__
case M_DECONV:
set_average(AV_DECONV);
set_average(0,AV_DECONV);
break;
#endif
}
@ -1499,13 +1501,124 @@ static UI_FUNCTION_ADV_CALLBACK(menu_reflevel_acb)
menu_move_back(true);
}
static uint8_t current_trace = TRACE_ACTUAL;
static UI_FUNCTION_ADV_CALLBACK(menu_average_acb)
{
(void)item;
if (b){
b->icon = setting.average[current_trace] == data ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP;
return;
}
set_average(current_trace,data);
ui_mode_normal();
// menu_move_back(true);
}
#ifdef __TRACE_MENU__
static UI_FUNCTION_ADV_CALLBACK(menu_trace_acb)
{
(void)item;
if(b){
b->param_1.i = data+1;
b->icon = (data == current_trace) ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP;
return;
}
current_trace = data;
menu_move_back(false);
}
static UI_FUNCTION_ADV_CALLBACK(menu_store_trace_acb)
{
(void)item;
if(b){
if (data == current_trace)
plot_printf(b->text, sizeof(b->text), "", data);
else
plot_printf(b->text, sizeof(b->text), S_RARROW"TRACE %d", data+1);
return;
}
if (data != current_trace) store_trace(current_trace,data);
menu_move_back(false);
}
static UI_FUNCTION_ADV_CALLBACK(menu_subtract_trace_acb)
{
(void)item;
if(b){
if (data)
plot_printf(b->text, sizeof(b->text), "SUBTRACT\nTRACE %d", data);
else
plot_printf(b->text, sizeof(b->text), "SUBTRACT\nDISABLED");
b->icon = (data == setting.subtract[current_trace]) ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP;
return;
}
subtract_trace(current_trace,data);
menu_move_back(false);
}
static UI_FUNCTION_ADV_CALLBACK(menu_traces_acb)
{
(void)item;
if(b){
if (data == 0) {
b->param_1.i = current_trace+1;
} else if (data == 1)
b->icon = IS_TRACE_ENABLE(current_trace) ? BUTTON_ICON_NOCHECK : BUTTON_ICON_CHECK ;
else if (data == 2)
b->icon = setting.stored[current_trace] ? BUTTON_ICON_CHECK : BUTTON_ICON_NOCHECK;
else if (data == 3) {
if (setting.stored[current_trace])
plot_printf(b->text, sizeof(b->text), "SUBTRACT\nTRACE %d", setting.stored[current_trace]);
else
plot_printf(b->text, sizeof(b->text), "SUBTRACT\nDISABLED");
}
return;
}
switch(data) {
case 0:
menu_push_submenu(menu_trace);
return;
case 1:
if (IS_TRACE_ENABLE(current_trace)) {
TRACE_DISABLE(1<<current_trace);
} else {
TRACE_ENABLE(1<<current_trace);
}
break;
case 2:
setting.stored[current_trace] = !setting.stored[current_trace];
break;
case 3:
menu_push_submenu(menu_subtract_trace);
return;
break;
#ifdef TINYSA4
case 6:
save_to_sd(1+2<<current_trace); // frequencies + trace
break;
#endif
}
// ui_mode_normal();
// draw_cal_status();
}
#endif
static UI_FUNCTION_ADV_CALLBACK(menu_storage_acb)
{
(void)item;
if(b){
if (data == 0 && setting.show_stored)
b->icon = BUTTON_ICON_CHECK;
if (setting.subtract_stored){
if (setting.subtract[0]){
if (data == 2 && setting.show_stored)
b->icon = BUTTON_ICON_CHECK;
if (data == 3 && !setting.show_stored)
@ -1515,7 +1628,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_storage_acb)
}
switch(data) {
case 0:
set_storage();
store_trace(0,2);
break;
case 1:
set_clear_storage();
@ -1525,7 +1638,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_storage_acb)
break;
case 3:
toggle_normalize();
if (setting.subtract_stored) {
if (setting.subtract[0]) {
kp_help_text = "Ref level";
ui_mode_keypad(KM_REFLEVEL);
// setting.normalize_level = uistat.value;
@ -1557,18 +1670,6 @@ static UI_FUNCTION_ADV_CALLBACK(menu_waterfall_acb){
ui_mode_normal();
}
static UI_FUNCTION_ADV_CALLBACK(menu_average_acb)
{
(void)item;
if (b){
b->icon = setting.average == data ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP;
return;
}
set_average(data);
ui_mode_normal();
// menu_move_back(true);
}
extern const menuitem_t menu_marker_modify[];
static UI_FUNCTION_ADV_CALLBACK(menu_marker_select_acb)
{
@ -1629,6 +1730,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_marker_modify_acb)
if (data == M_NORMAL) {
markers[active_marker].mtype = M_NORMAL;
}
#if 0
if (data == M_REFERENCE) {
for (int i = 0; i<MARKER_COUNT; i++ ) {
if (i != active_marker && markers[i].mtype & M_REFERENCE)
@ -1636,13 +1738,21 @@ static UI_FUNCTION_ADV_CALLBACK(menu_marker_modify_acb)
}
markers[active_marker].mtype &= ~M_DELTA;
}
#endif
if (data == M_DELTA) {
if (!(markers[active_marker].mtype & M_DELTA)) // Not yet set
menu_push_submenu(menu_marker_ref_select);
#if 0
markers[active_marker].mtype &= ~M_REFERENCE;
#endif
}
#if 1
markers[active_marker].mtype ^= data;
if (markers[active_marker].mtype & M_STORED)
markers[active_marker].trace = TRACE_STORED;
else
markers[active_marker].trace = TRACE_ACTUAL;
#else
if (markers[active_marker].mtype & data)
markers[active_marker].mtype &= ~data;
@ -2608,10 +2718,9 @@ static const menuitem_t menu_settings2[] =
{ MT_KEYPAD, KM_DECAY, "DECAY", "0..1000000ms or sweeps"},
#ifdef __QUASI_PEAK__
{ MT_KEYPAD, KM_ATTACK, "ATTACK", "0..100000ms"},
#else
{ MT_KEYPAD, KM_NOISE, "NOISE\nLEVEL", "2..20 dB"},
#endif
#ifdef TINYSA4
{ MT_KEYPAD, KM_NOISE, "NOISE\nLEVEL", "2..20 dB"},
{ MT_KEYPAD, KM_30MHZ, "ACTUAL\n30MHz*100", "Enter actual 30MHz * 100"},
#endif
{ MT_SUBMENU, 0, S_RARROW" MORE", menu_settings3},
@ -2805,7 +2914,17 @@ static const menuitem_t menu_config[] = {
{ MT_NONE, 0, NULL, menu_back} // next-> menu_back
};
static const menuitem_t menu_storage[] = {
static const menuitem_t menu_storage[] =
{
#ifdef __TRACE_MENU__
{ MT_ADV_CALLBACK,0, "TRACE %d", menu_storage_acb},
{ MT_ADV_CALLBACK,1, "%s", menu_storage_acb},
{ MT_ADV_CALLBACK,1, "DISPLAY", menu_storage_acb},
{ MT_ADV_CALLBACK,2, "COPY\nFROM", menu_storage_acb},
{ MT_ADV_CALLBACK,3, "SUBTRACT", menu_storage_acb},
{ MT_ADV_CALLBACK,4, "NORMALIZE", menu_storage_acb},
{ MT_ADV_CALLBACK,5, "WRITE\n"S_RARROW"SD",menu_storage_acb},
#else
{ MT_ADV_CALLBACK,0, "STORE\nTRACE", menu_storage_acb},
{ MT_ADV_CALLBACK,1, "CLEAR\nSTORED", menu_storage_acb},
{ MT_ADV_CALLBACK,2, "SUBTRACT\nSTORED",menu_storage_acb},
@ -2813,12 +2932,64 @@ static const menuitem_t menu_storage[] = {
#ifdef TINYSA4
{ MT_ADV_CALLBACK,4, "ACTUAL\n"S_RARROW"SD", menu_storage_acb},
{ MT_ADV_CALLBACK,5, "STORED\n"S_RARROW"SD", menu_storage_acb},
#endif
#endif
{ MT_NONE, 0, NULL, menu_back} // next-> menu_back
};
#ifdef __TRACE_MENU__
static const menuitem_t menu_trace[] =
{
{ MT_ADV_CALLBACK,0, "TRACE %d", menu_trace_acb},
{ MT_ADV_CALLBACK,1, "TRACE %d", menu_trace_acb},
{ MT_ADV_CALLBACK,2, "TRACE %d", menu_trace_acb},
#if TRACES_MAX > 3
{ MT_ADV_CALLBACK,3, "TRACE %d", menu_trace_acb},
#endif
{ MT_NONE, 0, NULL, menu_back} // next-> menu_back
};
static const menuitem_t menu_store_trace[] =
{
{ MT_ADV_CALLBACK,0, MT_CUSTOM_LABEL, menu_store_trace_acb},
{ MT_ADV_CALLBACK,1, MT_CUSTOM_LABEL, menu_store_trace_acb},
{ MT_ADV_CALLBACK,2, MT_CUSTOM_LABEL, menu_store_trace_acb},
#if TRACES_MAX > 3
{ MT_ADV_CALLBACK,3, MT_CUSTOM_LABEL, menu_store_trace_acb},
#endif
{ MT_NONE, 0, NULL, menu_back} // next-> menu_back
};
static const menuitem_t menu_subtract_trace[] =
{
{ MT_ADV_CALLBACK,0, MT_CUSTOM_LABEL, menu_subtract_trace_acb},
{ MT_ADV_CALLBACK,1, MT_CUSTOM_LABEL, menu_subtract_trace_acb},
{ MT_ADV_CALLBACK,2, MT_CUSTOM_LABEL, menu_subtract_trace_acb},
{ MT_ADV_CALLBACK,3, MT_CUSTOM_LABEL, menu_subtract_trace_acb},
#if TRACES_MAX > 3
{ MT_ADV_CALLBACK,4, MT_CUSTOM_LABEL, menu_subtract_trace_acb},
#endif
{ MT_NONE, 0, NULL, menu_back} // next-> menu_back
};
static const menuitem_t menu_traces[] =
{
{ MT_ADV_CALLBACK,0, "TRACE %d", menu_traces_acb},
{ MT_ADV_CALLBACK,1, "HIDDEN", menu_traces_acb},
{ MT_ADV_CALLBACK,2, "STORED", menu_traces_acb},
{ MT_ADV_CALLBACK,3, MT_CUSTOM_LABEL, menu_traces_acb},
{ MT_SUBMENU, 0, "CALC", menu_average},
{ MT_SUBMENU, 0, "STORE\n"S_RARROW"TRACE", menu_store_trace},
#ifdef TINYSA4
{ MT_ADV_CALLBACK,6, "WRITE\n"S_RARROW"SD", menu_traces_acb},
#endif
{ MT_NONE, 0, NULL, menu_back} // next-> menu_back
};
#endif
static const menuitem_t menu_display[] = {
{ MT_ADV_CALLBACK,0, "PAUSE\nSWEEP", menu_pause_acb},
#ifndef __TRACE_MENU__
{ MT_SUBMENU, 0, "CALC", menu_average},
{ MT_SUBMENU, 0, "STORAGE", menu_storage},
// { MT_ADV_CALLBACK,0, "STORE\nTRACE", menu_storage_acb},
@ -2830,9 +3001,18 @@ static const menuitem_t menu_display[] = {
#endif
#ifdef __LIMITS__
{ MT_SUBMENU, 0, "LIMITS", menu_limit_select},
#endif
#endif
{ MT_ADV_CALLBACK,4, "WATER\nFALL", menu_waterfall_acb},
{ MT_SUBMENU, 0, "SWEEP\nSETTINGS", menu_sweep_speed},
{ MT_KEYPAD, KM_SWEEP_TIME, "SWEEP\nTIME", "0..600s, 0=disable"}, // This must be item 3 to match highlighting
{ MT_SUBMENU, 0, "SWEEP\nPOINTS", menu_sweep_points},
#ifdef TINYSA4
{ MT_KEYPAD, KM_FAST_SPEEDUP,"FAST\nSPEEDUP", "2..20, 0=disable"},
#else
{ MT_KEYPAD | MT_LOW,KM_FAST_SPEEDUP,"FAST\nSPEEDUP", "2..20, 0=disable"},
#endif
//#ifdef __REMOTE_DESKTOP__
// { MT_ADV_CALLBACK,0, "SEND\nDISPLAY", menu_send_display_acb},
//#endif
@ -2911,6 +3091,9 @@ static const menuitem_t menu_top[] = {
{ MT_SUBMENU, 0, "PRESET", menu_load_preset},
{ MT_SUBMENU, 0, "FREQUENCY", menu_stimulus},
{ MT_SUBMENU, 0, "LEVEL", menu_level},
#ifdef __TRACE_MENU__
{ MT_SUBMENU, 0, "TRACE", menu_traces},
#endif
{ MT_SUBMENU, 0, "DISPLAY", menu_display},
{ MT_SUBMENU, 0, "MARKER", menu_marker},
{ MT_SUBMENU, 0, "MEASURE", menu_measure},
@ -3476,9 +3659,9 @@ redraw_cal_status:
// }
// Calc
if (setting.average>0) {
if (setting.average[0]>0) {
ili9341_set_foreground(LCD_BRIGHT_COLOR_GREEN);
lcd_printf(x, y, "Calc:\n%s", averageText[setting.average]);
lcd_printf(x, y, "Calc:\n%s", averageText[setting.average[0]]);
y = add_quick_menu(y+= YSTEP, (menuitem_t *)menu_average);
}
// Spur
@ -3495,7 +3678,7 @@ redraw_cal_status:
}
#endif
if (setting.subtract_stored) {
if (setting.subtract[0]) {
ili9341_set_foreground(LCD_BRIGHT_COLOR_GREEN);
ili9341_drawstring("Norm.", x, y);
y = add_quick_menu(y, (menuitem_t *)menu_storage);

Loading…
Cancel
Save

Powered by TurnKey Linux.