PatternPaint Animation exports on the EightByEight

edited November 2017 in General Help

I want to integrate animations created in PatternPaint with a custom sketch I'm writing for the EightByEight. The exports created by PatternPaint (the .h files) reference an Animation class, which is not present among the EightByEight demo code.
I see in the EightByEight commit history that the Animation class stubs were replaced with the PatternDemo class. Digging into this implementation it looks like it reads from separate compiled binary files uploaded by PatternPaint to the Arduino directly, not from the animation defined by the .h during compilation of the sketch.

I did find animation.cpp and animation.h in the BlinkyTape repository which looks promising, but this references FastLED as the output class, rather than RGBMatrix.
So, I'm thinking what is needed is to adapt the Animation class referenced above to use RGBMatrix (instead of FastLED) as the output interface.

Does that sound right? Any other guidance as to how to approach this?


  • Or would it make more sense to adapt the PatternDemo/PatternFile classes (which already work with RGBMatrix) to work directly with the Animation data as it's provided by the exported files (instead of reading from the compiled binaries)?

  • Storing the animations as separate files was a little nicer for PatternPaint, since it no longer needed to re-flash the firmware for each animation upload (it just loads the new patterns to the JFFS filesystem on the ESP flash), but for a custom program it could be better to bake them into your program.

    I'd probably go the second route, and adapt the PatternDemo/PatternFile class to work with the animation data. It should be straightforward to graft the guts of the animation library from the BlinkyTape sketch into that, and it works with the simple Demo framework,

    The animation class from the BlinkyTape library is a bit more advanced, since it supports a compressed RGB565+RLE encoding scheme as well as RGB24. PatternPaint is capable of exporting both styles, however it currently doesn't expose an option to let you chose which one to use during export. A long-standing to-do item for PatternPaint is to clean the export process up, and allow for that to be selected, along with exporting the entire pattern collection at once instead of individually. It would also be great to have it export an entire sketch for your device, including the animation library or the equivalent for the EightByEight.

  • Well, I ended up using the Animation class as a base since the .h files exported by PatternPaint use RLE compression.

    I changed the class name from Animation to MatrixAnimation so it's clear it is supposed to play on a matrix device rather than a strip, and the bulk of the update involved changing the target device from struct CRGB strip[] to RGBMatrix &matrix.

    My code works for that RGB565_RLE format, but I sort of guessed at the algorithm for the other formats, as I don't have any sample data to test it against, so some correction may be needed for it to work on those other encodings.

    All that's needed to get it to work with the .h files exported from PatternPaint are:
    1. edit the exported .h file to convert Animation class references to MatrixAnimation, e.g. MatrixAnimation animation(8, animationData, MatrixAnimation::RGB565_RLE, 64, 100);
    2. include the matrixAnimation.h and .h file for your exported animation in your .ino sketch file
    3. invoke the animation variables's .draw() method, passing in the RGBMatrix instance. This will draw the next frame of the animation.

    I added a get method to expose the frameIndex state variable so you can detect when the animation is finished, and for the other application I want to use this on I'll add a .play() method which will loop through all the frames in sequence.


  • Sweet, glad you got it working, and thanks for sharing your code!

Sign In or Register to comment.