diff options
Diffstat (limited to 'Layout/Layout.cpp')
-rw-r--r-- | Layout/Layout.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/Layout/Layout.cpp b/Layout/Layout.cpp index b2ca942..a38cc4f 100644 --- a/Layout/Layout.cpp +++ b/Layout/Layout.cpp @@ -35,15 +35,21 @@ void Layout::endUpdate() { _lcd->endUpdate(); } -bool Layout::writeField(uint8_t col, uint8_t row, std::string field, bool apply) { - return writeField(col, row, field.c_str(), field.size(), apply); +bool Layout::writeLabel(const Label& label) { + return writeText(label._col, label._row, label._value.c_str(), label._value.size()); } -bool Layout::writeField(uint8_t col, uint8_t row, const char* field, size_t size, bool apply) { +bool Layout::writeField(const Field& field, const std::string& value, bool apply) { + bool ret; + std::string v = value; + if (apply) startUpdate(); - _lcd->writeText(col*6, row, font_6x8, field, size); + while (v.size() < field._maxSize) + v += " "; + + ret = writeText(field._col, field._row, v.c_str(), field._maxSize); if (apply) endUpdate(); @@ -51,15 +57,29 @@ bool Layout::writeField(uint8_t col, uint8_t row, const char* field, size_t size return true; } -bool Layout::writeImage(uint8_t col, uint8_t row, const uint8_t* bmp, bool apply) { +bool Layout::writeImage(const Image& image, bool apply) { + bool ret; + if (apply) startUpdate(); - _lcd->writeBitmap(col, row, bmp); + ret = writeBmp(image._row, image._col, image._bmp); if (apply) endUpdate(); + return ret; +} + +bool Layout::writeText(uint8_t col, uint8_t row, const char* value, size_t size) { + _lcd->writeText(col*6, row, font_6x8, value, size); + + return true; +} + +bool Layout::writeBmp(uint8_t col, uint8_t row, const uint8_t* bmp) { + _lcd->writeBitmap(col*6, row, bmp); + return true; } |