minor fixes

This commit is contained in:
cho45 2019-09-11 08:17:40 +09:00
parent 8f0bfacf3d
commit b17ecfa533
2 changed files with 13 additions and 9 deletions

12
main.c
View file

@ -37,7 +37,6 @@
static void apply_error_term(void);
static void apply_error_term_at(int i);
static void cal_interpolate(int s);
static void transform_domain(void);
void sweep(void);
@ -84,7 +83,6 @@ static THD_FUNCTION(Thread1, arg)
draw_battery_status();
}
transform_domain();
/* calculate trace coordinates */
plot_into_index(measured);
/* plot trace as raster */
@ -119,13 +117,13 @@ transform_domain(void)
// and calculate ifft for time domain
float* tmp = (float*)spi_buffer;
for (int ch = 0; ch < 2; ch++) {
for (int i = 0; i < 128; i++) {
memcpy(tmp, measured[ch], sizeof(measured[0]));
for (int i = 101+1; i < 128; i++) {
tmp[i*2+0] = 0.0;
tmp[i*2+1] = 0.0;
}
memcpy(spi_buffer, measured[ch], sizeof(measured[0]));
fft((float(*)[2])tmp, 128, 1);
memcpy(measured[ch], spi_buffer, sizeof(measured[0]));
memcpy(measured[ch], tmp, sizeof(measured[0]));
for (int i = 0; i < 101; i++) {
measured[ch][i][0] /= 128.0;
measured[ch][i][1] /= 128.0;
@ -633,11 +631,13 @@ void sweep(void)
redraw_requested = FALSE;
ui_process();
if (redraw_requested)
return; // return to redraw screen asap.
break; // return to redraw screen asap.
if (frequency_updated)
goto rewind;
}
transform_domain();
}
static void

10
plot.c
View file

@ -701,6 +701,12 @@ trace_get_info(int t, char *buf, int len)
}
}
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]) * 128.0 * 2.0);
return distance * (velocity_factor / 100.0);
}
static inline void
mark_map(int x, int y)
{
@ -1371,9 +1377,7 @@ cell_draw_marker_info(int m, int n, int w, int h)
frequency_string(buf, sizeof buf, frequencies[idx]);
cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff);
} else {
#define SPEED_OF_LIGHT 299792458
float distance = ((float)idx * (float)SPEED_OF_LIGHT) / ( (float)(frequencies[1] - frequencies[0]) * 128.0 * 2.0);
chsnprintf(buf, sizeof buf, "%.1f m (%d%%)", distance * (velocity_factor / 100.0), velocity_factor);
chsnprintf(buf, sizeof buf, "%.1f m (VF=%d%%)", distance_of_index(idx), velocity_factor);
cell_drawstring_5x7(w, h, buf, xpos, ypos, 0xffff);
}