From 11ac166f3476116b08eeaffc25d80b163573089b Mon Sep 17 00:00:00 2001 From: Mike Fiore Date: Tue, 17 Nov 2015 13:04:00 -0600 Subject: join works, but only once - added object for running LoRa operations in a thread, lots of misc updates --- Layout/Layout.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'Layout/Layout.cpp') diff --git a/Layout/Layout.cpp b/Layout/Layout.cpp index a38cc4f..7b0c375 100644 --- a/Layout/Layout.cpp +++ b/Layout/Layout.cpp @@ -46,6 +46,7 @@ bool Layout::writeField(const Field& field, const std::string& value, bool apply if (apply) startUpdate(); + // fill the whole length with blank space in case the previous value was longer than this one while (v.size() < field._maxSize) v += " "; @@ -57,6 +58,27 @@ bool Layout::writeField(const Field& field, const std::string& value, bool apply return true; } +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)); + + if (apply) + startUpdate(); + + snprintf(buf, s, "%s", value); + + ret = writeText(field._col, field._row, value, field._maxSize); + + if (apply) + endUpdate(); + + return true; +} + bool Layout::writeImage(const Image& image, bool apply) { bool ret; @@ -71,6 +93,13 @@ bool Layout::writeImage(const Image& image, bool apply) { return ret; } +void Layout::removeField(const Field& field) { + startUpdate(); + std::string s(' ', field._maxSize); + writeText(field._row, field._col, s.c_str(), s.size()); + endUpdate(); +} + bool Layout::writeText(uint8_t col, uint8_t row, const char* value, size_t size) { _lcd->writeText(col*6, row, font_6x8, value, size); -- cgit v1.2.3