Sometimes you just want to make better use of your tools. Sometimes you want to write neat code that does fun things. And sometimes you just want to jam out to some Daft Punk. This project does all of the above.
I recently learned about a media service called Media Player Daemon (http://www.musicpd.org/). MPD is essentially a headless, back end tool that is used to manage media files, create playlists, and then render them to an output (usually an audio playback device, but not necessarily.) This makes it excellent for installing it on small computers connected to a room stereo system. You can then connect to it from external clients on things like cell phones to control the player.
By itself that would have been pretty darn cool and a great second use for Mr. Wiggles, my Raspberry Pi based testing web server. But I have an LCD plate that I really wanted to integrate into the system. Enter RaspberryPiMPDJukebox.
The MPD Jukebox client isn’t really a novel idea (several projects have done something similar,) but I wanted to take a crack at multi-threading in Python and working with locks and queues. So I put this together as a client for the MPD server that I have running on Mr. Wiggles.
However, I did learn a few things along the way. The older Adafruit library I was using was apparently DOG slow. The work I initially did with threading helped mitigate a bunch of that, but button responsiveness was essentially non-existent because updating the screen cost everything the CPU had and was slow enough I could watch it update. The new libraries improved that by a LOT and also allowed me to reduce the transactional costs by reducing button checks to a single call to the LCD.
That said, something I’d really like to see is a swap from a GPIO expander, which must be polled (something that isn’t a good idea when working with a non-realtime operating system like Linux,) to a microcontroller based system. Sending commands to a microcontroller to ask if, when, and how long a button was pressed is a far better strategy than hoping a fast loop in Linux is going to get around to seeing things, especially since it’s possible to get blocked out by other bus transactions.
This will require a rework of the LCD plate itself. Not sure if that’s something I want to tackle at this exact moment, but it’s a project to be put on the table.














