refactor a little, add function for clearing buffer

This commit is contained in:
Drath
2025-09-12 23:36:35 +02:00
parent cc038ec0a2
commit b1ea1f2c99
2 changed files with 8 additions and 3 deletions

View File

@@ -29,7 +29,7 @@ LCDDisplay::LCDDisplay(std::string dev, uint32_t baud) {
tcflush(lcd, TCIFLUSH);
tcsetattr(lcd, TCSANOW, &term);
_lcd = lcd;
std::memset(linebuf, ' ', sizeof(linebuf)); // init linebuf to spaces
clearBuf(); // init linebuf to spaces
}
LCDDisplay::~LCDDisplay() {
@@ -84,8 +84,12 @@ void LCDDisplay::writeBuf(uint8_t row, uint8_t col, std::string str) {
std::memcpy(&linebuf[row][col], str.c_str(), len); // will overflow
}
void LCDDisplay::clearBuf() {
std::memset(linebuf, ' ', sizeof(linebuf));
}
/* hyper optimized buffer flush command, writes whole disp with a single write */
void LCDDisplay::flushBuffer() {
void LCDDisplay::flushBuf() {
char writebuf[168]; // 4x40 chars + 2x4 setcursor commands
uint8_t setDisp[] = {254, 71, 1}; // skeleton set cursor command