Check the videos on Youtube
20x10 WS2812 LEDs driven by Raspberry Pi/Arduino to play games like Tetris in the living room
Check the videos on Youtube
Adobe Portable Document Format - 13.96 kB - 06/12/2016 at 14:51
CAD files for MDF matrix
Zip Archive - 306.31 kB - 05/04/2016 at 15:44
I just started to play around with parsing data from internet sources to the matrix.
Starting with this page (German parliament seat distribution):
and extracting data and colors from the SVG image using this code:
doc = minidom.parse('diagramm.svg') # parseString also exists style_string = [path.getAttribute('style') for path in doc.getElementsByTagName('path')] label_string = [path.getAttribute('aria-labelledby') for path in doc.getElementsByTagName('path')] text_string = [text.getAttribute('id') for text in doc.getElementsByTagName('text')] data_string = [text for text in doc.getElementsByTagName('text')] rgb= percentage= index=0 for i in range(0,7): rgb.append(style_string[i].split("(").split(")").split(",")) for i in range(0,text_string.__len__()): if text_string[i]==label_string[index]: percentage.append(int(round(200*int(data_string[i]._get_childNodes()._get_data().split(": "))/709))) if index < label_string.__len__()-1: index=index+1 doc.unlink() pix=0
So after sending this data to the matrix, I got this:
Nice starting point...
After several questions regarding code adaption for different matrix sizes, python code now has global pixel settings called PIXEL_X and PIXEL_Y.
I have uploaded the Arduino sketch of the ESP8266 based controller to Github.
Wiring is pretty simple, using a Sparkfun Thing and a single cell LiPo.
The schematic is now available. There are only three relevant connections:
Instead of the retro controller there is also a small Android app for game control. It provides the same functionality, so no additional controller hardware is needed if you already have an Android device.
There is a video on Youtube showing the app in action:
Python code and Arduino sketch now on Github. I will add more documentation how to use the code within the next week.
In reply to a comment, I will describe how to apply the veneer paper to the MDF matrix. The veneer I have used, is called Microwood, which is a 0.1 mm veneer with paper backing.
Before the final full-surface bonding onto the MDF matrix, I did some pre-testing with the glue and the surface preparation of the MDF. To avoid paper curling after the adhesion, I used a solvent based all purpose adhesive (UHU black), which worked as expected. For testing purpose, the black laser cutting edge on the MDF surface was removed with sand paper:
The following image shows the veneer glued on the MDF sanded off (right) in comparison to the veneer glued on the more or less black MDF. For me, this difference was not enough to polish all the MDF parts and the final result proved me right.
Because of the paper backing, it is quite easy to apply the veneer and there is no problem with dissolving, although the veneer was rolled up when it arrived.
If you have any questions, leave a comment.
I have now uploaded the DXF files of the MDF matrix. I have used 3mm MDF. The next version will be a combination of MDF and cardboard to save some cost.
Running Python code on the Pi makes it so easy to realize new features. This is a quick preview of getting a weather forecast on the LED matrix. Using PyOWM to talk to OpenWeaterMap and some 10x10 pixel weather icons, that's it.
There are 3 software components in the system:
This image gives an overview of the system:
There exists an option to directly drive the WS2812 LEDs from a Pi with the dpi_ws281x library. But I decided to use an Arduino, so it is possible to use the LEDs even during the Pi's boot process or without booting the Pi. Arduino and Pi communicate via UART at a speed of 500kbit/s, which is quite enough for a smooth gameplay.
The MAX7219-Matrix displays (e.g. available at eBay or direct china import) are driven by a great existing library, which provides text scrolling and direct pixel access via Python. I used four 8x8 matrix displays in a cascaded setup. For the Tetris highscore display, I build my own small font for 6 digits and enough space for displaying the next piece for the game. 6 digits are needed to realize the original Gamboy Tetris scoring.
There is an integrated speaker driven by a mono amplifier (from Adafruit), which is connected to the analog audio output of the Pi.
The Raspbian distribution includes a set of Python games in the folder python_games (doc of Python Games) which are based on the pygame lib. I replaced this library by my own display driver to directly drive the 20x10 LED matrix, but reused the gameplay for Tetris and Snake. For development purpose, I wrote a simulation version which still uses the pygame lib to write and test the code on a PC/Mac before transferring it to the Pi. Some screenshot of the simulator:
There is also a simulator for the controller using the arrow keys of the PC to control the simulator or the LED matrix
I will publish all the code soon after some code cleanup.