From 01057921f6710be17416498f81663082542ce9cf Mon Sep 17 00:00:00 2001 From: TT Date: Fri, 14 Oct 2016 03:56:08 +0900 Subject: [PATCH] adjust memory allocation for keep caldata --- halconf.h | 4 ++-- ili9431.c | 8 ++++---- main.c | 43 +++++++++++++++++++++++++++++++++++++++---- nanovna.h | 2 +- 4 files changed, 46 insertions(+), 11 deletions(-) diff --git a/halconf.h b/halconf.h index ba412ad..2f19627 100644 --- a/halconf.h +++ b/halconf.h @@ -313,7 +313,7 @@ * buffers. */ #if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__) -#define SERIAL_USB_BUFFERS_SIZE 256 +#define SERIAL_USB_BUFFERS_SIZE 128 #endif /** @@ -321,7 +321,7 @@ * @note The default is 2 buffers. */ #if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__) -#define SERIAL_USB_BUFFERS_NUMBER 2 +#define SERIAL_USB_BUFFERS_NUMBER 1 #endif /*===========================================================================*/ diff --git a/ili9431.c b/ili9431.c index b6b46d5..becf696 100644 --- a/ili9431.c +++ b/ili9431.c @@ -783,22 +783,22 @@ force_set_markmap(void) memset(markmap[current_mappage], 0xff, sizeof markmap[current_mappage]); } -void plot_into_index(float measured[101][4]) +void plot_into_index(float measured[101][2][2]) { int i, t; for (i = 0; i < 101; i++) { int x = i * (WIDTH-1) / (101-1); for (t = 0; t < TRACES_MAX; t++) { - int n = (t % 2)*2; + int n = t % 2; if (!trace[t].enabled) continue; if (trace[t].polar) { int x1, y1; - cartesian_scale(measured[i][n+1], measured[i][n], &x1, &y1); + cartesian_scale(measured[i][n][1], measured[i][n][0], &x1, &y1); trace_index[t][i] = INDEX(x1, y1, i); //mark_map(x1>>5, y1>>5); } else { - int y1 = logmag(&measured[i][n]) * 29; + int y1 = logmag(measured[i][n]) * 29; trace_index[t][i] = INDEX(x, y1, i); //mark_map(x>>5, y1>>5); } diff --git a/main.c b/main.c index 4c62b3f..6423706 100644 --- a/main.c +++ b/main.c @@ -44,7 +44,7 @@ static MUTEX_DECL(mutex); -static THD_WORKING_AREA(waThread1, 512); +static THD_WORKING_AREA(waThread1, 384); static THD_FUNCTION(Thread1, arg) { (void)arg; @@ -213,9 +213,19 @@ volatile int16_t wait_count = 0; int16_t dump_selection = 0; int16_t dsp_disabled = FALSE; -float measured[101][4]; +float measured[101][2][2]; uint32_t frequencies[101]; +float caldata[101][5][2]; +uint16_t cal_status; + +#define CAL_LOAD 0 +#define CAL_OPEN 1 +#define CAL_SHORT 2 +#define CAL_THRU 3 +#define CAL_ISOLN 4 + + void i2s_end_callback(I2SDriver *i2sp, size_t offset, size_t n) { @@ -364,7 +374,7 @@ void scan_lcd(void) while (wait_count) ; __disable_irq(); - calclate_gamma(&measured[i][2]); + calclate_gamma(&measured[i][1]); __enable_irq(); delay = set_frequency(frequencies[(i+1)%sweep_points]); @@ -445,6 +455,30 @@ static void cmd_sweep(BaseSequentialStream *chp, int argc, char *argv[]) set_sweep(freq_start, freq_stop); } + + + + + +static void cmd_cal(BaseSequentialStream *chp, int argc, char *argv[]) +{ + + if (argc == 0) { + chprintf(chp, "%d\r\n", cal_status); + return; + } + + char *cmd = argv[1]; + int s; + if (strcmp(cmd, "load")) { + cal_status |= CAL_LOAD; + memcpy(caldata[CAL_LOAD], measured[0], sizeof measured[0]); + } + +} + + + static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) { int i; @@ -547,7 +581,7 @@ static void cmd_stat(BaseSequentialStream *chp, int argc, char *argv[]) -#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(2048) +#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(384) static const ShellCommand commands[] = { @@ -568,6 +602,7 @@ static const ShellCommand commands[] = { "plot", cmd_scan_lcd }, { "pause", cmd_pause }, { "resume", cmd_resume }, + { "cal", cmd_cal }, { NULL, NULL } }; diff --git a/nanovna.h b/nanovna.h index 8ceb722..4a670a9 100644 --- a/nanovna.h +++ b/nanovna.h @@ -51,7 +51,7 @@ void sweep_tail(void); void redraw(void); void polar_plot(float measured[101][4]); -void plot_into_index(float measured[101][4]); +void plot_into_index(float measured[101][2][2]); void draw_cell_all(void); extern const uint16_t x5x7_bits [];