Beiträge von folny

    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);
    }


    Seddi


    Thank you for your advice is bad enough that each device has a limited MTU 1500 when I changed the MTU in Windows using software SG TCP optimizer I could control up to 507 LEDs

    There is no limit inside Jinx! for tpm2(net) channels. But as tpm2.net is network based you should try to use a smaller blocksize in the tpm2.net output, because sending 1466 channels in one network packet will result in fragmented packets on the network and most of the small tcpip stacks for microcontroller will not handle fragmented packets. Thats why a block size is implemented into tpm2.net, this has nothing directly to do with Jinx!.
    If your implementation supports multiple blocks, you have to try or ask the author. It is cleanly defined inside the protocol for the given reasons. As far as I remember, we got good results by using a block size around 800channels with a SEDU3.Seddi Thank you for your answer but I would like to ask how I should set up another 512 to control the LEDs because I set Channels to 1536 and Chan / Block then automatically get 1 Block rightly so ?.


    //edit
    Looked into the source code, you linked. Seems like there are no multible blocks supported, like defined in the specs. So with this implementation, you will not be able to use a channel size that will break your mtu size (including protocol and udp overhead).


    Seddi Thank you for your answer but I would like to ask how I should set up another 512 to control the LEDs because I set Channels to 1536 and Chan / Block then automatically get 1 Block rightly so ?.

    Hello Ottmar


    Thank you for your help looks like everything is already alright I tried to edit the sketch to work with FastLed library but it failed me please you if you look at it and say how I should do to make it work properly.


    #include <Artnet.h>
    #include <Ethernet.h>
    #include <EthernetUdp.h>
    #include <SPI.h>
    #include "FastLED.h"


    const int ledsPerStrip = 170; // change for your setup
    const byte numStrips= 4; // change for your setup
    DMAMEM int displayMemory[ledsPerStrip*6];
    int drawingMemory[ledsPerStrip*6];
    CRGB leds[ledsPerStrip];


    // 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 zero.
    const int numberOfChannels = ledsPerStrip * numStrips * 3; // Total number of channels you want to receive (1 led = 3 channels)
    byte channelBuffer[numberOfChannels]; // Combined universes into a single array


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


    byte ip[] = {192, 168, 2, 9};
    byte mac[] = {0x04, 0xE9, 0xE5, 0x00, 0x69, 0xEC};


    void setup(){

    FastLED.addLeds<WS2812B, 2, GRB>(leds, ledsPerStrip);

    Serial.begin(115200);
    artnet.begin(mac, ip);


    artnet.setArtDmxCallback(onDmxFrame);
    }


    void loop()
    {
    artnet.read();
    }


    void onDmxFrame(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t* data)
    {
    sendFrame = 1;


    if (universe < maxUniverses)
    universesReceived[universe] = 1;


    for (int i = 0 ; i < maxUniverses ; i++)
    {
    if (universesReceived[i] == 0)
    {
    sendFrame = 0;
    break;
    }
    }


    for (int i = 0 ; i < length ; i++)
    {
    int bufferIndex = i + ((universe - startUniverse) * length);
    if (bufferIndex < numberOfChannels)
    channelBuffer[bufferIndex] = byte(data[i]);
    }


    for (int i = 0; i < ledsPerStrip * numStrips; i++)
    {
    leds.setPixel(i, channelBuffer[(i) * 3], channelBuffer[(i * 3) + 1], channelBuffer[(i * 3) + 2]);
    }

    if (sendFrame)
    {
    FastLED.show();
    memset(universesReceived, 0, maxUniverses);
    }
    }