mwingerson / PICxel

Easy to use library for ChipKIT to control WS2812 LEDs
GNU General Public License v3.0
10 stars 9 forks source link

Multiple PICxel strips #2

Open vwalsh opened 6 years ago

vwalsh commented 6 years ago

Hello,

I have a Chipkit Wifire Rev B and I'm trying to run multiple strips (from multiple PWM pins). Is there any reason this library doesn't support this? I'm still trying to run down other issues here (hardware or a stupid bug I've made). I can post code a little later.

Thanks!

vwalsh commented 6 years ago

Ok, so I was being ignorant about the multiple-strip issue and it's totally possible. However, with only your library and basic Serial output, I'm running out of ram it appears when trying to instantiate 900 pixels. I have 512 KB of ram on this wifire board, so that seems very very unlikely. Any help into memory consumption suggestions is greatly appreciated.

I've proven that if I create a custom function to 'refresh leds' based on your code, and set it to utilize only one color code (eliminating the massive color array for 900 pixels) I can control all the pixels. This has lead me to start looking into only creating light patterns with procedural generation. I'm just hoping that I can keep the timing requirements to an acceptable range.

vwalsh commented 6 years ago

I've been working through the problem and I think I'll end up forking your code. There are a few memory leak situations I've found and I'm writing some procedurally generated light effects, instead of requiring such a massive in-memory footprint. I still haven't figured out why I cannot instantiate 2700 bytes of memory to a pointer (900 pixels in GRB mode). If you have any input I'd like to hear it. Thanks!

majenkotech commented 6 years ago

The problem is with the chipKIT compiler. It has a hard limit on the heap size.

To get around it you must manually allocate a static array and pass that to the library as the storage instead of relying on calloc(), which will fail for anything more than about 2kB of RAM.

I have made a pull request that tackles some of the memory issues, and also includes the ability to change the number of LEDs on the fly (which I need for a forthcoming project).