Jinx! artnet to Esp32 with 4 parallel output

Alex_cv
Posts: 2
Joined: Mon Mar 23, 2020 1:11 pm

Jinx! artnet to Esp32 with 4 parallel output

Postby Alex_cv » Mon Mar 23, 2020 1:37 pm

I ask for help.
There is a bunch of Jinx! (PC) to ESP32 (Devkit V1).
An access point has been created on the ESP, the PC is connected to it.
First, the connection (Code 1) to the matrix with 462 LEDs. Everything almost works fine, sometimes it slows down.
When I increase the number of LEDs by 4 times, I create 4 parallel outputs in the code. (Code 2).
Change settings in Jinx! on the required number of LEDs.
There is a very unstable work, frequent freezing.
I ask for your help. What could be the problem?

Code 1

Code: Select all

#include <ArtnetWifi.h>
#include <Arduino.h>
#include <FastLED.h>

// Wifi Настройки
const char* ssid = "AAA";
const char* password = "12345678";
WiFiServer server(80);

// LED Настройи

const int numLeds = 462; // 22*21
const int numberOfChannels = numLeds * 3; // Total number of channels you want to receive (1 led = 3 channels)
const byte dataPin = 2;
CRGB leds[numLeds];

// Art-Net settings
ArtnetWifi artnet;
const int startUniverse = 0; // CHANGE FOR YOUR SETUP most software this is 1, some software send out artnet first universe as 0.

// Check if we got all universes
const int maxUniverses = numberOfChannels / 512 + ((numberOfChannels % 512) ? 1 : 0);
bool universesReceived[maxUniverses];
bool sendFrame = 1;
int previousDataLength = 0;
// connect to wifi – returns true if successful or false if not


void onDmxFrame(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t* data)
{
  sendFrame = 1;
  // set brightness of the whole strip
  if (universe == 15)
  {
    FastLED.setBrightness(data[0]);
    FastLED.show();
  }

  // Store which universe has got in
  if ((universe - startUniverse) < maxUniverses) {
    universesReceived[universe - startUniverse] = 1;
  }

  for (int i = 0 ; i < maxUniverses ; i++)
  {
    if (universesReceived[i] == 0)
    {
      //Serial.println("Broke");
      sendFrame = 0;
      break;
    }
  }

  // read universe and put into the right part of the display buffer
  for (int i = 0; i < length / 3; i++)
  {
    int led = i + (universe - startUniverse) * (previousDataLength / 3);
    if (led < numLeds)
      leds[led] = CRGB(data[i * 3], data[i * 3 + 1], data[i * 3 + 2]);
  }
  previousDataLength = length;

  if (sendFrame)
  {
    FastLED.show();
    // Reset universeReceived to 0
    memset(universesReceived, 0, maxUniverses);
  }
}

void setup()
{
  Serial.begin(115200);
 WiFi.softAP(ssid, password);
  IPAddress myIP = WiFi.softAPIP();
   server.begin();

  Serial.println("Server started");
  artnet.begin();
  
  FastLED.addLeds<WS2812, dataPin, GRB>(leds, numLeds);


  // this will be called for each packet received
  artnet.setArtDmxCallback(onDmxFrame);
}

void loop()
{ WiFiClient client = server.available();
  // we call the read function inside the loop
  artnet.read();
}


Code 2

Code: Select all

#include <ArtnetWifi.h>
#include <Arduino.h>
#include <FastLED.h>
// Wifi settings
const char* ssid = "AAA";
const char* password = "12345678";

WiFiServer server(80);
// LED settings

const int numLeds = 1848; // 22*21*4
const int numberOfChannels = numLeds * 3; // Total number of channels you want to receive (1 led = 3 channels)
CRGB leds[numLeds];

// Art-Net settings
ArtnetWifi artnet;
const int startUniverse = 0; // CHANGE FOR YOUR SETUP most software this is 1, some software send out artnet first universe as 0.

const int maxUniverses = numberOfChannels / 512 + ((numberOfChannels % 512) ? 1 : 0);
bool universesReceived[maxUniverses];
bool sendFrame = 1;
int previousDataLength = 0;

const byte PIN1 = 2  ; 
const byte PIN2 = 4  ;  
const byte PIN3 = 5  ;
const byte PIN4 = 18 ; 

// connect to wifi – returns true if successful or false if not

void onDmxFrame(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t* data)
{
  sendFrame = 1;
  // set brightness of the whole strip
  if (universe == 15)
  {    FastLED.setBrightness(data[0]);
    FastLED.show();  }
  // Store which universe has got in
  if ((universe - startUniverse) < maxUniverses) {
    universesReceived[universe - startUniverse] = 1;
  }
  for (int i = 0 ; i < maxUniverses ; i++)
  {
    if (universesReceived[i] == 0)
    {
      //Serial.println("Broke");
      sendFrame = 0;
      break;
    }
  }
  // read universe and put into the right part of the display buffer
  for (int i = 0; i < length / 3; i++)
  {
    int led = i + (universe - startUniverse) * (previousDataLength / 3);
    if (led < numLeds)
      leds[led] = CRGB(data[i * 3], data[i * 3 + 1], data[i * 3 + 2]);
  }
  previousDataLength = length;

  if (sendFrame)
  {
    FastLED.show();
    // Reset universeReceived to 0
    memset(universesReceived, 0, maxUniverses);
  }
}

void setup()
{
  Serial.begin(115200);
 WiFi.softAP(ssid, password, 10, 0, 2);
  IPAddress myIP = WiFi.softAPIP();
   server.begin();
  Serial.println("Server started");
  
  artnet.begin();

  FastLED.addLeds<WS2812,  PIN1,  GRB>(leds, 0, 462);
  FastLED.addLeds<WS2812,  PIN2, GRB>(leds, 462, 462);
  FastLED.addLeds<WS2812,  PIN3, GRB>(leds, 924, 462);
  FastLED.addLeds<WS2812,  PIN4, GRB>(leds, 1386, 462);
FastLED.show();


  // this will be called for each packet received
 artnet.setArtDmxCallback(onDmxFrame);
}

void loop()
{ WiFiClient client = server.available();
  // we call the read function inside the loop
  artnet.read();

}

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: Jinx! artnet to Esp32 with 4 parallel output

Postby ESP_Sprite » Mon Mar 23, 2020 5:28 pm

Moving to Arduino subforum.

Who is online

Users browsing this forum: No registered users and 53 guests