Does anyone know how to slow down the LED matrix animation? the matrix.play(true); command plays each frame without delay. I used the LED Matrix Editor to download a series of letters as a .h file and I substituted them into IntroUnoR4WiFi sketch but they display too fast. A delay statement has no effect and the autoscroll parameter is useless. It says something about a next statement but no info on how to use it. The only way I could do it was duplicate each letter 15 times in the .h file.
It looks like the Led Matrix code is a work in progress.
I think you can change delays by changing the fourth integer in each frame of the sequence (most of them are 66 in the original code except for a couple at the end). I don't think autoscroll currently has any affect.
BTW, how did you get ".h" format output from the LED Matrix Editor? I can only get a python-style list when I try to download the animation.
You're right. Increasing the fourth line in each frame does increase the delay. You need to press the
</> button not the download button to save it as a .h file.
Aha! Thanks for the tip on the </>. I thought it was for renaming the animation!
BTW, I just tried this clumsy workaround for frame timing. If you set the frame interval for all of the frames to a large amount -- the maximum is 0xFFFFFFFF -- you can then use matrix.next() to move the frames along. For example:
int numFrames = sizeof(frames)/16;
for (int i=0; i<numFrames; i+=1) {
matrix.next();
delay(200);
}
I just tried this and it seems to work.
That works and you can add a delay after all the frames are displayed but it starts on the second frame.
hey folks
the library is built to be threaded, so the timing is managed by the 4th integer.
the purpose of threading is to make animations independent of your loop code, because delay
is bad... 'm'kay?
in the interface of the LED Matrix editor you can change the number at the bottom (66 to make it 15fps) and increase it.
The Editor is, as you guessed, still WIP and it's one of our Lab projects.
I wrote the engine so if you have questions feel free to ask.
here's a freebie:
if you press SHIFT + any of the cursor keys (UP/DOWN/LEFT/RIGHT) you'll shift the pixel matrix in that direction and it will wrap.
to prevent wrap add ALT (Option) to the sequence.
have fun
@ubidefeo Useful information. Thanks! The multi-threaded approach is great. Did you write Arduino_LED_Matrix.h?
BTW, the delay() in my example was to just demonstrate the concept. You could easily set up a timer using millis() to make the code non-blocking. FWIW
@trentd I just checked and it looks like my code starts on frame one. But, I commented out the matrix.play() and matrix.autoscroll() lines at the top. If one of them is still in, I think it would show the first frame but then immediately overwrite it with the second frame, so you might not notice it. That's my theory, anyway.
robertgallup, You were right. I still had the matrix.play(true); statement in the setup. I thought you needed it to get it started. It starts from frame 1 now.
ubidefeo, I see how you can move the image in the frame with the SHFT key but will the autoscroll statement do that in code in the future?
I did not write the initial Library, but I worked on it and defined a bit of the API.
The Matrix editor in the browser is based on my work (core engine and Canvas).
Also the PoC for some examples was made by me but rendered user-friendly by our content team
Often I make dodgy-looking code that works but don't get a lot of time to make it pretty
the matrix shift feature is only in the editor in order to generate a frame(set).
Autoscroll does something else and I believe it's text only.
I'm sure we'll work more on the library, but we also count on the community's contribution
@trentd I realized there's another workaround for controlling a sequence of frames that doesn't involve changing frame intervals in the sequence. And, it's easy to randomly access the frames rather than following them in sequence. Here's the sample:
// This steps through frames in a sequence
int numFrames = sizeof(frames)/16;
for (int i=0; i<numFrames; i+=1) {
matrix.loadFrame(frames[i]);
delay(70);
}
Note: as @ubidefeo pointed out, delay() is blocking and isn't a good choice if you're trying to do other things like check for button presses, etc. But, here it just shows the idea of accessing frames.
That is much more convenient since you don't have to manually replace the frame interval for every frame from 66 to 0xFFFFFFFF and can just copy the whole block as is. I'll try writing a case..select block to take input from a keypad and display it now that I have the alphabet and number sets downloaded from the LED matrix editor.
Thanks