Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Max-Plastix opened this issue Dec 22, 2021 · 1 comment

Comments

@Max-Plastix
Copy link

Max-Plastix commented Dec 22, 2021

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant