Skip to content

endText: SCROLL_RIGHT and SCROLL_DOWN "traces" #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
matteoguglielmi opened this issue Jul 27, 2022 · 6 comments · Fixed by #36
Closed

endText: SCROLL_RIGHT and SCROLL_DOWN "traces" #27

matteoguglielmi opened this issue Jul 27, 2022 · 6 comments · Fixed by #36
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@matteoguglielmi
Copy link

matteoguglielmi commented Jul 27, 2022

Hello,

I'm using this library to drive an Arduino RGB Shield (5x12 LED Matrix).

With the following piece of code:

MATRIX.beginText(MATRIX.width(), 0, 80, 80, 80);
MATRIX.print("H");
MATRIX.endText(SCROLL_RIGHT);

I get this behavior (5th frame):

ooooo  o....
ooooo  o....
oooooooo....
ooooo  o....
............

insted of this one (5th frame):

....o  o....
....o  o....
....oooo....
....o  o....
............

As you can see, pixels are not turned off properly, resulting in a character trace.

Character traces also occurs when using SCROLL_DOWN but not with SCROLL_LEFT or SCROLL_UP.

Any suggestion on how to remove such traces?

Thank you.

EDIT

Just noticed that:

  • traces are not present when using the letter "i" (either capitalized or not) and SCROLL_RIGHT
  • traces are present when using the letter "i" (either capitalized or not) and SCROLL_DOWN
@per1234 per1234 added the type: imperfection Perceived defect in any part of project label Jul 27, 2022
@matteoguglielmi matteoguglielmi changed the title endText SCROLL_RIGHT and SCROLL_DOWN do leave text traces (turned on LEDs) during animation endText: SCROLL_RIGHT and SCROLL_DOWN "traces" Jul 27, 2022
@aentinger
Copy link
Contributor

Your issue is caused by Arduino_Graphics providing negative numbers within set. A similar issue (arduino/ArduinoCore-renesas#226) occured for the Uno R4 WiFi, with this fix: arduino/ArduinoCore-renesas@e191781 .

@per1234
Copy link
Contributor

per1234 commented Jan 9, 2024

The Arduino_MKRRGB library already has code for correctly handling negative coordinates:

https://github.com/arduino-libraries/Arduino_MKRRGB/blob/258e28c03b572f1b0256606c54ab45687e1f829a/src/MKRRGBMatrix.cpp#L122

void RGBMatrixClass::set(int x, int y, uint8_t r, uint8_t g, uint8_t b)
{
  if (x < 0 || x >= RGB_MATRIX_WIDTH || y < 0 || y >= RGB_MATRIX_HEIGHT) {
    return;
  }

so that is not the cause of the bug.

The cause is that the ArduinoGraphics library simply doesn't have any code for clearing the graphic at the previous position when scrolling text:

} else if (scrollDirection == SCROLL_RIGHT) {
int scrollLength = _textBuffer.length() * textFontWidth() + _textX;
for (int i = 0; i < scrollLength; i++) {
beginDraw();
text(_textBuffer, _textX - (scrollLength - i - 1), _textY);
endDraw();
delay(_textScrollSpeed);
}

In cases like i, the clearing is done purely by chance due to the left column of the graphic being empty:

// i
(const uint8_t[]){
0b00100000,
0b00000000,
0b01100000,
0b00100000,
0b00100000,
0b01110000,
0b00000000,
},

@per1234 per1234 reopened this Jan 9, 2024
@per1234 per1234 added the topic: code Related to content of the project itself label Jan 9, 2024
@aentinger
Copy link
Contributor

Thank you @per1234 for reporting this in detail 🙇 . Though it seems to me that fixing this in the library may have been less work. I'll be ordering myself an Arduino MKR RGB Shield which - surprisingly - isn't in my collection yet. Then let's fix this once and for all.

@per1234
Copy link
Contributor

per1234 commented Jan 9, 2024

@aentinger the bug can also be reproduced with the UNO R4 WiFi. Here is a demonstration sketch:

#include <ArduinoGraphics.h>
#include <Arduino_LED_Matrix.h>

ArduinoLEDMatrix matrix;

void setup() {
  matrix.begin();
  matrix.textScrollSpeed(50);
  matrix.textFont(Font_5x7);

  matrix.beginText(matrix.width(), 1, 80, 80, 80);
  matrix.print("H");
  matrix.endText(SCROLL_RIGHT);
}

void loop() {}

@aentinger
Copy link
Contributor

That I have 🚀 . Let's fix it 🪛

@matteoguglielmi
Copy link
Author

Hello,

Was it fixed in the latest 1.1.2 release of the ArduinoGraphics library?

I'm asking because I still get the same artifacts with an Arduino MKR WIFI 1010 + Arduino RGB LED Shield when, for instance, scrolling down the three letters 'EEE,' but only on the second and third 'E.'

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants