From 2780dbb79e01d916e48452abf7d0e2b1b85dc643 Mon Sep 17 00:00:00 2001 From: Mike Fiore Date: Fri, 11 Dec 2015 09:47:25 -0600 Subject: fix bug in layout where a character from last field could be displayed in new field, remove lots of memset calls --- Layout/LayoutDemoSampling.cpp | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'Layout/LayoutDemoSampling.cpp') diff --git a/Layout/LayoutDemoSampling.cpp b/Layout/LayoutDemoSampling.cpp index aea80ac..1d1c92b 100644 --- a/Layout/LayoutDemoSampling.cpp +++ b/Layout/LayoutDemoSampling.cpp @@ -54,11 +54,8 @@ void LayoutDemoSampling::updateCountdown(uint32_t seconds) { char buf[32]; size_t size; - memset(buf, 0, sizeof(buf)); - // for some reason, there's a % character that gets displayed in the last column - // add the extra spaces to wipe it out - writeField(_fInfo, "No Free Channel ", true); - size = snprintf(buf, sizeof(buf), "%lu s ", seconds); + writeField(_fInfo, "No Free Channel", true); + size = snprintf(buf, sizeof(buf), "%lu s", seconds); writeField(_fSw2, buf, size, true); } @@ -66,10 +63,6 @@ void LayoutDemoSampling::updateInterval(uint32_t seconds) { char buf[32]; size_t size; - memset(buf, ' ', sizeof(buf)); - writeField(_fInfo, buf, sizeof(buf), true); - - memset(buf, 0, sizeof(buf)); if (seconds < 60) size = snprintf(buf, sizeof(buf), "Interval %lu s", seconds); else if (seconds < 60 * 60) @@ -83,7 +76,6 @@ void LayoutDemoSampling::updateInterval(uint32_t seconds) { void LayoutDemoSampling::updateAccelerationX(int16_t x) { char buf[16]; size_t size; - memset(buf, ' ', sizeof(buf)); size = snprintf(buf, sizeof(buf), "%d", x); writeField(_fAccx, buf, size, true); } @@ -91,7 +83,6 @@ void LayoutDemoSampling::updateAccelerationX(int16_t x) { void LayoutDemoSampling::updateAccelerationY(int16_t y) { char buf[16]; size_t size; - memset(buf, ' ', sizeof(buf)); size = snprintf(buf, sizeof(buf), "%d", y); writeField(_fAccy, buf, size, true); } @@ -99,7 +90,6 @@ void LayoutDemoSampling::updateAccelerationY(int16_t y) { void LayoutDemoSampling::updateAccelerationZ(int16_t z) { char buf[16]; size_t size; - memset(buf, ' ', sizeof(buf)); size = snprintf(buf, sizeof(buf), "%d", z); writeField(_fAccz, buf, size, true); } @@ -107,7 +97,6 @@ void LayoutDemoSampling::updateAccelerationZ(int16_t z) { void LayoutDemoSampling::updatePressure(float pressure) { char buf[16]; size_t size; - memset(buf, ' ', sizeof(buf)); size = snprintf(buf, sizeof(buf), "%3.2f KPa", pressure/1000); writeField(_fPres, buf, size, true); } @@ -115,7 +104,6 @@ void LayoutDemoSampling::updatePressure(float pressure) { void LayoutDemoSampling::updateAltitude(float altitude) { char buf[16]; size_t size; - memset(buf, ' ', sizeof(buf)); size = snprintf(buf, sizeof(buf), "%5.2f m", altitude); writeField(_fAlt, buf, size, true); } @@ -123,7 +111,6 @@ void LayoutDemoSampling::updateAltitude(float altitude) { void LayoutDemoSampling::updateTemperature(float temperature) { char buf[16]; size_t size; - memset(buf, ' ', sizeof(buf)); size = snprintf(buf, sizeof(buf), "%3.2f C", temperature); writeField(_fTemp, buf, size, true); } @@ -131,7 +118,6 @@ void LayoutDemoSampling::updateTemperature(float temperature) { void LayoutDemoSampling::updateLight(float light) { char buf[16]; size_t size; - memset(buf, ' ', sizeof(buf)); size = snprintf(buf, sizeof(buf), "%4.2f lux", light); writeField(_fLight, buf, size, true); } -- cgit v1.2.3