ThingPulse / esp8266-oled-ssd1306

Driver for the SSD1306 and SH1106 based 128x64, 128x32, 64x48 pixel OLED display running on ESP8266/ESP32
https://thingpulse.com
Other
1.98k stars 638 forks source link

The last character of an unterminated log line does not get printed in drawLogBuffer #362

Open Max-Plastix opened 2 years ago

Max-Plastix commented 2 years ago

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:

  1. Configure SSD1306Wire * display
  2. use display->print() to print a line ending in \n -- no problem.
  3. use display->print() to print a line without a \n -- all but the last character is displayed
  4. 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!

Max-Plastix commented 2 years ago

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.