Advertisement
Guest User

Untitled

a guest
Sep 13th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. #define NUM_STRIPS 12
  2. #define UNIVERSE_SIZE 150
  3. #define NUM_LEDS_PER_STRIP 300
  4.  
  5.  
  6. const char* ssid = "mySSID";
  7. const char* password = "myPassword";
  8.  
  9.  
  10. CRGB aLeds[NUM_LEDS_PER_STRIP*NUM_STRIPS];
  11. ArtnetESP32 artnet;
  12.  
  13.  
  14. void displayfunction()
  15. {
  16. unsigned long timeBefore =0;
  17. unsigned long timeAfter =0;
  18. if (artnet.frameslues%100==0)
  19. Serial.printf("nb frames read: %d nb of incomplete frames:%d lost:%.2f %%\n",artnet.frameslues,artnet.lostframes,(float)(artnet.lostframes*100)/artnet.frameslues);
  20.  
  21. timeBefore = millis();
  22. FastLED.show();
  23. timeAfter = millis();
  24. Serial.print("time elapsed (ms) in FastLED.show():");
  25. Serial.println(timeAfter - timeBefore);
  26.  
  27. }
  28.  
  29.  
  30. void setup()
  31. {
  32. int counter = 0;
  33. Serial.begin(115200);
  34. WiFi.mode(WIFI_STA);
  35. Serial.printf("Connecting ");
  36. WiFi.begin(ssid, password);
  37. while (WiFi.status() != WL_CONNECTED) {
  38. Serial.println(WiFi.status());
  39. counter++;
  40. delay(500);
  41. Serial.print(".");
  42. Serial.print("Connecting to WiFi..attempt:");
  43. Serial.println (counter);
  44. if (counter > 20){
  45. ESP.restart();
  46. }
  47. }
  48.  
  49. Serial.println("");
  50. Serial.println("WiFi connected.");
  51. Serial.println("IP address: ");
  52. Serial.println(WiFi.localIP());
  53.  
  54. FastLED.addLeds<NEOPIXEL, 12>(aLeds,0,NUM_LEDS_PER_STRIP);
  55. FastLED.addLeds<NEOPIXEL, 13>(aLeds,NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
  56. FastLED.addLeds<NEOPIXEL, 14>(aLeds,2*NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
  57. FastLED.addLeds<NEOPIXEL, 15>(aLeds,3*NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
  58. FastLED.addLeds<NEOPIXEL, 16>(aLeds,4*NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
  59. FastLED.addLeds<NEOPIXEL, 17>(aLeds,5*NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
  60. FastLED.addLeds<NEOPIXEL, 18>(aLeds,6*NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
  61. FastLED.addLeds<NEOPIXEL, 19>(aLeds,7*NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
  62. FastLED.addLeds<NEOPIXEL, 21>(aLeds,8*NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
  63. FastLED.addLeds<NEOPIXEL, 22>(aLeds,9*NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
  64. FastLED.addLeds<NEOPIXEL, 23>(aLeds,10*NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
  65. FastLED.addLeds<NEOPIXEL, 25>(aLeds,11*NUM_LEDS_PER_STRIP,NUM_LEDS_PER_STRIP);
  66.  
  67. artnet.setFrameCallback(&displayfunction); //set the function that will be called back a frame has been received
  68. artnet.setLedsBuffer((uint8_t*)aLeds); //set the buffer to put the frame once a frame has been received
  69.  
  70. artnet.begin(NUM_LEDS_PER_STRIP*NUM_STRIPS,UNIVERSE_SIZE); //configure artnet
  71. }
  72.  
  73. void loop()
  74. {
  75. artnet.readFrame(); //ask to read a full frame
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement