pull/151/merge
Louis Somers 4 weeks ago committed by GitHub
commit 5a4a48418d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -334,8 +334,8 @@ marker_to_value(const int i)
#endif
)
setting.unit = U_WATT; // Noise averaging should always be done in Watts
v = 0;
for (int i=0; i<sweep_points; i++)
v = value(ref_marker_levels[0])
for (int i=sweep_points-1; i != 0; i--)
v += value(ref_marker_levels[i]); // TODO this should be power averaging for noise markers
v /= sweep_points;
v = to_dBm(v);
@ -1152,7 +1152,9 @@ draw_cell(int m, int n)
c = GET_PALTETTE_COLOR(LCD_TRIGGER_COLOR);
for (x = 0; x < w; x++)
if (x+x0 == WIDTH/3 || x+x0 == 2*WIDTH/3 ) {
for (y = 0; y < h; y++) cell_buffer[y * CELLWIDTH + x] = c;
for (y = h-1; y != 0; y--)
cell_buffer[y * CELLWIDTH + x] = c;
cell_buffer[CELLWIDTH + x] = c;
}
}
#endif
@ -2060,17 +2062,20 @@ int display_test_pattern(pixel_t p)
// write and read display, return false on fail.
for (int h = 0; h < LCD_HEIGHT; h++) {
// write test pattern to LCD
for (int w = 0; w < LCD_WIDTH; w++)
for (int w = LCD_WIDTH-1; w != 0; w--)
spi_buffer[w] = p;
spi_buffer[0] = p;
ili9341_bulk(0, h, LCD_WIDTH, 1);
// Cleanup buffer
memset(spi_buffer, 0, LCD_WIDTH * sizeof(pixel_t));
// try read data
ili9341_read_memory(0, h, LCD_WIDTH, 1, spi_buffer);
// Check pattern from data for (volatile int w = 0; w < LCD_WIDTH; w++)
for (int w = 0; w < LCD_WIDTH; w++)
for (int w = LCD_WIDTH-1; w != 0; w--)
if (spi_buffer[w] != p)
return false;
if (spi_buffer[0] != p)
return false;
}
return true;
}

@ -1484,8 +1484,9 @@ void copy_trace(int f, int t)
{
if (f == t)
return;
for (int i=0; i<POINTS_COUNT;i++)
for (int i = POINTS_COUNT-1; i != 0; i--)
measured[t][i] = measured[f][i];
measured[t][0] = measured[f][0];
setting.stored[t] = true;
//dirty = true; // No HW update required, only status panel refresh
}
@ -1529,12 +1530,13 @@ void subtract_trace(int t, int f)
setting.subtract[t] = f+1;
setting.normalize_level = 0.0;
setting.auto_attenuation = false; // Otherwise noise level may move leading to strange measurements
for (int i=0;i<POINTS_COUNT;i++)
for (int i = POINTS_COUNT-1; i != 0; i--)
measured[t][i] -= measured[f][i]; // pre-load AVER
measured[t][0] -= measured[f][0];
} else {
for (int i=0;i<POINTS_COUNT;i++)
for (int i = POINTS_COUNT-1; i != 0; i--)
measured[t][i] += measured[f][i]; // pre-load AVER
measured[t][0] += measured[f][0];
setting.subtract[t] = 0;
}
}
@ -1548,15 +1550,17 @@ void toggle_normalize(int t)
TRACE_DISABLE(1<<TRACE_TEMP);
}
setting.normalized[t] = true;
for (int i=0;i<POINTS_COUNT;i++)
for (int i = POINTS_COUNT - 1; i != 0; i--)
measured[t][i] -= measured[TRACE_TEMP][i]; // pre-load AVER
measured[t][0] -= measured[TRACE_TEMP][0];
setting.auto_attenuation = false; // Otherwise noise level may move leading to strange measurements
setting.normalize_level = 0.0;
} else {
for (int f=0; f<TRACES_MAX-1;f++) {
if (setting.normalized[f] && (setting.normalized_trace == t || f == t)) {
for (int i=0;i<POINTS_COUNT;i++)
for (int i = POINTS_COUNT - 1; i != 0; i--)
measured[f][i] += measured[TRACE_TEMP][i]; // pre-load AVER
measured[f][0] += measured[TRACE_TEMP][0];
setting.normalized[f] = false;
}
}
@ -2247,13 +2251,13 @@ static const int8_t scaled_atten_correction[16][16] =
static void calculate_correction(void)
{
for (int c = 0; c < CORRECTION_SIZE; c++) {
scaled_correction_value[c][0] = config.correction_value[c][0] * (1 << (SCALE_FACTOR));
for (int i = 1; i < CORRECTION_POINTS; i++) {
scaled_correction_value[c][i] = config.correction_value[c][i] * (1 << (SCALE_FACTOR));
int32_t m = scaled_correction_value[c][i] - scaled_correction_value[c][i-1];
// int32_t d = (setting.correction_frequency[i] - setting.correction_frequency[i-1]) >> SCALE_FACTOR;
scaled_correction_multi[c][i] = m; // (int32_t) ( m / d );
}
scaled_correction_value[c][0] = config.correction_value[c][0] * (1 << (SCALE_FACTOR));
for (int i = 1; i < CORRECTION_POINTS; i++) {
scaled_correction_value[c][i] = config.correction_value[c][i] * (1 << (SCALE_FACTOR));
int32_t m = scaled_correction_value[c][i] - scaled_correction_value[c][i-1];
// int32_t d = (setting.correction_frequency[i] - setting.correction_frequency[i-1]) >> SCALE_FACTOR;
scaled_correction_multi[c][i] = m; // (int32_t) ( m / d );
}
}
}
#pragma GCC push_options
@ -3781,8 +3785,9 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) /
}
}
if (i == 0) {
for (int t=0;t<TRACES_MAX;t++)
for (int t = TRACES_MAX-1; t != 0; t--)
setting.scan_after_dirty[t] += 1;
setting.scan_after_dirty[0] += 1;
}
TRACE(0);
// --------------------------------- Pulse at start of low output sweep --------------------------
@ -5314,9 +5319,10 @@ static bool sweep(bool break_on_operation)
imag[i] = 0;
actual_t[i] = -150;
}
for (int i=0;i<sweep_points;i++) {
for (int i=sweep_points-1;i != 0; i--) {
real[i] = temp_t[i] - m;
}
real[0] = temp_t[0] - m;
FFT(real, imag, 256, false);
#if 1
for (int i = 128 - setting.vbw_x100; i<128+setting.vbw_x100; i++) {
@ -5326,11 +5332,13 @@ static bool sweep(bool break_on_operation)
#endif
FFT(real, imag, 256, true);
for (int i=0;i<sweep_points;i++) {
for (int i=sweep_points-1;i != 0; i--) {
float re = real[i];
temp_t[i] = re + m;
// actual_t[i] = sqrtf(re*re + im*im) + m;
}
float re = real[0];
temp_t[0] = re + m;
}
#else
@ -5363,12 +5371,15 @@ static bool sweep(bool break_on_operation)
d_width = (sweep_points * (actual_rbw_x10 * 250) / get_sweep_frequency(ST_SPAN));
d_start = sweep_points/2 - d_width/2;
d_offset = stored_t[d_start];
for (int i=0; i<d_width; i++)
for (int i = d_width-1; i != 0; i--)
if (d_offset > stored_t[d_start + i])
d_offset = stored_t[d_start + i];
if (d_offset > stored_t[d_start])
d_offset = stored_t[d_start];
// d_offset -= 1; // To avoid divide by zero
for (int i=0; i<d_width; i++)
for (int i = d_width - 1; i != 0; i--)
d_scale += stored_t[d_start + i] - d_offset;
d_scale += stored_t[d_start] - d_offset;
// d_scale *= d_wid;
}
#endif
@ -5385,10 +5396,12 @@ static bool sweep(bool break_on_operation)
imag2[i] = 0;
actual_t[i] = -150;
}
for (int i=0;i<sweep_points;i++) {
for (int i = sweep_points-1; i != 0 ; i--) {
if (temp_t[i] > m+25)
real[i] = temp_t[i] - m;
}
if (temp_t[0] > m + 25)
real[0] = temp_t[0] - m;
FFT(real, imag, 256, false);
#if 1
#if 0
@ -6069,8 +6082,8 @@ static volatile int dummy;
trace[TRACE_STORED].enabled = true;
adc_buf_read(ADC_CHSELR_CHSEL4, spi_buffer, 290);
#if 1 // Perform FFT on input
int32_t zero = 0;
for (int i=0;i<256;i++) {
int32_t zero = spi_buffer[0];
for (int i=255;i!=0;i--) {
zero += spi_buffer[i];
}
zero = zero >> 8;
@ -6715,10 +6728,10 @@ float measure_jump(int i) {
(void) i;
redraw_request |= REDRAW_AREA | REDRAW_CAL_STATUS;
draw_all(TRUE);
float left=0,
right = 0;
float left = actual_t[0];
float right = 0;
int h_p = setting._sweep_points/2;
for (int j = 0; j < h_p; j++) {
for (int j = h_p - 1; j != 0; j--) {
left += actual_t[j];
}
left /= h_p;

Loading…
Cancel
Save

Powered by TurnKey Linux.