Display Artnet pixel data with Smart Matrix fast


#1

Hi there!
My plan is to use a Ethernet controller to receive pixel data via the Artnet protocol from a software and display it on my 32x32 Matrix using the library.
First of i want to point out that i am by no means a advanced programmer, so please forgive me if my code looks pretty hacked together :slight_smile:

So i got the Ethernet and Artnet part working fine by attaching an WIZ820IO Ethernet module (W5200 chip). I only had to change the CS and Reset pins in the Teensy library, since the standard pins get used by the SmartMatrix shield.
I then combined an example from the Artnet library with an basic SmartMatrix setup to send the 3072 channels to the leds:

https://github.com/SeeedMonkey/SmartMatrix_Artnet/blob/master/Smart_Matrix_Artnet.ino

In the main for loop to transfer the data to the leds i had to put in some if cases to offset the channels to the pixels on the matrix. This is because my bitmap program is not capable to split one pixel in two Artnet universes. So there are some gaps in the channelBuffer at the end of each universe.
It basicly works, but there are a few problems with it:

  • First of all, it is way to slow. The big for loop takes to long to set the individual pixels, in most cases it does not finish before the next frame arrives. This causes the rows at the bottom not to be updated most of the time… Also the Matrix has a noticeable slower frame rate than the original signal…

  • Also the code causes the whole Teensy to freeze up some times, probably because it tries to access the main string at the same time it is written to…

  • I also have to define the color of the individual pixel each time with rgb24, this maybe takes a lot of time in total too…

I am pretty sure there is a much quicker way to pass the Artnet data over to the pixels than drawPixel, do you guys maybe can help me out with that? As i said, handling this mass of data is something new to me :slight_smile:

Thanks in advance, greetings,
Samuel


#2

Very cool, thanks for sharing! I’d love to see some video of it in action.

As for speed, you might try copying the pixel data directly into the background layer buffer, as shown here: https://github.com/pixelmatix/SmartMatrix/blob/master/examples/FastLED_Functions/FastLED_Functions.ino#L102-L116 It should be much faster, especially if you set it all at once or in chunks, instead of one byte or pixel at a time.


#3

Also, here’s the part of Aurora that handles TPM2 streaming data, which should be fairly similar. It’s actually able to read the data directly from Serial into the backBuffer: https://github.com/pixelmatix/aurora/blob/master/StreamingMode.h


#4

Hi,
thank you very much for the hint to the FastLed functions Jason, that was what i was looking for :slight_smile:

I worked at the code a bit more, and i got it running now! :slight_smile:
The FastLed Buffer helped to set the pixel colors much quicker, it now only takes between 350 and 480 microseconds (0,00035s) to fill the display buffer and display the frame! this is about 10 times faster than the drawPixel method i used before…
Also i finally understood how the dmx_on_frame function from Artnet.h works, as it gets executed for every universe separately instead on just ones for all of them. I think this was the main problem with the last version and the reason it did not worked.
Anyway, here is the new code:

https://github.com/SeeedMonkey/SmartMatrix_Artnet/blob/master/Smart_Matrix_Artnet.ino

in the code, i commented out a alternative method, where i write the Artnet data directly in the Fastled buffer without the ChannelBuffer in between. This should be even faster, for some reason it causes the Display to flicker really fast… Maybe this is because i have to declare the buffer outside the onDmxFrame function…

For some reason, the Teensy still freezes after a couple of minutes, i have no idea why. For the moment i fixed this with the Adafruit Watchdog to reset it.

Apart from that, i am pretty happy how it works so far! The display shows constantly the 25 fps i am sending to it. I measured that one frame takes approx. 4,2ms to transmit via Artnet, so there is still a lot of potential to increase the number of pixels or fps.
I am thinking about building a 128x32 pixel matrix with Artnet input right now, based on the times i measured on the one panel this should work. This matrix would use approx. 25 DMX universes with 12288 channels to display the 4096 pixels then :smile:

There is still a lot to do on this code i think, like adding a menu to set the ip etc.

Thanks again for your help! Greetings Samuel


#5

Cool! You shouldn’t need FastLED at all for this, you can use rgb24 instead of CRGB, might save you some RAM and/or flash.

I’m not sure why using the SmarMatrix backBuffer would cause flashing, or why the Teensy freezes after a while. @Louis might have some ideas.


#6

Great work Samuel!

for some reason it causes the Display to flicker really fast

You should get the backBuffer pointer after the swap. Right now you’re getting it before checking isSwapPending(), and potentially writing new data to the buffer that’s currently being used for refresh. Just swap lines 96 and 97 your code.

Not sure on the crash. If you comment out all the SmartMatrix drawing routines, does it still crash? What if you comment out all the writes to buffer?