pixelmatix / SmartMatrix

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

Handle PSRAM if available and enabled at compile time. #119

Closed marcmerlin closed 4 years ago

marcmerlin commented 4 years ago

Enabling PSRAM in the arduino GUI sets BOARD_HAS_PSRAM If it is defined, show PSRAM used/free along with rest of memory. Also fix heap_caps_get_free_size(MALLOC_CAP_INTERNAL) (using 0 was not correct). Allow allocating PSRAM for background buffers.

marcmerlin commented 4 years ago

@embedded-creations thanks for merging my other patches. This is the only one left I need to use your branch

embedded-creations commented 4 years ago

Merged, but untested by me as I don't have a PSRAM capable board wired up. Thanks for the patch!

marcmerlin commented 4 years ago

Thanks @embedded-creations , if that helps, that's the code I sent you:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SmartMatrix Init Done
Before matrix->begin
Heap/32-bit Memory Available     : 112752 bytes total, 41344 bytes largest free block
8-bit/malloc/DMA Memory Available: 71408 bytes total, 40896 bytes largest free block
Total PSRAM used: 40540 bytes total, 4153464 PSRAM bytes fre

that said, as you probably figured out, worst case if it's not working well, people can turn it off.

I'm currently looking into a weird isue where smartmatrix + wifi + PSRAM (I need PSRAM to have enough memory left to use wifi) will randomly hang the CPU with no traceback depending on whch unrelated instructions I comment out (serial.printf), but that may be a compiler bug or something weird I haven't found yet.