diff --git a/include/LCDDisplay.hpp b/include/LCDDisplay.hpp index 2f3a45c..b93973f 100644 --- a/include/LCDDisplay.hpp +++ b/include/LCDDisplay.hpp @@ -9,7 +9,7 @@ class LCDDisplay { private: uint8_t _lcd; - char writebuf[168]; // 4x40 chars + 2x4 setcursor commands + char writebuf[4 * 40 + 8]; // 4x40 chars + 2x4 setcursor commands void writeStr(std::string str); // do not use void writeLines(std::array lines); // do not use diff --git a/src/LCDDisplay.cpp b/src/LCDDisplay.cpp index 6f89200..537d76e 100644 --- a/src/LCDDisplay.cpp +++ b/src/LCDDisplay.cpp @@ -106,12 +106,12 @@ void LCDDisplay::clearBuf() { /* hyper optimized buffer flush command, writes whole disp with a single write */ void LCDDisplay::flushBuf() { // we could skip all of this and set it in constructor if we were extra sure the lines wont ever exceed 40 chars - uint8_t setDisp[] = {254, 71, 1, 1}; // set cursor to char 1, line 1 + constexpr uint8_t setDisp[] = {254, 71, 1, 1}; // set cursor to char 1, line 1 std::memcpy(&writebuf[0], setDisp, 4); std::memcpy(&writebuf[84], setDisp, 4); writebuf[87] = 3; // overwrite set cursor c1 l1 to c1 l3 - write(_lcd, writebuf, 168); + write(_lcd, writebuf, sizeof(writebuf)); } char LCDDisplay::bar(uint8_t char_id, double value) {