Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define NUM_STRIPS 12
- #define UNIVERSE_SIZE 150
- #define NUM_LEDS_PER_STRIP 300
- const char* ssid = "mySSID";
- const char* password = "myPassword";
- CRGB aLeds[NUM_LEDS_PER_STRIP*NUM_STRIPS];
- ArtnetESP32 artnet;
- void displayfunction()
- {
- unsigned long timeBefore =0;
- unsigned long timeAfter =0;
- if (artnet.frameslues%100==0)
- Serial.printf("nb frames read: %d nb of incomplete frames:%d lost:%.2f %%\n",artnet.frameslues,artnet.lostframes,(float)(artnet.lostframes*100)/artnet.frameslues);
- timeBefore = millis();
- FastLED.show();
- timeAfter = millis();
- Serial.print("time elapsed (ms) in FastLED.show():");
- Serial.println(timeAfter - timeBefore);
- }
- void setup()
- {
- int counter = 0;
- Serial.begin(115200);
- WiFi.mode(WIFI_STA);
- Serial.printf("Connecting ");
- WiFi.begin(ssid, password);
- while (WiFi.status() != WL_CONNECTED) {
- Serial.println(WiFi.status());
- counter++;
- delay(500);
- Serial.print(".");
- Serial.print("Connecting to WiFi..attempt:");
- Serial.println (counter);
- if (counter > 20){
- ESP.restart();
- }
- }
- Serial.println("");
- Serial.println("WiFi connected.");
- Serial.println("IP address: ");
- Serial.println(WiFi.localIP());
- FastLED.addLeds<NEOPIXEL, 12>(aLeds,0,NUM_LEDS_PER_STRIP);
- FastLED.addLeds<NEOPIXEL, 13>(aLeds,NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
- FastLED.addLeds<NEOPIXEL, 14>(aLeds,2*NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
- FastLED.addLeds<NEOPIXEL, 15>(aLeds,3*NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
- FastLED.addLeds<NEOPIXEL, 16>(aLeds,4*NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
- FastLED.addLeds<NEOPIXEL, 17>(aLeds,5*NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
- FastLED.addLeds<NEOPIXEL, 18>(aLeds,6*NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
- FastLED.addLeds<NEOPIXEL, 19>(aLeds,7*NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
- FastLED.addLeds<NEOPIXEL, 21>(aLeds,8*NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
- FastLED.addLeds<NEOPIXEL, 22>(aLeds,9*NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
- FastLED.addLeds<NEOPIXEL, 23>(aLeds,10*NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
- FastLED.addLeds<NEOPIXEL, 25>(aLeds,11*NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
- artnet.setFrameCallback(&displayfunction); //set the function that will be called back a frame has been received
- artnet.setLedsBuffer((uint8_t*)aLeds); //set the buffer to put the frame once a frame has been received
- artnet.begin(NUM_LEDS_PER_STRIP*NUM_STRIPS,UNIVERSE_SIZE); //configure artnet
- }
- void loop()
- {
- artnet.readFrame(); //ask to read a full frame
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement