Skip to content

Led Matrix : random bits on lines or columns #226

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
paulvha opened this issue Dec 26, 2023 · 1 comment · Fixed by #232
Closed

Led Matrix : random bits on lines or columns #226

paulvha opened this issue Dec 26, 2023 · 1 comment · Fixed by #232
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

@paulvha
Copy link
Contributor

paulvha commented Dec 26, 2023

When using ArduinoGraphics on the Led Matrix and doing a scroll left random bits are showing in the RIGHT columns. This is happening as well when doing a scroll up, on the bottom lines.

It was noticed already doing development given the remark in the function endDraw() in Arduino_LED_matrix.h:

// clear first line (no idea why it gets filled with random bits, probably some math not working fine for super small displays)

The root cause is related to ArduinoGraphics as it returns NEGATIVE numbers when scrolling. In the function set() in Arduino_led_matrix.h it checks for out of bound values, BUT not for negative values for Y and X. Then when doing a _canvasBuffer[y][x] will cause under desired memory to be written.

Solution :

change in function set(), line 251 from:

if (y >= canvasHeight || x >= canvasWidth) {

to:

if (y >= canvasHeight || x >= canvasWidth || y < 0 || x < 0) {
@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels Dec 26, 2023
@aentinger
Copy link
Contributor

Hi @paulvha ☕ 👋

Thank you for reporting this issue. I've been able to verify it with this minimal example sketch:

// To use ArduinoGraphics APIs, please include BEFORE Arduino_LED_Matrix
#include "ArduinoGraphics.h"
#include "Arduino_LED_Matrix.h"

ArduinoLEDMatrix matrix;

void setup() {
  Serial.begin(115200);
  matrix.begin();

  matrix.textScrollSpeed(50);

  matrix.beginDraw();
  matrix.stroke(0xFFFFFFFF);

  const char text[] = "UNO r4";
  matrix.textFont(Font_4x6);
  matrix.beginText(0, 1, 0xFFFFFF);
  matrix.println(text);
  matrix.endText(SCROLL_LEFT);

  matrix.endDraw();

  delay(2000);
}

void loop() {
}

I can confirm that your suggestion is fixing this issue and I will be preparing a PR for it.

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
3 participants