From 5f12c3afbbd905890f433926c1693bf5584d07fb Mon Sep 17 00:00:00 2001 From: DiSlord Date: Sat, 4 Jul 2020 16:22:52 +0300 Subject: [PATCH 1/3] init PE4302 attenuation cache as impossible value --- si4432.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/si4432.c b/si4432.c index c23399a..e121f34 100644 --- a/si4432.c +++ b/si4432.c @@ -125,7 +125,7 @@ static void shiftOutBuf(uint8_t *buf, uint16_t size) { } #endif -const uint16_t SI_nSEL[MAX_SI4432] = { GPIO_RX_SEL, GPIO_LO_SEL, 0}; // #3 is dummy!!!!!! +const uint16_t SI_nSEL[MAX_SI4432+1] = { GPIO_RX_SEL, GPIO_LO_SEL, 0}; // #3 is dummy!!!!!! volatile int SI4432_Sel = 0; // currently selected SI4432 // volatile int SI4432_guard = 0; @@ -659,11 +659,11 @@ void PE4302_shiftOut(uint8_t val) } #endif -static unsigned char old_attenuation = 0; +static unsigned char old_attenuation = 255; bool PE4302_Write_Byte(unsigned char DATA ) { -// if (old_attenuation == DATA) -// return false; + if (old_attenuation == DATA) + return false; // chThdSleepMicroseconds(PE4302_DELAY); SPI2_CLK_LOW; // chThdSleepMicroseconds(PE4302_DELAY); From 27f85e84058ad48f96c74bfc333517b20a3c85f0 Mon Sep 17 00:00:00 2001 From: DiSlord Date: Sat, 4 Jul 2020 18:44:13 +0300 Subject: [PATCH 2/3] Implement show grid values at right of screen --- chprintf.c | 2 +- nanovna.h | 2 ++ plot.c | 65 ++++++++++++++++++++++-------------------------------- 3 files changed, 29 insertions(+), 40 deletions(-) diff --git a/chprintf.c b/chprintf.c index 14df9f2..5b3d24e 100644 --- a/chprintf.c +++ b/chprintf.c @@ -34,7 +34,7 @@ // Enable [flags], support: // ' ' Prepends a space for positive signed-numeric types. positive = ' ', negative = '-'. This flag is ignored if the + flag exists. -//#define CHPRINTF_USE_SPACE_FLAG +#define CHPRINTF_USE_SPACE_FLAG // Force putting trailing zeros on float value #define CHPRINTF_FORCE_TRAILING_ZEROS diff --git a/nanovna.h b/nanovna.h index 434cce7..31b6fb0 100644 --- a/nanovna.h +++ b/nanovna.h @@ -304,6 +304,8 @@ extern uint16_t _grid_y; #define AREA_WIDTH_NORMAL (CELLOFFSETX + WIDTH + 1) #define AREA_HEIGHT_NORMAL ( HEIGHT + 1) +#define GRID_X_TEXT (AREA_WIDTH_NORMAL - 25) + // Smith/polar chart #define P_CENTER_X (CELLOFFSETX + WIDTH/2) #define P_CENTER_Y (HEIGHT/2) diff --git a/plot.c b/plot.c index 241f3e1..ec40127 100644 --- a/plot.c +++ b/plot.c @@ -34,10 +34,10 @@ int waterfall = false; int fullscreen = true; #endif static void cell_draw_marker_info(int x0, int y0); +static void cell_grid_line_info(int x0, int y0); static void draw_battery_status(void); static void update_waterfall(void); void cell_draw_test_info(int x0, int y0); -void frequency_string(char *buf, size_t len, int32_t freq); static int16_t grid_offset; static int16_t grid_width; @@ -908,7 +908,6 @@ static void trace_get_value_string( plot_printf(&buf2[1], sizeof(buf2) -1, "%.8qHz" , dfreq); } #endif - // frequency_string(&buf2[1], sizeof(buf2) -1, dfreq); v = value(coeff[i]); if (mtype & M_NOISE) v = v - 10*log10(actual_rbw_x10*100.0); @@ -1503,6 +1502,12 @@ draw_cell(int m, int n) cell_buffer[tp * CELLWIDTH + x] = DEFAULT_TRIGGER_COLOR; } +#if 1 + // Only right cells + if (m >= (GRID_X_TEXT)/CELLWIDTH) + cell_grid_line_info(x0, y0); +#endif + // Draw traces (50-600 system ticks for all screen calls, depend from lines // count and size) #if 1 @@ -1939,6 +1944,25 @@ cell_draw_marker_info(int x0, int y0) extern float temppeakLevel; +static void cell_grid_line_info(int x0, int y0) +{ + char buf[32]; + int xpos = GRID_X_TEXT - x0; + int ypos = 0 - y0 + 2; + ili9341_set_foreground(DEFAULT_GRID_COLOR); + float ref = get_trace_refpos(TRACE_ACTUAL); + float scale = get_trace_scale(TRACE_ACTUAL);; + for (int i = 0; i < NGRIDY; i++){ + if (ypos >= CELLHEIGHT) break; + if (ypos >= -FONT_GET_HEIGHT){ + plot_printf(buf, sizeof buf, "% .2F", ref); + cell_drawstring(buf, xpos, ypos); + } + ypos+=GRIDY; + ref+=scale; + } +} + static void cell_draw_marker_info(int x0, int y0) { char buf[32]; @@ -2050,43 +2074,6 @@ static void cell_draw_marker_info(int x0, int y0) } } } -void frequency_string(char *buf, size_t len, int32_t freq) -{ - if (freq < 0) { - freq = -freq; - *buf++ = '-'; - len -= 1; - } -#ifdef __VNA__ - if (freq < 1000) { - plot_printf(buf, len, "%d Hz", (int)freq); - } else if (freq < 1000000) { - plot_printf(buf, len, "%d.%03d kHz", - (int)(freq / 1000), - (int)(freq % 1000)); - } else { - plot_printf(buf, len, "%d.%03d %03d MHz", - (int)(freq / 1000000), - (int)((freq / 1000) % 1000), - (int)(freq % 1000)); - } -#endif -#ifdef __SA__ -/* - if (freq < 1000) { - plot_printf(buf, len, "%dHz", (int)freq); - } else if (freq < 1000000) { - plot_printf(buf, len, "%d.%03dkHz", - (int)(freq / 1000), - (int)(freq % 1000)); - } else -*/ { - plot_printf(buf, len, "%d.%03", - (int)(freq / 1000000), - (int)((freq / 1000) % 1000)); - } -#endif -} void draw_frequencies(void) From 3abc1ba504031a52e501da64eadad51f0cc68e77 Mon Sep 17 00:00:00 2001 From: DiSlord Date: Sat, 4 Jul 2020 18:55:50 +0300 Subject: [PATCH 3/3] Better right align text in grid --- nanovna.h | 2 +- plot.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nanovna.h b/nanovna.h index 31b6fb0..baaa90b 100644 --- a/nanovna.h +++ b/nanovna.h @@ -304,7 +304,7 @@ extern uint16_t _grid_y; #define AREA_WIDTH_NORMAL (CELLOFFSETX + WIDTH + 1) #define AREA_HEIGHT_NORMAL ( HEIGHT + 1) -#define GRID_X_TEXT (AREA_WIDTH_NORMAL - 25) +#define GRID_X_TEXT (AREA_WIDTH_NORMAL - 6*5) // Smith/polar chart #define P_CENTER_X (CELLOFFSETX + WIDTH/2) diff --git a/plot.c b/plot.c index ec40127..a1bafa2 100644 --- a/plot.c +++ b/plot.c @@ -1955,7 +1955,7 @@ static void cell_grid_line_info(int x0, int y0) for (int i = 0; i < NGRIDY; i++){ if (ypos >= CELLHEIGHT) break; if (ypos >= -FONT_GET_HEIGHT){ - plot_printf(buf, sizeof buf, "% .2F", ref); + plot_printf(buf, sizeof buf, "% 6.2F", ref); cell_drawstring(buf, xpos, ypos); } ypos+=GRIDY;