add backlight
This commit is contained in:
@@ -45,6 +45,12 @@ void LCDDisplay::setContrast(uint8_t contrast) {
|
||||
write(_lcd, cmdbuf, 3);
|
||||
}
|
||||
|
||||
void LCDDisplay::setBacklight(bool enabled) {
|
||||
std::cout << "[LCDDisplay] Backlight set to " << std::to_string(enabled) << std::endl;
|
||||
uint8_t cmdbuf[] = {254, (uint8_t)(enabled ? 66 : 70), 255};
|
||||
write(_lcd, cmdbuf, enabled ? 3 : 2);
|
||||
}
|
||||
|
||||
void LCDDisplay::setCursor(uint8_t row, uint8_t col) {
|
||||
uint8_t cmdbuf[] = {254, 71, (uint8_t)(col + 1), (uint8_t)(row + 1)};
|
||||
write(_lcd, cmdbuf, 4);
|
||||
@@ -77,4 +83,4 @@ void LCDDisplay::writeSStream(std::stringstream& ss) {
|
||||
writeStr(s.substr(0, 80));
|
||||
setCursor(2, 0);
|
||||
writeStr(s.substr(80, 159));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ class LCDDisplay {
|
||||
|
||||
void clear();
|
||||
void setContrast(uint8_t contrast);
|
||||
void setBacklight(bool enabled);
|
||||
void setCursor(uint8_t row, uint8_t col);
|
||||
void writeLines(std::array<std::string, 4> lines);
|
||||
void writeSStream(std::stringstream& ss);
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user