This is such a cool project I've used it to replace my Rotel RC-1590 preamp as the controller for my system. Since it allows my phone to stream to it using Airplay I could even eliminate the AppleTV from the setup.
mdsimon2 has done a really great job documenting this project and turning it into a tutorial!
This is the first time I've really seen or worked with Python code but I've been playing with it to see what all can be done. I wanted to have a bouncing ball animation for the idle-screen so it would match my MOTU Ultralite MkV when its idling but I found that the lgpio/Python combination only updates the screen approximately 1-2 times per second and would use a fair amount of CPU doing it. You can kind of see this when changing the volume that the redraw isn't all that fast. I tried different libraries and the simplest way I found to update the refresh rate is by using
RPi.GPIO in place of lgpio. It my testing I think I was able to get around 20+ updates per second at max CPU usage.
Evidently C is able to manipulate the IO pins much faster than Python. I'm not much of a C/C++ coder but I made a quick test program and could get around 100 updates per second. This is enough to do some really interesting things with the display! The exciting thing about this is that if you want to update the display at a more reasonable 10 frames per second you can do so with CPU usage lower than 30%. Combined with the multi-core nature of the RPi this allows reasonable screen updates at the same time as running FIR filters for the DSP.
I decided I wanted fancy VU meters.
That means I had to figure out how to draw graphics to the display as well as figure out how to calculate what graphics to draw. I was researching how to calculate proper diagonal lines and how to draw them on a bitmap display and came across a C library called
libssd1306 from Stealthy Labs. This library not only has the algorithms to draw diagonal lines but also allows text drawing with OpenType and TrueType fonts using Freetype. In addition it uses a framebuffer so you can setup what you want the screen to look like in memory and then write it to the display with a single call. This also allows you to have separate framebuffers in memory and switch between them easily. The downside is that the 1306 handles writing quite a bit differently than the 1322 chip that runs the display used for this project. I was able to do a
(rough) port to get it to work with this display, at least in 1 bit per pixel mode.
The other remaining piece to the puzzle is getting the information from CamillaDSP using C instead of Python. Fortunately the
pyCamillaDSP library is relatively simple and porting the needed functions for VU meters and status display to C was much simpler than the display code up above. That partian port can be found
here.
Once all of that framework is in place you can draw a picture of what you want the background of the VU meters to look like and then load that into the framebuffer. From there you can procedurally draw the needles/meter bars into the framebuffer in the appropriate positions and write this out to the display.
I can now write the status text to the display using a fonts of my choosing and then after a few seconds switch to either a screensaver if the system is paused or VU meters if the system is running.
View attachment 261905 View attachment 261906
I also added a motorized volume potentiometer as well as a button on the front panel to switch CamillaDSP configuration files. This allows pretty much anyone in the family to walk up to the stereo and, for instance, switch between Phono/Wifi/Aux etc. inputs and control the volume without needing to open a web browser and load the UI or use an IR remote.
I'm still working on getting that code uploaded. None of this stuff is really what I would consider ready for primetime but at least on my own system I've been able to make it work. This just underscores what a great job mdsimon2 did making his code something that is usable and workable for average computer users as opposed to just something that only software developers can make work.
With his permission I can at least upload the modifications to the oled.py file that gives the faster screen redrawing for simple things like volume changes and basic screensavers.