The last part of the integration process is to modify the “blinkdebug” utility so that it also initialises the LED Matrix panel drivers and copies any received Blinkenlights data to the panel.
The source code can be found the in the GitHub repository – https://github.com/john-davies/Blog-code-files, directory “LED_Panel” – and the file is called “blinkpanel.c”. To build you need to copy the following files from the “lib” directory of the “rpi-rgb-led-matrix” repository:
then run “make blinkpanel”
The code itself is fairly simple but the following notes may be useful:
- To make the integration with the Blinkenlights code a little easier I’ve used the C API to rpi-rgb-led-matrix. There is also a C++ API.
- The code defaults to a 64×32 panel size but it’s possible to overwrite these values using the rpi-rgb-led-matrix command line options, e.g. “–led-rows=<rows>” or “–led-cols=<cols>”. Command line options to blinkpanel are passed through to the matrix creation command using the “led_matrix_create_from_options” call in the API.
- Blinkenlights packets that don’t match the size of the panel are quietly dropped.
Once built then the software can be run as follows:
sudo ./blinkpanel [ options ]
The “sudo” may not be necessary depending on how the user privileges are set up. The default size is 64×32 pixels but can be overwritten using the command line options.
Testing the Display
In the LED_Panel directory in GitHub ( see above ) there are a few tools to help in testing the display:
Sample test image
The test image “test_colour_bars.png.bml” will send a simple colour bar pattern as shown on the left.
The file can be sent to the display using “bsend” as follows and the result should look similar to the image on the right:
bsend -h <target ip>:2323 test_colour_bars.png.bml
The colour bar test image was created using the utility called “img2bml”, the source for which is also in that directory. Note that this utility uses a a single file library to read the image files – https://github.com/nothings/stb. You’ll need to copy a file from that repository to build the utility but the dependencies are listed in the README file. The colour bars image BML file was created as follows:
MPlayer is an open source media player. It’s of interest here because one of its little known output formats is for Blinkenlights.
This driver is capable of playback using the Blinkenlights UDP protocol. If you don’t know what Blinkenlights or its successor Arcade are, find it out. Although this is most probably the least used video output driver, without a doubt it is the coolest MPlayer has to offer. Just watch some of the Blinkenlights documentation videos. On the Arcade video you can see the Blinkenlights output driver in action at 00:07:50.
Of course it’s not going to be straightforward because that format isn’t enabled in the standard built and we have to build from scratch 😦 However it actually turned out to be very straightforward, the code is available from the download page and I used the v1.3.0 release. The download page has some pointers to help you compile but the Blinkenlights output format is enabled via the build configuration using the following command:
If the configuration worked correctly then you should see the following message:
Enabled optional drivers:
Input: ftp pvr tv-v4l2 tv vcd dvb networking
Codecs: libvpx ffmpeg(internal) real xanim
Audio output: alsa jack oss v4l2 mpegpes(dvb)
Video output: v4l2 matrixview opengl pnm jpeg mpegpes(dvb)
fbdev aa xvidix cvidix x11 xover bl yuv4mpeg md5sum tga
If the “bl” option is present in the “Video output” line then we’re good to go and the software can be compiled in the normal manner.
MPlayer has a potentially bewildering array of options but I eventually ended up with a command similar to:
- Remove the sound
- Rescale the input video so that it matches the aspect ratio of the LED panel. This is in two stages. Firstly the video is downscaled so that the width matches the LED panel then expanded to the LED panel resolution, filling in any missing pixels with black.
- Select the Blinkenlights format, use the rgb output and send to the Raspberry Pi
It’s quite difficult to find some test video that doesn’t have copyright issues. However the Blender project has a number of Creative Commons licenced videos that have been created to showcase the tool’s capabilities. These are extremely useful for demo videos. Here’s the “Glass Half” cartoon, downscaled in MPlayer and played on the LED matrix:
For reference this is the original: