Skip to content

Add a clear() method to the LED matrix library #280

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

Merged
merged 2 commits into from
May 8, 2024
Merged

Conversation

alranel
Copy link
Contributor

@alranel alranel commented Mar 6, 2024

This method makes it easy to turn off the matrix.

@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Mar 6, 2024
Copy link
Contributor

@aentinger aentinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @alranel ☕ 👋

How do you expect this API being used? If I see a clear API in this context I expect the RGB LED matrix to be wiped clean the moment I call it. However, that does not work. I.e. in the following example sketch both 1 and 2 are persistently displayed:

#include "ArduinoGraphics.h"
#include "Arduino_LED_Matrix.h"

ArduinoLEDMatrix matrix;

void setup() {
  matrix.begin();
}

void loop() {
  matrix.beginDraw();
  matrix.clear();
  const char text_1[] = "1";
  matrix.textFont(Font_4x6);
  matrix.beginText(0, 1, 0xFFFFFF);
  matrix.println(text_1);
  matrix.endText();
  matrix.endDraw();

  delay(1000);

  matrix.beginDraw();
  matrix.clear();
  const char text_2[] = "2";
  matrix.textFont(Font_4x6);
  matrix.beginText(8, 1, 0xFFFFFF);
  matrix.println(text_2);
  matrix.endText();
  matrix.endDraw();

  delay(1000);
}

@alranel
Copy link
Contributor Author

alranel commented Mar 26, 2024

Hi @aentinger!
The intention is to provide a method to wipe the matrix instantly. I implemented it as a shortcut to matrix.loadFrame() called with a blank frame, which AFAIK should work. Maybe it should not be called inside beginDraw()? What do you recommend to achieve this goal?

@alranel
Copy link
Contributor Author

alranel commented May 7, 2024

I added an example to the PR to show the intended usage. I also just tested it and it works.

To add some context: this is what I saw quite a few users doing manually all the time when they need to wipe the matrix. :)

@facchinm facchinm merged commit 8b1c030 into main May 8, 2024
13 checks passed
@facchinm facchinm deleted the ledmatrix-clear branch May 8, 2024 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants