natcl / Artnet

An Art-Net library for Teensy, Arduino and ESP boards
Other
334 stars 91 forks source link

WS2812B Neopixel example only works with 155Leds #66

Open Gabriel-Graf opened 4 months ago

Gabriel-Graf commented 4 months ago

Hi,

Firstly, thank you for sharing this awesome library. It's the only library that has worked for me so far!

In my setup, I am using an Arduino Nano with a W5500 Lite shield. I have attached a small LED strip with 49 LEDs to it, and it works fine. I want to try to maximize the output of a single output of the Nano and test the boundaries of this library. When I try to send more data, let's say 147 LEDs, this also works fine. However, when I increase the number a little bit more, the maximum number of LEDs seems to be 155. If I go over 155, the animation stops for all LEDs, and nothing is displayed anymore.

I modified the Neopixel example with some more prints, and I am trying to send 3 universes, and each one gets received. However, I can only display 155 LEDs even though there are more than 500 LEDs across 3 universes.

I can't wrap my head around this, and I am hoping you guys have an idea.

`

include

include

include

/*

include

include

// Neopixel settings const int numLeds = 155; // change for your setup const int channelsPerLed = 3; const int numberOfChannels = numLeds * channelsPerLed; // Total number of channels you want to receive (1 led = 3 channels) const byte dataPin = 8; Adafruit_NeoPixel leds = Adafruit_NeoPixel(numLeds, dataPin, NEO_GRB + NEO_KHZ800);

// Artnet settings Artnet artnet; const int startUniverse = 0; // CHANGE FOR YOUR SETUP most software this is 1, some software send out artnet first universe as 0. const int spi_cs = 5; // Check if we got all universes const int maxUniverses = 3; //numberOfChannels / 512 + ((numberOfChannels % 512) ? 1 : 0); bool universesReceived[maxUniverses]; bool sendFrame = 1; int previousDataLength = 0;

// Change ip and mac address for your setup byte ip[] = {192, 168, 178, 199}; byte mac[] = {0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02}; byte broadcast[] = {192, 168, 178, 255};

void setup() { initTest();

Serial.begin(115200); Ethernet.init(spi_cs); // Most Arduino shields artnet.begin(mac, ip); leds.begin(); artnet.setBroadcast(broadcast);

// this will be called for each packet received artnet.setArtDmxCallback(onDmxFrame); }

void loop() { // we call the read function inside the loop artnet.read(); }

void onDmxFrame(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t* data, IPAddress remoteIP) {

sendFrame = 1;

// Store which universe has got in if ((universe - startUniverse) < maxUniverses) universesReceived[universe - startUniverse] = 1;

// sets flag that all universes got read out for (int i = 0 ; i < maxUniverses ; i++) { if (universesReceived[i] == 0) { sendFrame = 0; break; } }

//set_all_leds_black();

int led; // read universe and put into the right part of the display buffer for (int i = 0; i < length / channelsPerLed; i++) { led = i + (universe - startUniverse) (previousDataLength / channelsPerLed); if (led < numLeds) { if (channelsPerLed == 4) leds.setPixelColor(led, data[i channelsPerLed], data[i channelsPerLed + 1], data[i channelsPerLed + 2], data[i channelsPerLed + 3]); if (channelsPerLed == 3) leds.setPixelColor(led, data[i channelsPerLed], data[i channelsPerLed + 1], data[i channelsPerLed + 2]); } } Serial.print("led_count: "); Serial.print(led);

Serial.print(" universe: "); Serial.print(universe);

Serial.print(" Maxuniverse: "); Serial.print(maxUniverses);

Serial.print(" Number of LEDs: "); Serial.print(numLeds);

Serial.print(" rec_arr_length: "); Serial.println(length);

// Serial.print("Received DMX data: "); // printArray(data, length);

previousDataLength = length;

if (sendFrame) { leds.show(); Serial.println("show"); // Reset universeReceived to 0 memset(universesReceived, 0, maxUniverses); } }

`