Keeping track of how hot your CPU is running can be quite boring, as staring at a list of changing numbers gets old, quickly. That's why Sebastian from the website There Ought to Be has created a cube with three faces that display CPU usage and temperature statistics. He was inspired to design this when he attended the 36th Chaos Communication Congress and saw the smaller cubes that people were building and using to show particles reacting to changes in the cube's position. Rather than also making his cube battery powered, Sebastian wanted a stationary device that can plug into the wall, which allows for far more LEDs to be used.
Perhaps the most important part of this project are the three LED panels, which each contain 4,096 LEDs, for a total of 12,288. They rely on a simple serial communication protocol, which sweeps through each row to update the display, and it also allows for multiple panels to be chained together in a series. All of that lighting needs power, which is why Sebastian used a 5V 10A power supply. As for driving the pixels, a Raspberry Pi 2 and Adafruit RGB Matrix Bonnet are responsible for outputting and converting the signals.
In very simplified terms, the Raspberry Pi gets its CPU temperature through an API, converts that number into a color and animation, and then pushes it to the display. When stated this way, much of the complexity is hidden, especially when it comes to how the animations get from idea to the matrices, so it will be explored in more detail.
The LEDs on the matrix are not like the ones you would find on an LED strip, since they lack dedicated controllers. Rather, it uses many serial demultiplexers that decode the signal and output the appropriate value to the right LED. For a 64 x 64 matrix, 5 bit addressing is required, making the total number of GPIO pins used 13. Each panel can draw up to 5A if every pixel is set to full white (255, 255, 255), so it's important not to exceed the power supply's limit.
The three panels are mounted onto a basic chassis that was 3D printed in black PLA. There is a small are on the bottom to mount the Pi, along with a few cutouts for cable routing. The base has a small tilt for display purposes, but it can cause viewing angle issues.
The software is where the magic happens. It is a C++ program that first opens a UDP port to receive cpu information from an external script, then it displays the appropriate animation. It uses the rpi-rgb-led-matrix library (the same one Adafruit uses in their Python wrapper) to map the physical pixels onto a software-defined grid and then push them over the physical bus. This abstraction helps to greatly simplify the development process, as you can simply plug in the hardware mapping, timings, and display information to get it started.
Sebastian thought that just displaying a GIF or text on the cube would be too boring, so he wanted something dynamically generated instead. The OpenGL program is quite complicated, so here's the basic rundown. The three faces of the cube are rendered as three pairs of triangles, which then get flattened to make a virtual canvas. This way of addressing pixels will cause a shape like a circle to look proper when viewed from the single common vertex in the center.
All of this preparation has led to the final task of getting the current CPU stats from a PC to the Pi. This is accomplished with a short Python script that takes in CPU die thermal sensor data using the psutil library and then formatting it as a string. It then gets pushed out via a UDP socket to the host Raspberry Pi for decoding.
The final result is impressive, as there are complex gradients and shapes moving in different directions constantly. Although extravagant, this project is a great way to showcase what can be done with a few components and some creativity.