Hi friends
Recently I bought this LED panel http://www.aliexpress.com/item…ED-module/1615047851.html and try to write a program with which I would be able to be controlled via ArtNet protocol and Jinx, I found this library https://github.com/pkourany/RGBmatrixPanel_IDE you want to use could anyone advise me how can this be done ?.
Here's the code that I started writing while but it does not work very well,
#include <Artnet.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <SPI.h>
#include <Adafruit_GFX.h> // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library
#define CLK 8 // MUST be on PORTB! (Use pin 11 on Mega)
#define LAT A3
#define OE 9
#define A A0
#define B A1
#define C A2
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);
const int numberOfChannels = 512 * 3; // Total number of channels you want to receive (1 led = 3 channels)
// Artnet settings
Artnet 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;
// Change ip and mac address for your setup
byte ip[] = {192, 168, 2, 100};
byte mac[] = {0x04, 0xE9, 0xE5, 0x00, 0x69, 0xEC};
void setup()
{
//Serial.begin(115200);
matrix.begin();
initTest();
artnet.begin(mac, ip);
// this will be called for each packet received
artnet.setArtDmxCallback(onDmxFrame);
}
void loop()
{
// we call the read function inside the loop
artnet.read();
matrix.fillScreen(0);
}
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)
{
}
// 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++)
for (uint8_t x=0; x < 32; x++)
for (uint8_t y=0; y < 16; y++)
{
int led = i + (universe - startUniverse) * (previousDataLength / 3);
if (led < 512)
matrix.drawPixel(x, y, matrix.Color888(data[i * 3], data[i * 3 + 1], data[i * 3 + 2]));
}
previousDataLength = length;
if (sendFrame)
{
// Reset universeReceived to 0
memset(universesReceived, 0, maxUniverses);
}
}
void initTest()
{
for (uint8_t x=0; x < 32; x++)
for (uint8_t y=0; y < 16; y++)
matrix.drawPixel(x, y, matrix.Color333(255, 0, 0));
delay(1000);
for (uint8_t x=0; x < 32; x++)
for (uint8_t y=0; y < 16; y++)
matrix.drawPixel(x, y, matrix.Color333(0, 255, 0));
delay(1000);
for (uint8_t x=0; x < 32; x++)
for (uint8_t y=0; y < 16; y++)
matrix.drawPixel(x, y, matrix.Color333(0, 0, 255));
delay(1000);
for (uint8_t x=0; x < 32; x++)
for (uint8_t y=0; y < 16; y++)
matrix.drawPixel(x, y, matrix.Color333(0, 0, 0));
delay(1000);
}