@@ -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