Announce: SmartMatrix::GFX

(TL;DR: swapBuffers on ESP32 is pretty slow, I only get 76fps for 4096 pixels)

I finished my initial hackish port of FastLED::NeoMatrix to SmartMatrix.
It should allow any Adafruit::GFX code to work on SmartMatrix backend with minimal changes. Similarly FastLED::NeoMatrix code should mostly work out of the box too.

Code: GitHub - marcmerlin/SmartMatrix_GFX: SmartMatrix: Allow using Adafruit::GFX as well as FastLED_NeoMatrix code with SmartMatrix backend,
Demo: SmartMatrix_GFX/MatrixGFXDemo.ino at master · marcmerlin/SmartMatrix_GFX · GitHub

I’m doing something terrible which is to render inside a FastLED array buffer to be compatible with existing code, and then copying the entire framebuffer into SmartMatrix, pixel by pixel.
I know it’s terrible but honestly I’m not sure how to do better.

I can’t push and display pixels faster than 74 frames per second for 4096 pixels, which isn’t that good, but it’s usable.

EDIT: I tried to backgroundLayer.swapBuffers(); only (without copying to my FastLED buffer to the SmartMatrix buffer, and it was only 1s faster (75fps). So it is swapbuffer that is slow on ESP32.
I tried swapbuffer zero copy swapBuffers(true), and it’s not measurably faster.

Suggestions welcome :slight_smile:

I just had time to port a bunch of demos to SmartMatrix thanks to the new API layer, see

Demos:

Those demos should work with both SmartMatrix::GFX and FastLED::NeoMatrix thanks to the compat layer.

@Jason might notice the irony that I ported Aurora demos back from SmartMatrix to GFX and then back to SmartMatrix
https://github.com/marcmerlin/SmartMatrix_GFX/tree/master/examples/Aurora
but this version is “better” in that the demos have been split in independent demos that can run on their own, and can be moved from SmartMatrix and to NeoMatrix with a single #define in the top level config.h

Oh, also, @Jason, in case you have a 32x32 or even 64x64 matrix laying around, I’d love for you to have a look at my port of Aurora to check that I haven’t butchered it too much.
Some of the effects I selected look ok-ish in 64x64 but probably not quite like they were meant to originally (scaling up is not always perfect).
For one, I can’t get PatternSwirl.h to have a wider blur around its drawings, and it doesn’t look that great without one (IMO)
Thanks

Thanks to

SmartMatrix::GFX is now “free” to use, no more duplicate framebuffer or extra copies
You can now use FastLED / NeoMatrix and LEDMatrix code without having to rewrite anything.