The last character of an unterminated log line does not get printed in drawLogBuffer
Describe the bug When printing characters to the screen without a terminating new-line, the LogBuffer is correctly displayed, except for the very last character, which is omitted from the display.
To Reproduce Steps to reproduce the behavior:
- Configure
SSD1306Wire * display - use
display->print()to print a line ending in\n-- no problem. - use
display->print()to print a line without a\n-- all but the last character is displayed - print another character, and the first missing character appears
Sample code
void OLEDDisplay::drawLogBuffer(uint16_t xMove, uint16_t yMove) {
...
drawStringInternal(xMove, yMove + line * lineHeight, &this->logBuffer[lastPos], length, 0);
May be related to the problem, as logBuffer[lastPos] may point to the newline character \n itself, from the
lastPos=i in the loop above.
Expected behavior Each character, including the last printable character, should appear on the last line of the log display
Versions (please complete the following information): ESP8266 and ESP32 OLED driver for SSD1306 displays by Daniel Eichhorn, ThingPulse 4.2.1 pulled in by PlatformIO
lib_deps = thingpulse/ESP8266 and ESP32 OLED driver for SSD1306 displays
Additional context Thanks!
Changing Line 819 in drawLogBuffer to read
drawStringInternal(xMove, yMove + line * lineHeight, &this->logBuffer[lastPos+1], length, 0);
does cause all characters to display. It may be unsafe, with regards to buffer length, seemed to confirm the printable character is present and displayed.