kitesurfer1404/WS2812FX

Can't add 2nd instance. (Running multiple LED-strips via different pins at once)

TipsTricksMore opened this issue · 1 comments

Hi @kitesurfer1404
thanks for this great lib! It's awesome.

I'm running two LED sources (WS2812B) via two different pins on my Arduino Nano.
When running the "auto-mode-example" on each of them individually, everything is fine.
However, when I'm adding a 2nd instance to drive both of them at the same time, nothing happens...

This is my basic code. Is this a bug, or am I missing something?

#include <WS2812FX.h>

#define LED_COUNT 256
#define LED_PIN 3

#define LED_COUNT2 9
#define LED_PIN2 10

#define TIMER_MS 5000

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
WS2812FX ws2812fx1 = WS2812FX(LED_COUNT, LED_PIN, NEO_RGB + NEO_KHZ800);
WS2812FX ws2812fx2 = WS2812FX(LED_COUNT2, LED_PIN2, NEO_RGB + NEO_KHZ800);

unsigned long last_change = 0;
unsigned long now = 0;

void setup() {
  ws2812fx1.init();
  ws2812fx1.setBrightness(100);
  ws2812fx1.setSpeed(1000);
  ws2812fx1.setColor(0x007BFF);
  ws2812fx1.setMode(FX_MODE_STATIC);
  ws2812fx1.start();

  ws2812fx2.init();
  ws2812fx2.setBrightness(100);
  ws2812fx2.setSpeed(1000);
  ws2812fx2.setColor(0x007BFF);
  ws2812fx2.setMode(FX_MODE_STATIC);
  ws2812fx2.start();
  
}

void loop() {
  now = millis();

  ws2812fx1.service();
  ws2812fx2.service();

  if(now - last_change > TIMER_MS) {
    ws2812fx1.setMode((ws2812fx1.getMode() + 1) % ws2812fx1.getModeCount());
    ws2812fx2.setMode((ws2812fx2.getMode() + 1) % ws2812fx2.getModeCount());
    last_change = now;
  }
}

Help would be very much appreciated. Thanks a lot!

BR
Leo

Oh, I just stumbled across this...
#273 (comment)
So it's a RAM problem. I'll switch to a ESP32 then..
Thanks.