From bfa392da0254ebc7d22232f40a2efb6d85d4be47 Mon Sep 17 00:00:00 2001 From: DiSlord Date: Sun, 12 Jul 2020 00:33:51 +0300 Subject: [PATCH] Remove trailling zero at %F format Fix some format output --- chprintf.c | 3 +++ sa_core.c | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/chprintf.c b/chprintf.c index 9859eee..6484fa2 100644 --- a/chprintf.c +++ b/chprintf.c @@ -204,6 +204,9 @@ static char *ftoaS(char *p, float num, int precision) { if (precision<0) precision=0; p=ftoa(p, num, precision); + // remove zeros at end + while (p[-1]=='0') p--; + if (p[-1]=='.') p--; if (prefix) *p++ = prefix; return p; diff --git a/sa_core.c b/sa_core.c index 2c27cb8..a3098e6 100644 --- a/sa_core.c +++ b/sa_core.c @@ -2330,7 +2330,7 @@ void draw_cal_status(void) if (rounding) plot_printf(buf, BLEN, "%+4d", (int)yMax); else - plot_printf(buf, BLEN, "%+.3F", (yMax/setting.unit_scale)); + plot_printf(buf, BLEN, "%+4.3F", (yMax/setting.unit_scale)); if (level_is_calibrated()) { if (setting.auto_reflevel) @@ -2464,10 +2464,10 @@ void draw_cal_status(void) ili9341_drawstring(buf, x, y); y += YSTEP; - plot_printf(buf, BLEN, "%.3Fs", (float)setting.sweep_time_us/ONE_SECOND_TIME); + plot_printf(buf, BLEN, "%5.3Fs", (float)setting.sweep_time_us/ONE_SECOND_TIME); ili9341_drawstring(buf, x, y); y += YSTEP; - plot_printf(buf, BLEN, "%.3Fs", (float)setting.actual_sweep_time_us/ONE_SECOND_TIME); + plot_printf(buf, BLEN, "%5.3Fs", (float)setting.actual_sweep_time_us/ONE_SECOND_TIME); ili9341_drawstring(buf, x, y); #if 1 y += YSTEP; @@ -2477,10 +2477,10 @@ void draw_cal_status(void) // if (t < setting.sweep_time_us) // t = setting.sweep_time_us; // setting.actual_sweep_time_us = t; - plot_printf(buf, BLEN, "%.3Fs", (float)t/ONE_SECOND_TIME); + plot_printf(buf, BLEN, "%5.3Fs", (float)t/ONE_SECOND_TIME); ili9341_drawstring(buf, x, y); y += YSTEP; - plot_printf(buf, BLEN, "%.3Fs", (float)setting.additional_step_delay_us/ONE_SECOND_TIME); + plot_printf(buf, BLEN, "%5.3Fs", (float)setting.additional_step_delay_us/ONE_SECOND_TIME); ili9341_drawstring(buf, x, y); #endif @@ -2587,11 +2587,11 @@ void draw_cal_status(void) // ili9341_set_background(DEFAULT_BG_COLOR); // Bottom level - y = area_height - 7 + OFFSETY; + y = area_height - 8 + OFFSETY; if (rounding) plot_printf(buf, BLEN, "%4d", (int)(yMax - setting.scale * NGRIDY)); else - plot_printf(buf, BLEN, "%.3F", ((yMax - setting.scale * NGRIDY)/setting.unit_scale)); + plot_printf(buf, BLEN, "%+4.3F", ((yMax - setting.scale * NGRIDY)/setting.unit_scale)); // buf[5]=0; if (level_is_calibrated()) if (setting.auto_reflevel)