From 67851716ba09442a972869adcb337a0ee7873f7f Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Sat, 6 Jun 2020 09:01:05 +0200 Subject: [PATCH] Status panel to 30 pixels --- nanovna.h | 6 +++--- plot.c | 7 ++++--- sa_core.c | 40 ++++++++++++++++++++-------------------- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/nanovna.h b/nanovna.h index 706cdf4..1b923ee 100644 --- a/nanovna.h +++ b/nanovna.h @@ -259,9 +259,9 @@ extern void tlv320aic3204_select(int channel); */ // Offset of plot area -#define OFFSETX 25 +#define OFFSETX 30 #define OFFSETY 0 -#define BUTTON_WIDTH 66 +#define BUTTON_WIDTH 60 #ifdef __SCROLL__ #define HEIGHT _height extern int _height; @@ -290,7 +290,7 @@ extern int _height; // #define CELLOFFSETX 0 -#define AREA_WIDTH_NORMAL (CELLOFFSETX + WIDTH + 1 + 4) +#define AREA_WIDTH_NORMAL (CELLOFFSETX + WIDTH) #define AREA_HEIGHT_NORMAL ( HEIGHT + 1) // Smith/polar chart diff --git a/plot.c b/plot.c index 8c2cbbc..b9198b5 100644 --- a/plot.c +++ b/plot.c @@ -621,7 +621,7 @@ trace_into_index(int t, int i, float array[POINTS_COUNT]) int y, x; float coeff = array[i]; float refpos = get_trace_refpos(t); - float v; + float v=0; float scale = get_trace_scale(t); switch (trace[t].type) { @@ -859,9 +859,10 @@ static void trace_get_value_string( } else { dfreq = frequencies[i]; } - if (get_actual_RBW() < 10) + uint32_t resolution = get_sweep_frequency(ST_SPAN)/290; + if (resolution <= 2000) plot_printf(&buf2[1], sizeof(buf2) -1, "%3.3f" , (dfreq + 500) / 1000000.0); - else if (get_actual_RBW() < 100) + else if (resolution <= 20000) plot_printf(&buf2[1], sizeof(buf2) -1, "%3.2f" , (dfreq + 5000) / 1000000.0); else plot_printf(&buf2[1], sizeof(buf2) -1, "%3.1f" , (dfreq + 50000) / 1000000.0); diff --git a/sa_core.c b/sa_core.c index dd6e3d1..e33cf56 100644 --- a/sa_core.c +++ b/sa_core.c @@ -1746,10 +1746,10 @@ void draw_cal_status(void) float yMax = setting.reflevel; if (rounding) - plot_printf(buf, BLEN, "%5d", (int)yMax); + plot_printf(buf, BLEN, "%6d", (int)yMax); else - plot_printf(buf, BLEN, "%5f", yMax); - buf[5]=0; + plot_printf(buf, BLEN, "%6f", yMax); + buf[6]=0; if (level_is_calibrated()) { if (setting.auto_reflevel) color = DEFAULT_FG_COLOR; @@ -1781,9 +1781,9 @@ void draw_cal_status(void) } #if 0 if (rounding) - plot_printf(buf, BLEN, "%4d/",(int)setting.scale); + plot_printf(buf, BLEN, "%5d/",(int)setting.scale); else - plot_printf(buf, BLEN, "%4f/",setting.scale); + plot_printf(buf, BLEN, "%5f/",setting.scale); #endif ili9341_drawstring(buf, x, y); @@ -1797,7 +1797,7 @@ void draw_cal_status(void) y += YSTEP; plot_printf(buf, BLEN, "%ddB", setting.attenuate); - buf[5]=0; + buf[6]=0; ili9341_drawstring(buf, x, y); if (setting.average>0) { @@ -1807,7 +1807,7 @@ void draw_cal_status(void) y += YSTEP; plot_printf(buf, BLEN, "%s",averageText[setting.average]); - buf[5]=0; + buf[6]=0; ili9341_drawstring(buf, x, y); } #ifdef __SPUR__ @@ -1833,7 +1833,7 @@ void draw_cal_status(void) y += YSTEP; plot_printf(buf, BLEN, "%dkHz", (int)actual_rbw); - buf[5]=0; + buf[6]=0; ili9341_drawstring(buf, x, y); if (setting.frequency_step > 0) { @@ -1843,7 +1843,7 @@ void draw_cal_status(void) y += YSTEP; plot_printf(buf, BLEN, "%dkHz",(int)setting.vbw); - buf[5]=0; + buf[6]=0; ili9341_drawstring(buf, x, y); } if (dirty) @@ -1865,13 +1865,13 @@ void draw_cal_status(void) #endif ; // in mS if (t>=10000.0) - plot_printf(buf, BLEN, "%dS",(int)t); + plot_printf(buf, BLEN, "%5dS",(int)t); else if (t>=1000) - plot_printf(buf, BLEN, "%.0fS",t); + plot_printf(buf, BLEN, "%5fS",t); else plot_printf(buf, BLEN, "%dmS",(int)t); - buf[5]=0; + buf[6]=0; ili9341_drawstring(buf, x, y); @@ -1882,7 +1882,7 @@ void draw_cal_status(void) y += YSTEP; plot_printf(buf, BLEN, "%dMHz",reffer_freq[setting.refer]/1000000); - buf[5]=0; + buf[6]=0; ili9341_drawstring(buf, x, y); } @@ -1893,7 +1893,7 @@ void draw_cal_status(void) y += YSTEP; plot_printf(buf, BLEN, "%.1fdB",setting.offset); - buf[5]=0; + buf[6]=0; ili9341_drawstring(buf, x, y); } @@ -1908,10 +1908,10 @@ void draw_cal_status(void) y += YSTEP; if (rounding) - plot_printf(buf, BLEN, "%d", (int)value(setting.trigger_level)); + plot_printf(buf, BLEN, "%6d", (int)value(setting.trigger_level)); else - plot_printf(buf, BLEN, "%.2f", value(setting.trigger_level)); - buf[5]=0; + plot_printf(buf, BLEN, "%6f", value(setting.trigger_level)); + buf[6]=0; ili9341_drawstring(buf, x, y); } @@ -1929,10 +1929,10 @@ void draw_cal_status(void) y = HEIGHT-7 + OFFSETY; if (rounding) - plot_printf(buf, BLEN, "%5d", (int)(yMax - setting.scale * NGRIDY)); + plot_printf(buf, BLEN, "%6d", (int)(yMax - setting.scale * NGRIDY)); else - plot_printf(buf, BLEN, "%5f", (yMax - setting.scale * NGRIDY)); - buf[5]=0; + plot_printf(buf, BLEN, "%6f", (yMax - setting.scale * NGRIDY)); + buf[6]=0; if (level_is_calibrated()) if (setting.auto_reflevel) color = DEFAULT_FG_COLOR;