try to move away from hardcoded values, see if i can make it support different displays
This commit is contained in:
@@ -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<std::string, 4> lines); // do not use
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user