summaryrefslogtreecommitdiff
path: root/Layout/Layout.cpp
diff options
context:
space:
mode:
authorMike Fiore <mfiore@multitech.com>2015-12-11 09:47:25 -0600
committerMike Fiore <mfiore@multitech.com>2015-12-11 09:47:25 -0600
commit2780dbb79e01d916e48452abf7d0e2b1b85dc643 (patch)
treebc9a4d964d8be761e7ded4b47257d538561e12ea /Layout/Layout.cpp
parent8f3d5d0a8e9539ebcc203f5dd7c3661cad101a35 (diff)
downloadmtdot-box-evb-factory-firmware-2780dbb79e01d916e48452abf7d0e2b1b85dc643.tar.gz
mtdot-box-evb-factory-firmware-2780dbb79e01d916e48452abf7d0e2b1b85dc643.tar.bz2
mtdot-box-evb-factory-firmware-2780dbb79e01d916e48452abf7d0e2b1b85dc643.zip
fix bug in layout where a character from last field could be displayed in new field, remove lots of memset calls
Diffstat (limited to 'Layout/Layout.cpp')
-rw-r--r--Layout/Layout.cpp9
1 files changed, 5 insertions, 4 deletions
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();