Skip to content

Commit 177e5d5

Browse files
Merge pull request #51 from per1234/fix-scroll-clearing
Fix scroll trail clearing bugs
2 parents 6dd5d44 + 83d6df0 commit 177e5d5

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

.codespellrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# See: https://github.com/codespell-project/codespell#using-a-config-file
22
[codespell]
33
# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here:
4-
ignore-words-list = mis
4+
ignore-words-list = cleary,mis
55
check-filenames =
66
check-hidden =
77
skip = ./.git

src/ArduinoGraphics.cpp

+34-5
Original file line numberDiff line numberDiff line change
@@ -448,17 +448,21 @@ void ArduinoGraphics::endText(int scrollDirection)
448448
uint8_t strokeG = _strokeG;
449449
uint8_t strokeB = _strokeB;
450450

451-
452-
stroke(_textR, _textG, _textB);
453-
454451
if (scrollDirection == SCROLL_LEFT) {
455452
int scrollLength = _textBuffer.length() * textFontWidth() + _textX + 1;
456453

457454
for (int i = 0; i < scrollLength; i++) {
458455
beginDraw();
456+
459457
int const text_x = _textX - i;
458+
stroke(_textR, _textG, _textB);
460459
text(_textBuffer, text_x, _textY);
461-
bitmap(_font->data[0x20], text_x - 1, _textY, 1, _font->height, _textSizeX, _textSizeY);
460+
461+
// clear previous position
462+
const int clearX = text_x + _textBuffer.length() * _font->width;
463+
stroke(_backgroundR, _backgroundG, _backgroundB);
464+
line(clearX, _textY, clearX, _textY + _font->height - 1);
465+
462466
endDraw();
463467

464468
delay(_textScrollSpeed);
@@ -468,9 +472,18 @@ void ArduinoGraphics::endText(int scrollDirection)
468472

469473
for (int i = 0; i < scrollLength; i++) {
470474
beginDraw();
475+
471476
int const text_x = _textX - (scrollLength - i - 1);
477+
stroke(_textR, _textG, _textB);
472478
text(_textBuffer, text_x, _textY);
479+
480+
// clear previous position
481+
const int clearX = text_x - 1;
482+
stroke(_backgroundR, _backgroundG, _backgroundB);
483+
line(clearX, _textY, clearX, _textY + _font->height - 1);
484+
473485
bitmap(_font->data[0x20], text_x - 1, _textY, 1, _font->height, _textSizeX, _textSizeY);
486+
474487
endDraw();
475488

476489
delay(_textScrollSpeed);
@@ -480,9 +493,16 @@ void ArduinoGraphics::endText(int scrollDirection)
480493

481494
for (int i = 0; i < scrollLength; i++) {
482495
beginDraw();
496+
483497
int const text_y = _textY - i;
498+
stroke(_textR, _textG, _textB);
484499
text(_textBuffer, _textX, text_y);
485-
bitmap(_font->data[0x20], _textX, text_y - 1, _font->width, 1, _textSizeX, _textSizeY);
500+
501+
// clear previous position
502+
const int clearY = text_y + _font->height;
503+
stroke(_backgroundR, _backgroundG, _backgroundB);
504+
line(_textX, clearY, _textX + (_font->width * _textBuffer.length()) - 1, clearY);
505+
486506
endDraw();
487507

488508
delay(_textScrollSpeed);
@@ -492,15 +512,24 @@ void ArduinoGraphics::endText(int scrollDirection)
492512

493513
for (int i = 0; i < scrollLength; i++) {
494514
beginDraw();
515+
495516
int const text_y = _textY - (scrollLength - i - 1);
517+
stroke(_textR, _textG, _textB);
496518
text(_textBuffer, _textX, text_y);
519+
520+
// clear previous position
521+
const int clearY = text_y - 1;
522+
stroke(_backgroundR, _backgroundG, _backgroundB);
523+
line(_textX, clearY, _textX + (_font->width * _textBuffer.length()) - 1, clearY);
524+
497525
bitmap(_font->data[0x20], _textX, text_y - 1, _font->width, 1, _textSizeX, _textSizeY);
498526
endDraw();
499527

500528
delay(_textScrollSpeed);
501529
}
502530
} else {
503531
beginDraw();
532+
stroke(_textR, _textG, _textB);
504533
text(_textBuffer, _textX, _textY);
505534
endDraw();
506535
}

0 commit comments

Comments
 (0)