ESP 8266 + Neopixel

Bonjour à tous,
j'avais sollicité le forum pour un aide sur une carte ESP 8266 pour faire marcher des leds Neopixel. Grâce à vous j'ai pu bricoler un code pour gérer en temps réel par un autre logiciel (Max Msp) mes Leds. Pour info voici le Code (pas très propre mais fonctionnel à ce jour):



/*
  UDPSendReceive.pde:
  This sketch receives UDP message strings, prints them to the serial port
  and sends an "acknowledge" string back to the sender

  A Processing sketch is included at the end of file that can be used to send
  and received messages for testing with a computer.

  created 21 Aug 2010
  by Michael Margolis

  This code is in the public domain.

    https://github.com/kitesurfer1404/WS2812FX


*/
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1

#define LED_COUNT 47
#define NUMPIXELS 47
#define LED_PIN 2
#define PIN    2

// How many NeoPixels are attached to the Arduino?


Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

#include "SPI.h"
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>

#ifndef STASSID
#define STASSID "F4IDM_2T2L"
#define STAPSK "1234567890@"
#endif

#include <WS2812FX.h>

WS2812FX ws2812fx = WS2812FX(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

int MODE, M_BR, Ba1, Pa2, Va2, Ra2, Ba2,Pa3, Va3, Ra3, Ba3, Pa4, Va4, Ra4, Ba4;

int ja1, ja2, jb1, jb2, jc1, jc2, jd1, jd2;

int val1a, val2a, val3a, val1b, val2b, val3b, val1c, val2c, val3c, val4a, val4b, val4c;

int Col1, Col2 ;


unsigned int localPort = 7770;  // local port to listen on

// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE];  // buffer to hold incoming packet,

WiFiUDP Udp;
// Set your Static IP Address Settings
IPAddress local_IP(192, 168, 1, 110);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 0, 0);
IPAddress primaryDNS(8, 8, 8, 8); // this is optional
IPAddress secondaryDNS(8, 8, 4, 4); // this is optional

void setup() {
  Serial.begin(115200);
  // Print feedback if the settings are not configured
if (!WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS)) {
  Serial.println("STA Failed to configure");
}
  
  WiFi.begin(STASSID, STAPSK);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print('.');
    
    delay(500);
  }
  Serial.print("Connected! IP address: ");
  Serial.println(WiFi.localIP());
   
  
  Serial.printf("UDP server on port %d\n", localPort);
  Udp.begin(localPort);
  
  ws2812fx.init();
 // ws2812fx.setBrightness(2);
  ws2812fx.start();
  // segment 0 is the builtin comet effect
 // ws2812fx.setSegment(0, 0,           LED_COUNT - 1, FX_MODE_THEATER_CHASE  );
pixels.begin(); // This initializes the NeoPixel library.
 // Update LED contents, to start they are all 'off'



 
}


void loop() {
  // if there's data available, read a packet
  int packetSize = Udp.parsePacket();
  if (packetSize) {
    
    // read the packet into packetBufffer
    Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
    //Serial.println("Contents:");
   // Serial.println(packetBuffer);
  String   pacchetto = packetBuffer;
   // Create a new String object to be split

 
  String MODE_Int = splitString(pacchetto, ' ', 0);
  String M_BR_Int = splitString(pacchetto, ' ', 1);

 
 String a1 = splitString(pacchetto, ' ', 2);
 String a2 = splitString(pacchetto, ' ', 3);
 String a3 = splitString(pacchetto, ' ', 4);
 String a4 = splitString(pacchetto, ' ', 5);
 String a5 = splitString(pacchetto, ' ', 6);
 
 String b1 = splitString(pacchetto, ' ', 7); 
 String b2 = splitString(pacchetto, ' ', 8);
 String b3 = splitString(pacchetto, ' ', 9);
 String b4 = splitString(pacchetto, ' ', 10);
 String b5 = splitString(pacchetto, ' ', 11);

 String c1 = splitString(pacchetto, ' ', 12);
 String c2 = splitString(pacchetto, ' ', 13);
 String c3 = splitString(pacchetto, ' ', 14);
 String c4 = splitString(pacchetto, ' ', 15);
 String c5 = splitString(pacchetto, ' ', 16);

 String d1 = splitString(pacchetto, ' ', 17);
 String d2 = splitString(pacchetto, ' ', 18);
 String d3 = splitString(pacchetto, ' ', 19);
 String d4 = splitString(pacchetto, ' ', 20);
 String d5 = splitString(pacchetto, ' ', 21);

 
 String Col_1 = splitString(pacchetto, ' ', 22);
 String Col_2 = splitString(pacchetto, ' ', 23);


 ja1 = a1.toInt();
 ja2 = a2.toInt();
    val1a = a3.toInt();
    val1b = a4.toInt();
    val1c = a5.toInt();

jb1 = b1.toInt();
 jb2 = b2.toInt();
    val2a = b3.toInt();
    val2b = b4.toInt();
    val2c = b5.toInt();

jc1 = c1.toInt();
 jc2 = c2.toInt();
    val3a = c3.toInt();
    val3b = c4.toInt();
    val3c = c5.toInt();

jd1 = d1.toInt();
 jd2 = d2.toInt();
    val4a = d3.toInt();
    val4b= d4.toInt();
    val4c = d5.toInt();




MODE = MODE_Int.toInt();
M_BR = M_BR_Int.toInt();

Col1 = Col_1.toInt();
Col2 = Col_2.toInt();

 
    
if ((MODE) == 1) { 

{
       byte A;
       for (A = ja1 ; A < ja2; A++) {
          pixels.setPixelColor (A, pixels.Color ( val1a, val1b, val1c));
       }
}
{
        byte B;
       for (B = jb1 ; B < jb2; B++) {
          pixels.setPixelColor (B, pixels.Color ( val2a, val2b, val2c));
         }
      }
{
      byte C;
       for (C = jc1 ; C < jc2; C++) {
          pixels.setPixelColor (C, pixels.Color ( val3a, val3b, val3c));
         }
}   
  {    
        byte D;
        for (D = jd1 ; D < jd2; D++) {
          pixels.setPixelColor (D, val4a, val4b, val4c);
        }
      }
 
       
        
        pixels.show();   // Send the updated pixel colors to the hardware.
      
} 
     
 
    
    
      if ((MODE) == 2)  {
     if ((Col1) == 1)  {
     
 
         
          ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_THEATER_CHASE, BLUE , 20 );
          ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      
      if ((Col1) == 2 ) {
     
          ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_THEATER_CHASE, GREEN , 20 );
           ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
   if ((Col1) == 3) {
        
          ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_THEATER_CHASE, RED, 20  );
           ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 4) {
        
          ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_THEATER_CHASE, WHITE, 20  );
           ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 5) {
        
          ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_THEATER_CHASE, YELLOW , 20 );
           ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 6) {
        
          ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_THEATER_CHASE, CYAN , 20 );
           ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 7) {
        
          ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_THEATER_CHASE, MAGENTA, 20  );
           ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 8) {
        
          ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_THEATER_CHASE, PURPLE, 20  );
           ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 9) {
        
          ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_THEATER_CHASE, ORANGE , 20 );
           ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
          
      }
   
   
   
  ws2812fx.setBrightness(M_BR);
  ws2812fx.service();
 }



   if ((MODE) == 3)  {
   
      if ((Col1) == 1) {
         
           uint32_t colors[] = {BLUE, CYAN};
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_RUNNING_LIGHTS, colors , 20   );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 2) {
        
          uint32_t colors[] = {GREEN, RED};
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_RUNNING_LIGHTS, colors, 20   );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
   if ((Col1) == 3) {
        
          uint32_t colors[] = {RED, YELLOW};
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_RUNNING_LIGHTS, colors , 20  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 4) {
        
           uint32_t colors[] = {MAGENTA, PURPLE};
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_RUNNING_LIGHTS, colors, 20   );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 5) {
        
           uint32_t colors[] = {ORANGE, RED};
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_RUNNING_LIGHTS, colors , 20  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 6) {
        
           uint32_t colors[] = {WHITE, RED};
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_RUNNING_LIGHTS, colors , 20  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 7) {
        
          uint32_t colors[] = {PINK, RED};
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_RUNNING_LIGHTS, colors , 20  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 8) {
        
          uint32_t colors[] = {BLUE, RED};
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_RUNNING_LIGHTS, colors  , 20 );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 9) {
      
 
 ws2812fx.setSegment(0, 0,           (LED_COUNT/2)-1, FX_MODE_RUNNING_LIGHTS, COLORS(RED, WHITE) , 20);
ws2812fx.setSegment(1, LED_COUNT/2, LED_COUNT-1,     FX_MODE_RUNNING_LIGHTS, COLORS(GREEN, WHITE), 20);

      }
       if ((Col1) == 10) {
      
 
 ws2812fx.setSegment(0, 0,           (LED_COUNT/2)-1, FX_MODE_RUNNING_LIGHTS, COLORS(RED, GREEN) , 20);
ws2812fx.setSegment(1, LED_COUNT/2, LED_COUNT-1,     FX_MODE_RUNNING_LIGHTS, COLORS(GREEN, WHITE), 20);

      }
       if ((Col1) == 11) {
      
 
 ws2812fx.setSegment(0, 0,           (LED_COUNT/2)-1, FX_MODE_RUNNING_LIGHTS, COLORS(RED, WHITE) , 20);
ws2812fx.setSegment(1, LED_COUNT/2, LED_COUNT-1,     FX_MODE_RUNNING_LIGHTS, COLORS(GREEN, RED), 20);

      }
       if ((Col1) == 12) {
      
 
 ws2812fx.setSegment(0, 0,           (LED_COUNT/2)-1, FX_MODE_RUNNING_LIGHTS, COLORS(GREEN, RED) , 20);
ws2812fx.setSegment(1, LED_COUNT/2, LED_COUNT-1,     FX_MODE_RUNNING_LIGHTS, COLORS(RED, WHITE), 20);

      }
  
  ws2812fx.setBrightness(M_BR);
  ws2812fx.service();

}
if ((MODE) == 4)  {
   
      if ((Col1) == 1) {
         ws2812fx.init();
          
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_TWINKLE_FADE, BLUE , 20  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 2) {
        ws2812fx.init();
       
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_TWINKLE_FADE, GREEN  , 20 );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
   if ((Col1) == 3) {
        ws2812fx.init();
       
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_TWINKLE_FADE, RED  , 20 );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 4) {
        ws2812fx.init();
          
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_TWINKLE_FADE, CYAN , 20  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 5) {
          ws2812fx.init();
           
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_TWINKLE_FADE, ORANGE , 20  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 6) {
          ws2812fx.init();
          
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_TWINKLE_FADE, ULTRAWHITE , 20  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 7) {
          ws2812fx.init();
         
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_TWINKLE_FADE, PINK  , 20 );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 8) {
          ws2812fx.init();
    
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_TWINKLE_FADE, PURPLE , 20  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 9) {
        ws2812fx.init();
 uint32_t colors[] = {PINK, WHITE};
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_TWINKLE_FADE, MAGENTA  , 20 );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
  
  ws2812fx.setBrightness(M_BR);
  ws2812fx.service();

}
if ((MODE) == 5)  {
   
      if ((Col1) == 1) {
         ws2812fx.init();
          
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_HYPER_SPARKLE, BLUE, 20   );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 2) {
        ws2812fx.init();
       
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_HYPER_SPARKLE, GREEN  , 20 );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
   if ((Col1) == 3) {
        ws2812fx.init();
       
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_HYPER_SPARKLE, RED  , 20 );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 4) {
        ws2812fx.init();
          
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_HYPER_SPARKLE, CYAN   , 20);
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 5) {
          ws2812fx.init();
           
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_HYPER_SPARKLE, ORANGE  , 20 );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 6) {
          ws2812fx.init();
          
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_HYPER_SPARKLE, ULTRAWHITE , 20  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 7) {
          ws2812fx.init();
         
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_HYPER_SPARKLE, PINK , 20  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 8) {
          ws2812fx.init();
    
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_HYPER_SPARKLE, PURPLE, 20   );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 9) {
        ws2812fx.init();

  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_HYPER_SPARKLE, MAGENTA  , 20 );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
  
  ws2812fx.setBrightness(M_BR);
  ws2812fx.service();

}
if ((MODE) == 6)  {
   
      if ((Col1) == 1) {
     
          
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_STROBE, BLUE , 20  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 2) {
   
       
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_STROBE, GREEN , 20  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
   if ((Col1) == 3) {
    
       
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_STROBE, RED , 20  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 4) {
     
          
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_STROBE, CYAN , 20  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 5) {
     
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_STROBE, ORANGE , 20  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 6) {
        
          
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_STROBE, ULTRAWHITE , 20  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 7) {
         
         
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_STROBE, PINK , 20  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 8) {
      
    
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_STROBE, PURPLE , 20  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 9) {
 

  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_STROBE, MAGENTA , 20  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
  
  ws2812fx.setBrightness(M_BR);
  ws2812fx.service();

}
if ((MODE) == 7)  {
   
      if ((Col1) == 1) {
     
          
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_LARSON_SCANNER, BLUE , 1   );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 2) {
   
       
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_LARSON_SCANNER, GREEN , 1  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
   if ((Col1) == 3) {
    
       
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_LARSON_SCANNER, RED , 1);
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 4) {
     
          
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_LARSON_SCANNER, CYAN , 1 );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 5) {
     
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_LARSON_SCANNER, ORANGE , 1  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 6) {
        
          
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_LARSON_SCANNER, ULTRAWHITE , 1  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 7) {
         
         
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_LARSON_SCANNER, PINK , 1  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 8) {
      
    
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_LARSON_SCANNER, PURPLE , 1);
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 9) {
 

  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_LARSON_SCANNER, MAGENTA , 1  );
   ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }

      if ((Col1) == 10) {
 

  ws2812fx.setSegment(0, 0, (LED_COUNT/2) - 1, FX_MODE_LARSON_SCANNER, CYAN , 1  );
  ws2812fx.setSegment(1, LED_COUNT/2, LED_COUNT-1,     FX_MODE_LARSON_SCANNER, CYAN, 1, reverse);
      }
  
  ws2812fx.setBrightness(M_BR);
  ws2812fx.service();

}
if ((MODE) == 8)  {
   
      if ((Col1) == 1) {
     
          
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_FIREWORKS, BLUE , 1   );
     ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 2) {
   
       
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_FIREWORKS, GREEN , 1  );
     ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
   if ((Col1) == 3) {
    
       
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_FIREWORKS, RED , 1);
     ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
     
      if ((Col1) == 4) {
     
          
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_FIREWORKS, CYAN , 1 );
     ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 5) {
     
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_FIREWORKS, ORANGE , 1  );
     ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 6) {
        
          
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_FIREWORKS, ULTRAWHITE , 1  );
     ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 7) {
         
         
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_FIREWORKS, PINK , 1  );
     ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 8) {
      
    
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_FIREWORKS, PURPLE , 1);
     ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 9) {
 

  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_FIREWORKS, MAGENTA , 1  );
     ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }

      
  
  ws2812fx.setBrightness(M_BR);
  ws2812fx.service();

}
if ((MODE) == 9)  {
   
      if ((Col1) == 1) {
     
          
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_FIRE_FLICKER_INTENSE, BLUE , 1   );
     ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 2) {
   
       
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_FIRE_FLICKER_INTENSE, GREEN , 1  );
     ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
   if ((Col1) == 3) {
    
       
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_FIRE_FLICKER_INTENSE, RED , 1);
     ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 4) {
     
          
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_FIRE_FLICKER_INTENSE, CYAN , 1 );
     ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 5) {
     
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_FIRE_FLICKER_INTENSE, ORANGE , 1  );
     ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 6) {
        
          
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_FIRE_FLICKER_INTENSE, ULTRAWHITE , 1  );
     ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 7) {
         
         
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_FIRE_FLICKER_INTENSE, PINK , 1  );
     ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 8) {
      
    
  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_FIRE_FLICKER_INTENSE, PURPLE , 1);
     ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }
      if ((Col1) == 9) {
 

  ws2812fx.setSegment(0, 0, LED_COUNT - 1, FX_MODE_FIRE_FLICKER_INTENSE, MAGENTA , 1  );
     ws2812fx.setSegment(1, LED_COUNT +1, LED_COUNT +2);
      }

      
  
  ws2812fx.setBrightness(M_BR);
  ws2812fx.service();

}
if ((MODE) == 10)  {
   
      if ((Col1) == 1) {
     
  uint32_t colors[] = {RED, GREEN, WHITE};
  ws2812fx.setSegment(0, 0,           LED_COUNT - 1, FX_MODE_TRICOLOR_CHASE, colors, 200   , true  );
      }
      if ((Col1) == 2) {
   
       
  uint32_t colors[] = {BLUE, RED, WHITE};
  ws2812fx.setSegment(0, 0,           LED_COUNT - 1, FX_MODE_TRICOLOR_CHASE, colors, 200   , true  );
      }      
  
  ws2812fx.setBrightness(M_BR);
  ws2812fx.service();

}

  }
  delay (20);
}
  
String splitString(String str, char sep, int index)
{
 int found = 0;
 int strIdx[] = { 0, -1 };
 int maxIdx = str.length() - 1;

 for (int i = 0; i <= maxIdx && found <= index; i++)
 {
    if (str.charAt(i) == sep || i == maxIdx)
    {
      found++;
      strIdx[0] = strIdx[1] + 1;
      strIdx[1] = (i == maxIdx) ? i+1 : i;
    }
 }
 return found > index ? str.substring(strIdx[0], strIdx[1]) : "";
}
uint16_t myCustomEffect(void) { // random chase
  WS2812FX::Segment* seg = ws2812fx.getSegment(); // get the current segment
  for(uint16_t i=seg->stop; i>seg->start; i--) {
    ws2812fx.setPixelColor(i, ws2812fx.getPixelColor(i-1));
  }
  uint32_t color = ws2812fx.getPixelColor(seg->start + 1);
  int r = random(6) != 0 ? (color >> 16 & 0xFF) : random(256);
  int g = random(6) != 0 ? (color >> 8  & 0xFF) : random(256);
  int b = random(6) != 0 ? (color       & 0xFF) : random(256);
  ws2812fx.setPixelColor(seg->start, r, g, b);
  return seg->speed; // return the delay until the next animation step (in msec)
}
  

J'ai deux petits soucis:

  1. je suis obligé de déconnecter les Leds au démarrage de ma carte car sinon ça ne marche pas et les brancher après avoir mis sous tension mon ESP 8266. Je n'ai pas trouvé d'autres solution à ce jour ...
  2. de temps en temps certains modules se déconnectent. Pour info j'alimente les carte et les Leds avec des batteries de téléphone 5V 2.0A et deux modules directement avec des alimentateur 5V 3A. J'ai environs une dizaine de modules sur des adresses IP séparés. Chaque module a entre 30 et 140 Leds et j'envoie des trames au plus vite tous les 25 ms .

Si vous avez des suggestions je vous remercie d'avance de votre aide.
Claudio

Bonjour, j'utilise Google Translate ici, quelques conseils pour vous.

Le choix de la broche de sortie est ici en cause. Selon la façon dont vous connectez la barrette, GPIO 2 ne peut pas être mis en position BAS au démarrage (pas plus que GPIO 0 et 1) ou le mauvais mode de démarrage sera sélectionné.

Cela est probablement dû à la méthode de sortie. Adafruit_neopixel.h utilise une méthode bit-banged pour créer le signal et désactive même les interruptions, ce qui rend le WiFi instable,
Pour les ESP, je recommande plutôt Makuna Neopixelbus comme bibliothèque, et la méthode I2s (DMA) par défaut en particulier. Celui-ci utilisera GPIO 3 (rx) comme broche de sortie et est 100 % stable en combinaison avec le WiFi.

Merci beaucoup Deva_Rishi,
maintenant pas de souci au démarrage ! Ça marche parfaitement :partying_face:
Je vais travailler sur la nouvelle bibliothèque.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.