Hello everyone,
I'm currently working on a project using the Arduino Uno R4 WiFi board, specifically focusing on utilizing the LED matrix. After reviewing the Arduino documentation, I noticed that the gallery.h
file offers a variety of predefined animations, which I'm eager to display on my matrix.
https://docs.arduino.cc/tutorials/uno-r4-wifi/led-matrix/#frame-gallery
To achieve this, I've written a program intended to cycle through these animations. Unfortunately, I'm encountering an issue where, after running for a while, the program seems to freeze, and the LED matrix starts showing random dots instead of the animations. I added some serial output to debug, but it appears that the code gets stuck and never reaches the "out loop" print statement.
Here's the code snippet I'm working with:
#include "Arduino_LED_Matrix.h" // Include the LED_Matrix library
ArduinoLEDMatrix matrix;
const size_t num_sequences = 8;
uint32_t (*animation_sequences[])[4] = {
const_cast<uint32_t (*)[4]>(LEDMATRIX_ANIMATION_STARTUP),
const_cast<uint32_t (*)[4]>(LEDMATRIX_ANIMATION_TETRIS_INTRO),
const_cast<uint32_t (*)[4]>(LEDMATRIX_ANIMATION_ATMEGA),
const_cast<uint32_t (*)[4]>(LEDMATRIX_ANIMATION_WIFI_SEARCH),
const_cast<uint32_t (*)[4]>(LEDMATRIX_ANIMATION_OPENSOURCE),
const_cast<uint32_t (*)[4]>(LEDMATRIX_ANIMATION_SPINNING_COIN),
const_cast<uint32_t (*)[4]>(LEDMATRIX_ANIMATION_TETRIS),
const_cast<uint32_t (*)[4]>(LEDMATRIX_ANIMATION_WIFI_SEARCH)
};
void setup() {
Serial.begin(115200);
matrix.begin();
}
void loop() {
Serial.println("in loop");
for (size_t i = 0; i < num_sequences; ++i) {
matrix.loadSequence(animation_sequences[i]);
matrix.play(false);
while (1) {
if (matrix.sequenceDone() == 1) {
break;
}
}
}
Serial.println("out loop");
}
If anyone has experienced similar issues or has suggestions on how to fix this freezing behavior, your input would be greatly appreciated. I'm especially interested in knowing if there could be a problem with how I'm managing the animation loops or a potential memory overflow issue related to handling the animations.
Thank you all in advance for your help and advice!