pixelmatix / SmartMatrix

SmartMatrix Library for Teensy 3, Teensy 4, and ESP32
http://docs.pixelmatix.com/SmartMatrix
611 stars 161 forks source link

Update AnimatedGIFs sketch for ESP32 to use malloc and avoid compile/startup issues with large buffers #69

Open embedded-creations opened 5 years ago

embedded-creations commented 5 years ago

https://github.com/pixelmatix/AnimatedGIFs/issues/26

marcmerlin commented 4 years ago

if anyone needs this it's in my fork: https://github.com/marcmerlin/AnimatedGIFs

embedded-creations commented 3 years ago

I'm not sure where this stands after updating GifDecoder to use the AnimatedGIF library, so I'm going to close it

marcmerlin commented 3 years ago

if it still uses arrays instead of mallocs, the problem isn't fixed. arrays get alloced early in a smaller pool in ESP32, and just don't fit on a decent size display, but they fit if you use malloc because that goes into another pool (yeah, ESP32 sucks in that way)

embedded-creations commented 3 years ago

OK, thanks for the clarification, I'll reopen it.

embedded-creations commented 3 years ago

I think this shows how to allocate the block needed for AnimatedGIF with malloc (after allocating mymemorypool with malloc):

https://github.com/bitbank2/AnimatedGIF/issues/8#issuecomment-676480432

marcmerlin commented 3 years ago

I'm only seeing the use of a single static array. If so, that is not as good as malloc as ESP32 has memory available at runtime with malloc but not available in pre-allocated buffers (global arrays). Also, to use psram if you choose to, you have to use malloc.

This is what I did to my old fork of the library, I switched everything to malloc. Sorry, this is not a single CL, I wrote it over time

I later updated mallocordie to allow allocating in PSRAM to further save main memory

marcmerlin commented 3 years ago

mallocordie might be helpful to you: https://github.com/marcmerlin/FastLED_NeoMatrix_SmartMatrix_LEDMatrix_GFX_Demos/blob/38a137e3ac54d4f0b8d7a11ca99d2061cbbf86b1/neomatrix_config.h#L885

embedded-creations commented 3 years ago

Thanks for the links, I'm not working on this now, but they look useful for later