@@ -373,32 +373,55 @@ void ArduinoGraphics::beginText(int x, int y, uint32_t color)
373373 beginText (x, y, COLOR_R (color), COLOR_G (color), COLOR_B (color));
374374}
375375
376- void ArduinoGraphics::endText (bool scroll )
376+ void ArduinoGraphics::endText (int scrollDirection )
377377{
378378 // backup the stroke color and set the color to the text color
379379 bool strokeOn = _stroke;
380380 uint8_t strokeR = _strokeR;
381381 uint8_t strokeG = _strokeG;
382382 uint8_t strokeB = _strokeB;
383383
384- Serial.println (_textBuffer);
385- Serial.println (_textX);
386- Serial.println (_textY);
387- Serial.println (_textR);
388- Serial.println (_textG);
389- Serial.println (_textB);
390-
391384
392385 stroke (_textR, _textG, _textB);
393386
394- if (scroll ) {
387+ if (scrollDirection == SCROLL_LEFT ) {
395388 int scrollLength = _textBuffer.length () * textFontWidth () + _textX;
396389
397390 for (int i = 0 ; i < scrollLength; i++) {
398391 beginDraw ();
399392 text (_textBuffer, _textX - i, _textY);
400393 endDraw ();
401394
395+ delay (_textScrollSpeed);
396+ }
397+ } else if (scrollDirection == SCROLL_RIGHT) {
398+ int scrollLength = _textBuffer.length () * textFontWidth () + _textX;
399+
400+ for (int i = 0 ; i < scrollLength; i++) {
401+ beginDraw ();
402+ text (_textBuffer, _textX - (scrollLength - i - 1 ), _textY);
403+ endDraw ();
404+
405+ delay (_textScrollSpeed);
406+ }
407+ } else if (scrollDirection == SCROLL_UP) {
408+ int scrollLength = textFontHeight () + _textY;
409+
410+ for (int i = 0 ; i < scrollLength; i++) {
411+ beginDraw ();
412+ text (_textBuffer, _textX, _textY - i);
413+ endDraw ();
414+
415+ delay (_textScrollSpeed);
416+ }
417+ } else if (scrollDirection == SCROLL_DOWN) {
418+ int scrollLength = textFontHeight () + _textY;
419+
420+ for (int i = 0 ; i < scrollLength; i++) {
421+ beginDraw ();
422+ text (_textBuffer, _textX, _textY - (scrollLength - i - 1 ));
423+ endDraw ();
424+
402425 delay (_textScrollSpeed);
403426 }
404427 } else {
0 commit comments