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/Layout.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'Layout/Layout.cpp') diff --git a/Layout/Layout.cpp b/Layout/Layout.cpp index 7b0c375..e9f6aee 100644 --- a/Layout/Layout.cpp +++ b/Layout/Layout.cpp @@ -61,17 +61,18 @@ bool Layout::writeField(const Field& field, const std::string& value, bool apply bool Layout::writeField(const Field& field, const char* value, size_t size, bool apply) { bool ret; char buf[32]; - size_t s = (field._maxSize > size) ? size : field._maxSize; // fill the whole length with blank space in case the previous value was longer than this one - memset(buf, 0x20, sizeof(buf)); + memset(buf, ' ', sizeof(buf)); if (apply) startUpdate(); - snprintf(buf, s, "%s", value); + snprintf(buf, sizeof(buf), "%s", value); + // wipe out the null character - the LCD driver will just skip that character otherwise + buf[size] = ' '; - ret = writeText(field._col, field._row, value, field._maxSize); + ret = writeText(field._col, field._row, buf, field._maxSize); if (apply) endUpdate(); -- cgit v1.2.3