From 884ca4218f0191f9fe5e7234b1c9b405b1760ebe Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Wed, 2 Oct 2019 11:13:09 +0200 Subject: [PATCH] REmove start and done messages --- main.c | 22 +++++++--------------- plot.c | 10 ++++++++++ 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/main.c b/main.c index fa8e69d..0df574b 100644 --- a/main.c +++ b/main.c @@ -66,7 +66,6 @@ static THD_FUNCTION(Thread1, arg) while (1) { bool completed = false; - if (sweep_enabled || sweep_once) { chMtxLock(&mutex); completed = sweep(true); @@ -75,6 +74,7 @@ static THD_FUNCTION(Thread1, arg) } else { __WFI(); } + chMtxLock(&mutex); ui_process(); @@ -92,6 +92,7 @@ static THD_FUNCTION(Thread1, arg) redraw_request |= REDRAW_CELLS; } } + /* plot trace as raster */ draw_all(completed); // flush markmap only if scan completed to prevent remaining traces chMtxUnlock(&mutex); @@ -178,7 +179,6 @@ transform_domain(void) for (int ch = 0; ch < 2; ch++) { memcpy(tmp, measured[ch], sizeof(measured[0])); - for (int i = 0; i < 101; i++) { float w = kaiser_window(i+offset, window_size, beta); tmp[i*2+0] *= w; @@ -187,7 +187,6 @@ transform_domain(void) for (int i = 101; i < FFT_SIZE; i++) { tmp[i*2+0] = 0.0; tmp[i*2+1] = 0.0; - } if (is_lowpass) { for (int i = 1; i < 101; i++) { @@ -199,7 +198,6 @@ transform_domain(void) fft256_inverse((float(*)[2])tmp); memcpy(measured[ch], tmp, sizeof(measured[0])); for (int i = 0; i < 101; i++) { - measured[ch][i][0] /= (float)FFT_SIZE; if (is_lowpass) { measured[ch][i][1] = 0.0; @@ -654,10 +652,6 @@ bool sweep(bool break_on_operation) float gamma0[2],gamma1[2]; float *rg; - if (sweep_once) - chprintf(saved_chp, "start\r\n"); - - frequency_updated = FALSE; //delay = 3; if (!sweep_once) { count = sweep_points; @@ -691,9 +685,9 @@ bool sweep(bool break_on_operation) /* calculate transmission coeficient */ (*sample_func)(rg); - if (sweep_once) - chprintf(saved_chp, "%d %f %f %f %f\r\n", freq, gamma0[0], gamma0[1], gamma1[0], gamma1[1]); - + if (sweep_once) { + chprintf(saved_chp, "%d %f %f %f %f\r\n", freq, 10.0 * gamma0[0], 10.0 * gamma0[1], 3.0 * gamma1[0],3.0 * gamma1[1]); + } // blink LED while scanning palSetPad(GPIOC, GPIOC_LED); @@ -709,9 +703,7 @@ bool sweep(bool break_on_operation) return false; freq += step; } - if (sweep_once) - chprintf(saved_chp, "done\r\n"); - else + if (!sweep_once) transform_domain(); return true; } @@ -720,7 +712,7 @@ static void cmd_scan(BaseSequentialStream *chp, int argc, char *argv[]) { if (argc != 2 && argc != 3) { - chprintf(chp, "usage: sweep {start(Hz)} {step(Hz)} [points]\r\n"); + chprintf(chp, "usage: scan {start(Hz)} {step(Hz)} [points]\r\n"); return; } diff --git a/plot.c b/plot.c index ad43241..42d01f9 100644 --- a/plot.c +++ b/plot.c @@ -601,6 +601,15 @@ gamma2imp(char *buf, int len, const float coeff[2], uint32_t frequency) float zi = 2*coeff[1] * d; int n; +#if 1 + n = string_value_with_prefix(buf, len, zr, '\0'); + if(zi<0) + buf[n++]='-'; + else + buf[n++]='+'; + buf[n++]='j'; + string_value_with_prefix(buf+n, len-n, fabs(zi), S_OHM[0]); +#else n = string_value_with_prefix(buf, len, zr, S_OHM[0]); buf[n++] = ' '; @@ -611,6 +620,7 @@ gamma2imp(char *buf, int len, const float coeff[2], uint32_t frequency) float l = zi / (PI2 * frequency); string_value_with_prefix(buf+n, len-n, l, 'H'); } +#endif } static void