refactor a little, add function for clearing buffer
This commit is contained in:
@@ -25,7 +25,8 @@ class LCDDisplay {
|
||||
void setBacklight(bool enabled);
|
||||
void setCursor(uint8_t row, uint8_t col);
|
||||
void writeBuf(uint8_t row, uint8_t col, std::string str);
|
||||
void flushBuffer();
|
||||
void clearBuf();
|
||||
void flushBuf();
|
||||
void writeSStream(std::stringstream& ss);
|
||||
void setCustomChar(uint8_t index, std::array<uint8_t, 8> cchar);
|
||||
char bar(uint8_t char_id, double value);
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user