Closed folny closed 8 years ago
Hi
Trying to neopixel code and the code does not work Can you tell me what's wrong or how I could change to make it work properly ?.
void loop() {
uint8_t i;
uint16_t packetSize = eUDP.parsePacket();
if ( packetSize ) {
packetSize = eUDP.read(packetBuffer, SACN_BUFFER_MAX);
uint8_t read_result = Universe0->readDMXPacketContents(eUDP, packetSize);
uint8_t read_result2 = 0;
if ( read_result == RESULT_DMX_RECEIVED ) {
// edge case test universe 1, slot 1
for (int p=0; p<8; p++) {
// for each NeoPixel find the slot number (each takes 3 slots for RGB)
i = 3*p;
// write to NeoPixel Driver
leds.setPixelColor(p, Universe0->getSlot(i+1), Universe0->getSlot(i+2), Universe0->getSlot(i+3));
}
// send to NeoPixel Ring
leds.show();
}
else if ( read_result == RESULT_NONE ) { // if not good dmx first universe (or art poll), try 2nd
read_result2 = Universe1->readDMXPacketContents(eUDP, packetSize);
if ( read_result2 == RESULT_DMX_RECEIVED ) {
// edge case test 2nd universe, slot 512
for (int p=8; p<16; p++) {
// for each NeoPixel find the slot number (each takes 3 slots for RGB)
i = 3*p;
// write to NeoPixel Driver
leds.setPixelColor(p, Universe1->getSlot(i+1), Universe1->getSlot(i+2), Universe1->getSlot(i+3));
}
// send to NeoPixel Ring
leds.show();
}
}
} }
As noted in the commit for the 2 Universe example, it is untested. Try the example with leds connected to pins 9 and 10 to see if the problem is with your NeoPixel code.
Yes with for example LED code works properly, not works only for neopixel code.
The code works in the following terms but it works very slowly, the problem will packetSize because the same code works correctly in library LXWiFiArtNet.
void loop() { uint16_t r,g,b; uint8_t i;
// read a packet and if the packet is dmx, write its data to the pixels
if ( Universe0->readDMXPacket(eUDP) ) {
for (int p=0; p<170; p++) {
// for each NeoPixel find the slot number (each takes 3 slots for RGB)
i = 3p;
r = Universe0->getSlot(i+1); // Red
g = Universe0->getSlot(i+2); // Green
b = Universe0->getSlot(i+3); // Blue
// gamma correct
r = (r_r)/255;
g = (g_g)/255;
b = (b_b)/255;
// write to NeoPixel Driver
ring.setPixelColor(p, r, g, b);
}
// send to NeoPixel Ring
ring.show();
}
if ( Universe1->readDMXPacket(eUDP) ) {
for (int p=170; p<340; p++) {
// for each NeoPixel find the slot number (each takes 3 slots for RGB)
i = 3_p;
r = Universe1->getSlot(i+1); // Red
g = Universe1->getSlot(i+2); // Green
b = Universe1->getSlot(i+3); // Blue
// gamma correct
r = (r_r)/255;
g = (g_g)/255;
b = (bb)/255;
// write to NeoPixel Driver
ring.setPixelColor(p, r, g, b);
}
// send to NeoPixel Ring
ring.show();
}
}
It is possible you have a pin conflict with one of the select lines for the ethernet shield. The two universe example is updated with a working NeoPixel test.
Hi
Please can add also the example 2 Universe because I'm not sure if I'm doing what I'm doing right thanks.