Add linear averaging switch

multi_trace
erikkaashoek 5 years ago
parent fd35921ef2
commit 5878d5e01d

@ -1072,6 +1072,7 @@ extern const float unit_scale_value[];
extern const char unit_scale_text[]; extern const char unit_scale_text[];
#ifdef TINYSA4 #ifdef TINYSA4
extern int debug_frequencies; extern int debug_frequencies;
extern int linear_averaging;
#endif #endif
#if 1 // Still sufficient flash #if 1 // Still sufficient flash
// Flash save area - flash7 : org = 0x0801B000, len = 20k in *.ld file // Flash save area - flash7 : org = 0x0801B000, len = 20k in *.ld file

@ -310,7 +310,11 @@ marker_to_value(const int i)
float v = value(ref_marker_levels[markers[i].index]); float v = value(ref_marker_levels[markers[i].index]);
if (markers[i].mtype & M_AVER) { if (markers[i].mtype & M_AVER) {
int old_unit = setting.unit; int old_unit = setting.unit;
if (markers[i].mtype & M_NOISE) if (markers[i].mtype & M_NOISE
#ifdef TINYSA4
&& linear_averaging
#endif
)
setting.unit = U_WATT; // Noise averaging should always be done in Watts setting.unit = U_WATT; // Noise averaging should always be done in Watts
v = 0; v = 0;
for (int i=0; i<sweep_points; i++) for (int i=0; i<sweep_points; i++)

@ -72,6 +72,7 @@ uint32_t old_CFGR;
uint32_t orig_CFGR; uint32_t orig_CFGR;
int debug_frequencies = false; int debug_frequencies = false;
int linear_averaging = true;
static freq_t old_freq[5] = { 0, 0, 0, 0,0}; static freq_t old_freq[5] = { 0, 0, 0, 0,0};
static freq_t real_old_freq[5] = { 0, 0, 0, 0,0}; static freq_t real_old_freq[5] = { 0, 0, 0, 0,0};
@ -4069,12 +4070,15 @@ static volatile int dummy;
case AV_16: actual_t[i] = (actual_t[i]*15.0 + RSSI) / 16.0; break; case AV_16: actual_t[i] = (actual_t[i]*15.0 + RSSI) / 16.0; break;
case AV_100: case AV_100:
#ifdef TINYSA4 #ifdef TINYSA4
if (linear_averaging)
{ {
int old_unit = setting.unit; int old_unit = setting.unit;
setting.unit = U_WATT; // Power averaging should always be done in Watts 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 ); actual_t[i] = to_dBm((value(actual_t[i])*(scan_after_dirty-1) + value(RSSI)) / scan_after_dirty );
setting.unit = old_unit; setting.unit = old_unit;
} }
else
actual_t[i] = (actual_t[i]*(scan_after_dirty-1) + RSSI)/ scan_after_dirty;
#else #else
actual_t[i] = (actual_t[i]*(scan_after_dirty-1) + RSSI)/ scan_after_dirty; actual_t[i] = (actual_t[i]*(scan_after_dirty-1) + RSSI)/ scan_after_dirty;
#endif #endif
@ -5863,6 +5867,23 @@ abort:
test_validate(TEST_LEVEL); // Validate test test_validate(TEST_LEVEL); // Validate test
shell_printf("Temp = %4.1f, level = %6.2f, delta = %6.2f\n\r",Si446x_get_temp() , peakLevel, (first_level - peakLevel)*10.0 ); shell_printf("Temp = %4.1f, level = %6.2f, delta = %6.2f\n\r",Si446x_get_temp() , peakLevel, (first_level - peakLevel)*10.0 );
} }
} else if (test == 10) {
// reset_settings(M_LOW);
set_refer_output(-1);
if (setting.test_argument > 0)
set_R(setting.test_argument);
set_attenuation(0);
int test_case = TEST_POWER;
for (int i=1; i<30; i++) {
set_sweep_points(51);
set_sweep_frequency(ST_CENTER, 30000000 * i);
set_sweep_frequency(ST_SPAN, 3000);
test_acquire(test_case); // Acquire test
test_validate(test_case);
shell_printf("Freq = %8.3fMHz, level = %6.2f\n\r", ((float)peakFreq) / 1000000.0, peakLevel);
}
set_sweep_points(450);
reset_settings(M_LOW);
#endif #endif
} }

@ -1157,6 +1157,22 @@ static UI_FUNCTION_ADV_CALLBACK(menu_debug_freq_acb)
// menu_move_back(); // menu_move_back();
ui_mode_normal(); ui_mode_normal();
} }
static UI_FUNCTION_ADV_CALLBACK(menu_linear_averaging_acb)
{
(void)data;
(void)item;
if (b){
b->icon = linear_averaging == 0 ? BUTTON_ICON_NOCHECK : BUTTON_ICON_CHECK;
return;
}
linear_averaging = ! linear_averaging;
// menu_move_back();
ui_mode_normal();
}
#endif #endif
static UI_FUNCTION_CALLBACK(menu_clearconfig_cb) static UI_FUNCTION_CALLBACK(menu_clearconfig_cb)
@ -2556,6 +2572,7 @@ static const menuitem_t menu_settings4[] =
#ifdef __HARMONIC__ #ifdef __HARMONIC__
{ MT_SUBMENU,0, "HARMONIC", menu_harmonic}, { MT_SUBMENU,0, "HARMONIC", menu_harmonic},
#endif #endif
{ MT_ADV_CALLBACK, 0, "LINEAR\nAVERAGING", menu_linear_averaging_acb},
// { MT_SUBMENU, 0, S_RARROW" MORE", menu_settings3}, // { MT_SUBMENU, 0, S_RARROW" MORE", menu_settings3},
{ MT_NONE, 0, NULL, menu_back} // next-> menu_back { MT_NONE, 0, NULL, menu_back} // next-> menu_back
}; };

Loading…
Cancel
Save

Powered by TurnKey Linux.