diff options
author | Mike Fiore <mfiore@multitech.com> | 2015-11-13 13:09:31 -0600 |
---|---|---|
committer | Mike Fiore <mfiore@multitech.com> | 2015-11-13 13:09:31 -0600 |
commit | 7016673d4b4a7d7c7f66612aa6a269397bbc9487 (patch) | |
tree | cdec007db0bfbde7c245eefe6b6b733e5ae6d6c4 /Layout | |
parent | 1c3cf27c5676d976d3a4b6b70420119b6541250e (diff) | |
download | mtdot-box-evb-factory-firmware-7016673d4b4a7d7c7f66612aa6a269397bbc9487.tar.gz mtdot-box-evb-factory-firmware-7016673d4b4a7d7c7f66612aa6a269397bbc9487.tar.bz2 mtdot-box-evb-factory-firmware-7016673d4b4a7d7c7f66612aa6a269397bbc9487.zip |
update generic display functions in Layout - update LayoutStartup accordingly
Diffstat (limited to 'Layout')
-rw-r--r-- | Layout/Layout.cpp | 32 | ||||
-rw-r--r-- | Layout/Layout.h | 9 | ||||
-rw-r--r-- | Layout/LayoutStartup.cpp | 12 |
3 files changed, 39 insertions, 14 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; } diff --git a/Layout/Layout.h b/Layout/Layout.h index 5b25458..5e7ece2 100644 --- a/Layout/Layout.h +++ b/Layout/Layout.h @@ -42,11 +42,14 @@ class Layout { void clear(); void startUpdate(); void endUpdate(); - bool writeField(uint8_t col, uint8_t row, std::string field, bool apply = false); - bool writeField(uint8_t col, uint8_t row, const char* field, size_t size, bool apply = false); - bool writeImage(uint8_t col, uint8_t row, const uint8_t* bmp, bool apply = false); + bool writeLabel(const Label& label); + bool writeField(const Field& field, const std::string& value, bool apply = false); + bool writeImage(const Image& image, bool apply = false); private: + bool writeText(uint8_t col, uint8_t row, const char* value, size_t size); + bool writeBmp(uint8_t col, uint8_t row, const uint8_t* bmp); + DOGS102* _lcd; }; diff --git a/Layout/LayoutStartup.cpp b/Layout/LayoutStartup.cpp index ea339d6..850ea50 100644 --- a/Layout/LayoutStartup.cpp +++ b/Layout/LayoutStartup.cpp @@ -14,14 +14,16 @@ LayoutStartup::LayoutStartup(DOGS102* lcd) LayoutStartup::~LayoutStartup() {} void LayoutStartup::display() { + std::string version = MTDOT_BOX_VERSION; + clear(); startUpdate(); - writeImage(_iLogo._col, _iLogo._row, _iLogo._bmp); - writeField(_lName._col, _lName._row, _lName._value); - writeField(_lInfo._col, _lInfo._row, _lInfo._value); - writeField(_lVersion._col, _lVersion._row, _lVersion._value); - writeField(_fVersion._col, _fVersion._row, MTDOT_BOX_VERSION, sizeof(MTDOT_BOX_VERSION)); + writeImage(_iLogo); + writeLabel(_lName); + writeLabel(_lInfo); + writeLabel(_lVersion); + writeField(_fVersion, version); endUpdate(); } |