From 9a8a1558ee93094acb56c729a583b7af614f15af Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Tue, 16 Jun 2020 09:50:30 +0200 Subject: [PATCH] Various UI improvements --- chprintf.c | 8 +++++--- plot.c | 4 ++-- sa_core.c | 11 ++++++++--- ui.c | 19 +++++++++++++++++-- ui_sa.c | 8 ++++---- 5 files changed, 36 insertions(+), 14 deletions(-) diff --git a/chprintf.c b/chprintf.c index 3e19b26..5c758f4 100644 --- a/chprintf.c +++ b/chprintf.c @@ -182,7 +182,7 @@ static char *ftoa(char *p, float num, uint32_t precision) { return p; } -static char *ftoaS(char *p, float num, uint32_t precision) { +static char *ftoaS(char *p, float num, int precision) { char prefix=0; char *ptr; if (num > 1000.0){ @@ -200,10 +200,12 @@ static char *ftoaS(char *p, float num, uint32_t precision) { // Auto set precision uint32_t l = num; - if (l > 100) + if (l >= 100) precision-=2; - else if (l > 10) + else if (l >= 10) precision-=1; + if (precision<0) + precision=0; p=ftoa(p, num, precision); if (prefix) *p++ = prefix; diff --git a/plot.c b/plot.c index f7fbd99..44d6702 100644 --- a/plot.c +++ b/plot.c @@ -2151,9 +2151,9 @@ draw_frequencies(void) float t = setting.actual_sweep_time; // in mS ; // in mS if (t>=1000) - plot_printf(buf2, sizeof(buf2), "TIME %.2fS",t/1000.0); + plot_printf(buf2, sizeof(buf2), " TIME %.2fS",t/1000.0); else - plot_printf(buf2, sizeof(buf2), "TIME %.2fmS", t); + plot_printf(buf2, sizeof(buf2), " TIME %.2fmS", t); } else if (FREQ_IS_STARTSTOP()) { plot_printf(buf1, sizeof(buf1), " START %qHz", get_sweep_frequency(ST_START)); diff --git a/sa_core.c b/sa_core.c index 5371cbd..81e2957 100644 --- a/sa_core.c +++ b/sa_core.c @@ -193,6 +193,10 @@ void set_sweep_time(float t) if (t > 600000.0) t = 600000.0; setting.sweep_time = t; + float ta = calc_min_sweep_time(); + if (ta < t) + ta = t; + setting.actual_sweep_time = ta; if (FREQ_IS_CW()) update_grid(); // Really only needed in zero span mode redraw_request |= REDRAW_FREQUENCY; @@ -1978,10 +1982,11 @@ void draw_cal_status(void) ili9341_drawstring("RBW:", x, y); y += YSTEP; - plot_printf(buf, BLEN, "%dkHz", (int)actual_rbw); - buf[6]=0; + plot_printf(buf, BLEN, "%.1FkHz", actual_rbw); +// buf[6]=0; ili9341_drawstring(buf, x, y); +#if 0 // VBW if (setting.frequency_step > 0) { ili9341_set_foreground(DEFAULT_FG_COLOR); @@ -1993,7 +1998,7 @@ void draw_cal_status(void) buf[6]=0; ili9341_drawstring(buf, x, y); } - +#endif // Sweep time if (dirty) color = BRIGHT_COLOR_RED; diff --git a/ui.c b/ui.c index 818f63d..8062956 100644 --- a/ui.c +++ b/ui.c @@ -1949,7 +1949,7 @@ step_round(uint32_t v) { // decade step uint32_t x = 1; - for (x = 1; x*10 < v; x*= 10) + for (x = 1; x*10 <= v; x*= 10) ; // 1-2-5 step @@ -1974,6 +1974,21 @@ lever_zoom_span(int status) set_sweep_frequency(ST_SPAN, span); } +static void +lever_zoom_time(int status) +{ + uint32_t time = setting.sweep_time; // in mS + if (time < MINIMUM_SWEEP_TIME) + time = MINIMUM_SWEEP_TIME; + if (status & EVT_UP) { + time = time*10/25; + } else if (status & EVT_DOWN) { + time = time*25/10; + } + time = step_round(time); + set_sweep_time(time); +} + static void lever_move(int status, int mode) { @@ -2022,7 +2037,7 @@ ui_process_normal(void) if (FREQ_IS_STARTSTOP()) lever_move(status, ST_STOP); else - lever_zoom_span(status); + lever_zoom_time(status); break; #ifdef __VNA__ case LM_EDELAY: diff --git a/ui_sa.c b/ui_sa.c index 20e3e5d..e4904fb 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -1169,20 +1169,20 @@ const menuitem_t menu_modulation[] = { const menuitem_t menu_lowoutputmode[] = { { MT_FORM | MT_CALLBACK, 0, "LOW OUTPUT %s", menu_outputmode_cb}, - { MT_FORM | MT_KEYPAD, KM_CENTER, "FREQ: %s", "10kHz..350Mhz"}, + { MT_FORM | MT_KEYPAD, KM_CENTER, "FREQ: %s", "10kHz..350MHz"}, { MT_FORM | MT_KEYPAD, KM_LOWOUTLEVEL, "LEVEL: %s", "-76..-6"}, { MT_FORM | MT_SUBMENU, 0, "MODULATION: %s", menu_modulation}, { MT_FORM | MT_KEYPAD, KM_SPAN, "SPAN: %s", "0..350MHz"}, { MT_FORM | MT_KEYPAD | MT_LOW, KM_LEVELSWEEP,"LEVELSWEEP: %s", "-70..70"}, { MT_FORM | MT_KEYPAD, KM_SWEEP_TIME, "SWEEP TIME: %s", "0..600S"}, - // { MT_FORM | MT_KEYPAD, KM_10MHZ, "10MHZ: %s", NULL}, + // { MT_FORM | MT_KEYPAD, KM_10MHZ, "10MHz: %s", NULL}, { MT_FORM | MT_CANCEL, 0, "MODE", NULL }, { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; const menuitem_t menu_highoutputmode[] = { { MT_FORM | MT_CALLBACK, 0, "HIGH OUTPUT %s", menu_outputmode_cb}, - { MT_FORM | MT_KEYPAD, KM_CENTER, "FREQ: %s", "240MHz..960Mhz"}, + { MT_FORM | MT_KEYPAD, KM_CENTER, "FREQ: %s", "240MHz..960MHz"}, { MT_FORM | MT_SUBMENU, 0, "LEVEL: %s", menu_drive_wide}, { MT_FORM | MT_SUBMENU, 0, "MODULATION: %s", menu_modulation}, { MT_FORM | MT_KEYPAD, KM_SPAN, "SPAN: %s", NULL}, @@ -1382,7 +1382,7 @@ static const menuitem_t menu_settings2[] = #ifdef __ULTRA__ { MT_SUBMENU,0, "HARMONIC", menu_harmonic}, #endif -// { MT_KEYPAD, KM_10MHZ,"\00210MHZ\0ACTUAL", NULL}, +// { MT_KEYPAD, KM_10MHZ,"\00210MHz\0ACTUAL", NULL}, { MT_CANCEL, 0, "\032 BACK", NULL }, { MT_NONE, 0, NULL, NULL } // sentinel };