Skip to content

Commit ce5ac8e

Browse files
committed
Correct text scroll trail clearing coordinates calculation for left and up directions
The `endText` function has the capability to scroll the printed text. In order to ensure artifacts are not left behind on the display while scrolling, the library must clear the pixels at the previous location of the text after each frame of the scrolling animation. Previously, the code to handle this clearing incorrectly calculated the clearing coordinates for the leftwards (`SCROLL_LEFT`) and upwards (`SCROLL_UP`) scroll directions, having two separate problems: * The offset was subtracted rather than added. * An offset of 1 was used, which did not consider the width/height of the text. This bug might not be immediately apparent to the user because many character bitmaps do not populate any pixels on the rightmost column or bottom row of the grid, and thus those characters provide incidental self scroll trail clearing. However, this is not the case for all characters and those would cause a trail of artifacts to be left behind on the display when scrolled. The clearing coordinates calculation code is hereby corrected. NOTE: The coordinates calculation will still be incorrect for multi-line strings. However, this is not a regression because it was also incorrect before this change. The scroll trail clearing code has never had any provisions for handling multi-line strings so addition of such support is out of scope for this commit. In addition, the text scrolling code (not the scroll trail clearing code) has never correctly handled horizontal scrolling of multi-line strings, so until that is fixed it is only the lack of correct scroll trail clearing for vertical scrolling that is impactful to users.
1 parent 589b622 commit ce5ac8e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ArduinoGraphics.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ void ArduinoGraphics::endText(int scrollDirection)
458458
beginDraw();
459459
int const text_x = _textX - i;
460460
text(_textBuffer, text_x, _textY);
461-
bitmap(_font->data[0x20], text_x - 1, _textY, 1, _font->height, _textSizeX, _textSizeY);
461+
bitmap(_font->data[0x20], text_x + _textBuffer.length() * _font->width, _textY, 1, _font->height, _textSizeX, _textSizeY);
462462
endDraw();
463463

464464
delay(_textScrollSpeed);
@@ -482,7 +482,7 @@ void ArduinoGraphics::endText(int scrollDirection)
482482
beginDraw();
483483
int const text_y = _textY - i;
484484
text(_textBuffer, _textX, text_y);
485-
bitmap(_font->data[0x20], _textX, text_y - 1, _font->width, 1, _textSizeX, _textSizeY);
485+
bitmap(_font->data[0x20], _textX, text_y + _font->height, _font->width, 1, _textSizeX, _textSizeY);
486486
endDraw();
487487

488488
delay(_textScrollSpeed);

0 commit comments

Comments
 (0)