ESP32-HUB75-MatrixPanel-DMA: Stutter & freezing when adding wifi control.
Hi i’m having an issue on wifi where it works fine then it freezes it also seems to set the wrong pixels too. Ive attached a video and the code i’ve used.
I’ve adapted ArtNet to use these matrix panels.
#include <ArtnetWifi.h>
#include <Arduino.h>
#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
MatrixPanel_I2S_DMA matrix;
// Wifi settings
const char* ssid = "Reece-PC";
const char* password = "";
const int numLeds = 2048; // CHANGE FOR YOUR SETUP
const int numberOfChannels = numLeds * 3; // Total number of channels you want to receive (1 led = 3 channels)
// 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;
int matrixWidth = 64;
int matrixHeight = 32;
boolean ConnectWifi(void)
{
boolean state = true;
int i = 0;
WiFi.begin(ssid, password);
Serial.println("");
Serial.println("Connecting to WiFi");
// Wait for connection
Serial.print("Connecting");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
if (i > 20){
state = false;
break;
}
i++;
}
if (state){
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
} else {
Serial.println("");
Serial.println("Connection failed.");
}
return state;
}
int* computeLedPos(int ledNo)
{
int x = 0;
int y = 0;
for (int i = 0; i < ledNo; i++)
{
if(y = 32) {
++x;
y = 0;
}
++y;
}
static int cords[2];
cords[0] = x;
cords[1] = y;
return cords;
}
void initTest()
{
}
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){
int x = led % matrixWidth;
int y = led / matrixWidth;
//Serial.print("X: ");
//Serial.print(x);
//Serial.print("Y: ");
//Serial.print(y);
//Serial.print("R: ");
//Serial.print(data[i * 3]);
//Serial.print("G: ");
//Serial.print( data[i * 3 + 1]);
//Serial.print("B: ");
//Serial.print( data[i * 3 + 2]);
//Serial.println();
matrix.drawPixelRGB888(x, y, data[i * 3], data[i * 3 + 1], data[i * 3 + 2]);
//leds[led] = CRGB(data[i * 3], data[i * 3 + 1], data[i * 3 + 2]);
}
}
previousDataLength = length;
if (sendFrame)
{
matrix.fillScreen(0);
// Reset universeReceived to 0
memset(universesReceived, 0, maxUniverses);
}
}
void setup()
{
Serial.begin(115200);
ConnectWifi();
matrix.begin();
matrix.fillScreen(0);
artnet.begin();
initTest();
artnet.setArtDmxCallback(onDmxFrame);
}
void loop()
{
// we call the read function inside the loop
artnet.read();
}
Only a few pixels at the top are being set too that maybe me doing the wrong calculation however as the orignal example used FastLED which sets leds using:
leds[led] = CRGB(data[i * 3], data[i * 3 + 1], data[i * 3 + 2]);
And i do:
int x = led % matrixWidth; int y = led / matrixWidth; matrix.drawPixelRGB888(x, y, data[i * 3], data[i * 3 + 1], data[i * 3 + 2]);
Any help would be greatly appreicated.
https://user-images.githubusercontent.com/4342846/102909174-7a12a400-4470-11eb-9eca-b227002c78ab.mp4
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 22 (8 by maintainers)
I have updated the Glediator3 jar to make it much easier to use with the Arduino ESP32 TPM2_NET sketch. Literally three steps now.
https://github.com/mrfaptastic/Glediator3
https://user-images.githubusercontent.com/4342846/103111496-b3503d00-4645-11eb-846d-673eab387fd3.mp4
I can play doom on it now.
Merry Christmas by the way you two.