prettier logger
This commit is contained in:
@@ -40,11 +40,11 @@ LCDDisplay::~LCDDisplay() {
|
||||
}
|
||||
|
||||
void LCDDisplay::open(bool reopen) {
|
||||
log(LOG::INF, "LCDDisplay", "Opening serial port at \"{}\"", _dev);
|
||||
log(LOG::INF, "Opening serial port at \"{}\"", _dev);
|
||||
if (_lcd < 0 || reopen)
|
||||
_lcd = ::open(_dev.c_str(), O_RDWR | O_NOCTTY | O_NONBLOCK); // ::open calls the global open() instead of LCDDisplay::open()
|
||||
if (_lcd < 0) {
|
||||
log(LOG::ERR, "LCDDisplay", "Error opening serial port \"{}\"", _dev); // err
|
||||
log(LOG::ERR, "Error opening serial port \"{}\"", _dev); // err
|
||||
exit(_lcd);
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ void LCDDisplay::open(bool reopen) {
|
||||
void LCDDisplay::close() {
|
||||
if (_lcd >= 0) {
|
||||
::close(_lcd);
|
||||
log(LOG::INF, "LCDDisplay", "Closed LCD port");
|
||||
log(LOG::INF, "Closed LCD port");
|
||||
}
|
||||
_lcd = -1;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ void LCDDisplay::close() {
|
||||
void LCDDisplay::write(const uint8_t* cmdbuf, uint8_t len) {
|
||||
int rc = ::write(_lcd, cmdbuf, len);
|
||||
if(rc < 0) {
|
||||
log(LOG::ERR, "LCDDisplay::write", "failed to execute ::write, lost access to port?");
|
||||
log(LOG::ERR, "failed to execute ::write, lost access to port?");
|
||||
this->open(true);
|
||||
}
|
||||
}
|
||||
@@ -71,20 +71,20 @@ void LCDDisplay::clear() {
|
||||
}
|
||||
|
||||
void LCDDisplay::setContrast(uint8_t contrast) {
|
||||
log(LOG::INF, "LCDDisplay::setContrast", "Set contrast to {}", contrast);
|
||||
log(LOG::INF, "Set contrast to {}", contrast);
|
||||
const uint8_t cmdbuf[] = {254, 80, contrast};
|
||||
this->write(cmdbuf, sizeof(cmdbuf));
|
||||
}
|
||||
|
||||
void LCDDisplay::setBacklight(bool enabled) {
|
||||
log(LOG::INF, "LCDDisplay::setBacklight", "Set backlight to {}", enabled);
|
||||
log(LOG::INF, "Set backlight to {}", enabled);
|
||||
const uint8_t cmdbuf[] = {254, (uint8_t)(enabled ? 66 : 70), 255};
|
||||
this->write(cmdbuf, enabled ? 3 : 2);
|
||||
}
|
||||
|
||||
/* still doesnt work? */
|
||||
void LCDDisplay::setBacklight(uint8_t brightness) {
|
||||
log(LOG::INF, "LCDDisplay::setBacklight", "Set backlight brightness to {}", brightness);
|
||||
log(LOG::INF, "Set backlight brightness to {}", brightness);
|
||||
const uint8_t cmdbuf[] = {254, (uint8_t)(brightness ? 66 : 70), 255, brightness}; // 3rd char is timer, 4th is brightness
|
||||
this->write(cmdbuf, brightness ? 4 : 2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user