cleanup cont.
This commit is contained in:
@@ -53,22 +53,26 @@ void LCDDisplay::setBacklight(bool enabled) {
|
||||
write(_lcd, &cmdbuf, enabled ? 3 : 2);
|
||||
}
|
||||
|
||||
/* doesnt quite work yet, need to look up matrix orbital spec */
|
||||
void LCDDisplay::setBacklight(uint8_t brightness) {
|
||||
std::println("[LCDDisplay::setBacklight] Set backlight brightness to {}", brightness);
|
||||
uint8_t cmdbuf[] = {254, (uint8_t)(brightness ? 66 : 70), brightness};
|
||||
write(_lcd, &cmdbuf, brightness ? 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);
|
||||
}
|
||||
|
||||
void LCDDisplay::setCustomChar(uint8_t index, std::array<uint8_t, 8> cchar) {
|
||||
uint8_t cmdbuf[11];
|
||||
cmdbuf[0] = 254;
|
||||
cmdbuf[1] = 78;
|
||||
cmdbuf[2] = index;
|
||||
uint8_t cmdbuf[11] = {254, 78, index, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
for (uint8_t i = 0; i < 8; i++)
|
||||
cmdbuf[i + 3] = cchar[i];
|
||||
write(_lcd, &cmdbuf, 11);
|
||||
}
|
||||
|
||||
|
||||
void LCDDisplay::writeStr(std::string str) {
|
||||
write(_lcd, str.c_str(), str.size());
|
||||
}
|
||||
@@ -100,8 +104,8 @@ void LCDDisplay::clearBuf() {
|
||||
|
||||
/* hyper optimized buffer flush command, writes whole disp with a single write */
|
||||
void LCDDisplay::flushBuf() {
|
||||
uint8_t writebuf[168]; // 4x40 chars + 2x4 setcursor commands
|
||||
uint8_t setDisp[] = {254, 71, 1, 1}; // set cursor to char 1, line 1
|
||||
uint8_t writebuf[168]; // 4x40 chars + 2x4 setcursor commands
|
||||
uint8_t setDisp[] = {254, 71, 1, 1}; // set cursor to char 1, line 1
|
||||
|
||||
std::memcpy(&writebuf[0], setDisp, 4); // copy set cursor command
|
||||
std::memcpy(&writebuf[4], linebuf[0], 40); // copy 1st line
|
||||
@@ -114,7 +118,6 @@ void LCDDisplay::flushBuf() {
|
||||
write(_lcd, writebuf, 168);
|
||||
}
|
||||
|
||||
|
||||
char LCDDisplay::bar(uint8_t char_id, double value) {
|
||||
std::array<uint8_t, 8> b;
|
||||
b.fill(0b01110);
|
||||
|
||||
Reference in New Issue
Block a user