/*
All credits to :
Shelby Merrick for his E131
&
Michael Miller for the NeoPixel_Bus
E131_Test.ino - Simple sketch to listen for E1.31 data on an ESP32
and print some statistics.
Project: ESPAsyncE131 - Asynchronous E.131 (sACN) library for Arduino ESP8266 and ESP32
Copyright (c) 2019 Shelby Merrick
http://www.forkineye.com
NeoPixelTest
https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
*/
#include <ESPAsyncE131.h>
#include <NeoPixelBus.h>
#include <WiFi.h>
#define UNIVERSE 1 // First DMX Universe to listen for
#define UNIVERSE_COUNT 12
#define CHANNEL_START 1
#define CHANNEL_START_B 1
#define CHANNEL_START_C 1
#define CHANNEL_START_D 1
#define CHANNEL_START_E 1
#define CHANNEL_START_F 1
#define CHANNEL_START_G 1
#define CHANNEL_START_H 1
#define CHANNEL_START_I 1
#define CHANNEL_START_J 1
#define CHANNEL_START_K 1
#define CHANNEL_START_L 1
const uint16_t PixelCount1 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin1 = 23; // make sure to set this to the correct pin, ignored for Esp8266
const uint16_t PixelCount2 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin2 = 22; // make sure to set this to the correct pin, ignored for Esp8266
const uint16_t PixelCount3 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin3 = 21; // make sure to set this to the correct pin, ignored for Esp8266
const uint16_t PixelCount4 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin4 = 19; // make sure to set this to the correct pin, ignored for Esp8266
const uint16_t PixelCount5 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin5 = 18; // make sure to set this to the correct pin, ignored for Esp8266
const uint16_t PixelCount6 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin6 = 17; // make sure to set this to the correct pin, ignored for Esp8266
const uint16_t PixelCount7 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin7 = 4; // make sure to set this to the correct pin, ignored for Esp8266
const uint16_t PixelCount8 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin8 = 15; // make sure to set this to the correct pin, ignored for Esp8266
const uint16_t PixelCount9 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin9 = 0; // make sure to set this to the correct pin, ignored for Esp8266
const uint16_t PixelCount10 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin10 = 16; // make sure to set this to the correct pin, ignored for Esp8266
const uint16_t PixelCount11 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin11 = 27; // make sure to set this to the correct pin, ignored for Esp8266
const uint16_t PixelCount12 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin12 = 25; // make sure to set this to the correct pin, ignored for Esp8266
const char ssid[] = "SSID"; // Replace with your SSID
const char passphrase[] = "PASSWORD"; // Replace with your WPA2 passphrase
// ESPAsyncE131 instance with UNIVERSE_COUNT buffer slots
ESPAsyncE131 e131(12);
NeoPixelBus<NeoGrbFeature, NeoEsp32Rmt0800KbpsMethod> strip1(PixelCount1, PixelPin1);
NeoPixelBus<NeoGrbFeature, NeoEsp32Rmt1800KbpsMethod> strip2(PixelCount2, PixelPin2);
NeoPixelBus<NeoGrbFeature, NeoEsp32Rmt2800KbpsMethod> strip3(PixelCount3, PixelPin3);
NeoPixelBus<NeoGrbFeature, NeoEsp32Rmt3800KbpsMethod> strip4(PixelCount4, PixelPin4);
NeoPixelBus<NeoGrbFeature, NeoEsp32Rmt4800KbpsMethod> strip5(PixelCount5, PixelPin5);
NeoPixelBus<NeoGrbFeature, NeoEsp32Rmt5800KbpsMethod> strip6(PixelCount6, PixelPin6);
NeoPixelBus<NeoGrbFeature, NeoEsp32Rmt6800KbpsMethod> strip7(PixelCount7, PixelPin7);
NeoPixelBus<NeoGrbFeature, NeoEsp32Rmt7800KbpsMethod> strip8(PixelCount8, PixelPin8);
NeoPixelBus<NeoGrbFeature, NeoEsp32BitBang800KbpsMethod> strip9(PixelCount9, PixelPin9);
NeoPixelBus<NeoGrbFeature, NeoEsp32BitBang800KbpsMethod> strip10(PixelCount10, PixelPin10);
NeoPixelBus<NeoGrbFeature, NeoEsp32BitBang800KbpsMethod> strip11(PixelCount11, PixelPin11);
NeoPixelBus<NeoGrbFeature, NeoEsp32BitBang800KbpsMethod> strip12(PixelCount12, PixelPin12);
void setup() {
Serial.begin(115200);
delay(10);
// Make sure you're in station mode
WiFi.mode(WIFI_STA);
Serial.println("");
Serial.print(F("Connecting to "));
Serial.print(ssid);
if (passphrase != NULL)
WiFi.begin(ssid, passphrase);
else
WiFi.begin(ssid);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print(F("Connected with IP: "));
Serial.println(WiFi.localIP());
// this resets all the neopixels to an off state
strip1.Begin();
strip1.Show();
strip2.Begin();
strip2.Show();
strip3.Begin();
strip3.Show();
strip4.Begin();
strip4.Show();
strip5.Begin();
strip5.Show();
strip6.Begin();
strip6.Show();
strip7.Begin();
strip7.Show();
strip8.Begin();
strip8.Show();
strip9.Begin();
strip9.Show();
strip10.Begin();
strip10.Show();
strip11.Begin();
strip11.Show();
strip12.Begin();
strip12.Show();
// Choose one to begin listening for E1.31 data
//if (e131.begin(E131_UNICAST)); // Listen via Unicast
if (e131.begin(E131_MULTICAST, UNIVERSE, UNIVERSE_COUNT)); // Listen via Multicast
}
void loop() {
// Parse a packet and update pixels
while (!e131.isEmpty()) {
e131_packet_t packet;
e131.pull(&packet); // Pull packet from ring buffer
uint16_t universe = htons(packet.universe);
if (universe == 1) {
for (int i = 0; i < PixelCount1; i++) {
int j = i * 3 + (CHANNEL_START);
strip1.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j] );
}
strip1.Show();
}
if (universe == 2) {
for (int i = 0; i < PixelCount2; i++) {
int j = i * 3 + (CHANNEL_START_B);
strip2.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j + 1] );
}
strip2.Show();
}
if (universe == 3) {
for (int i = 0; i < PixelCount3; i++) {
int j = i * 3 + (CHANNEL_START_C);
strip3.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j + 1] );
}
strip3.Show();
}
if (universe == 4) {
for (int i = 0; i < PixelCount4; i++) {
int j = i * 3 + (CHANNEL_START_D);
strip4.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j + 1] );
}
strip4.Show();
}
if (universe == 5) {
for (int i = 0; i < PixelCount5; i++) {
int j = i * 3 + (CHANNEL_START_E);
strip5.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j + 1] );
}
strip5.Show();
}
if (universe == 6) {
for (int i = 0; i < PixelCount6; i++) {
int j = i * 3 + (CHANNEL_START_F);
strip6.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j + 1] );
}
strip6.Show();
}
if (universe == 7) {
for (int i = 0; i < PixelCount7; i++) {
int j = i * 3 + (CHANNEL_START_G);
strip7.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j + 1] );
}
strip7.Show();
}
if (universe == 8) {
for (int i = 0; i < PixelCount8; i++) {
int j = i * 3 + (CHANNEL_START_H);
strip8.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j + 1] );
}
strip8.Show();
}
if (universe == 9) {
for (int i = 0; i < PixelCount9; i++) {
int j = i * 3 + (CHANNEL_START_I);
strip9.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j + 1] );
}
strip9.Show();
}
if (universe == 10) {
for (int i = 0; i < PixelCount10; i++) {
int j = i * 3 + (CHANNEL_START_J);
strip10.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j + 1] );
}
strip10.Show();
}
if (universe == 11) {
for (int i = 0; i < PixelCount11; i++) {
int j = i * 3 + (CHANNEL_START_K);
strip11.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j + 1] );
}
strip11.Show();
}
if (universe == 12) {
for (int i = 0; i < PixelCount12; i++) {
int j = i * 3 + (CHANNEL_START_L);
strip12.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j + 1] );
}
strip12.Show();
}
}
}