Description
Describe the problem
The endText
function has the capability to scroll the printed text. In order to avoid leaving behind artifacts 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.
🐛 Artifacts are left behind in the matrix when scrolling text under any of the following sets of conditions:
- Scroll direction is leftwards (
SCROLL_LEFT
) - A pixel is populated at the rightmost column of the bitmap for the final character in the string.
- OR -
- Scroll direction is upwards (
SCROLL_UP
). - A pixel is populated at the bottom row of the bitmap for any character in the string.
- OR -
- Scroll direction is downwards (
SCROLL_DOWN
). - A pixel is populated at the top row of the bitmap for any character other than the first character in the string.
Here you can see the problem as it occurs with the #
character and SCROLL_LEFT
:
To reproduce
SCROLL_LEFT
#include <ArduinoGraphics.h>
#include <Arduino_LED_Matrix.h>
ArduinoLEDMatrix matrix;
void setup() {
matrix.begin();
matrix.textFont(Font_4x6);
matrix.textScrollSpeed(200);
}
void loop() {
matrix.beginText(matrix.width(), 1, 0xFFFFFF);
matrix.print("#"); // The bitmap for the Font_4x6 # character has two populated pixels on the rightmost column
matrix.endText(SCROLL_LEFT);
}
🐛 A trail of artifacts is left on the display.
SCROLL_UP
#include <ArduinoGraphics.h>
#include <Arduino_LED_Matrix.h>
ArduinoLEDMatrix matrix;
void setup() {
matrix.begin();
matrix.textFont(Font_4x6);
matrix.textScrollSpeed(300);
}
void loop() {
matrix.beginText(1, matrix.height(), 0xFFFFFF);
matrix.print("(("); // The bitmap for the Font_4x6 ( character has a populated pixel on the bottom row
matrix.endText(SCROLL_UP);
}
🐛 A trail of artifacts is left on the display for each character in the string.
SCROLL_DOWN
#include <ArduinoGraphics.h>
#include <Arduino_LED_Matrix.h>
ArduinoLEDMatrix matrix;
void setup() {
matrix.begin();
matrix.textFont(Font_4x6);
matrix.textScrollSpeed(300);
}
void loop() {
matrix.beginText(0, matrix.height(), 0xFFFFFF);
matrix.print("(((");
matrix.endText(SCROLL_DOWN);
}
🐛 Although trail clearing works correctly for the first character, trail of artifacts is left on the display for each additional character in the string.
Expected behavior
Artifacts are not left behind on display when scrolling text.
ArduinoGraphics version
Display Library
Any
Verified with:
- LED_Matrix version 1.1.0 (Arduino UNO R4 Boards version 1.3.2)
- Arduino_MKRRGB version 1.1.0
Additional context
Test/investigatory code:
#include <ArduinoGraphics.h>
#include <Arduino_LED_Matrix.h>
ArduinoLEDMatrix matrix;
Font fonts[] = { Font_4x6, Font_5x7 };
int directions[] = { SCROLL_LEFT, SCROLL_UP };
void setup() {
matrix.begin();
matrix.textScrollSpeed(50);
}
void loop() {
for (byte fontIndex = 0; fontIndex < (sizeof(fonts) / sizeof(fonts[0])); fontIndex++) {
matrix.textFont(fonts[fontIndex]);
for (char character = 33; character < 127; character++) {
matrix.beginText(matrix.width(), (matrix.height()-matrix.textFontHeight())/2, 0xFFFFFF);
matrix.print(character);
matrix.endText(SCROLL_LEFT);
matrix.beginText((matrix.width()-matrix.textFontWidth())/2, matrix.height(), 0xFFFFFF);
matrix.print(character);
matrix.endText(SCROLL_UP);
}
}
}