Software: Akiniscope design
Rather than write everything from scratch, it’s easier to use a framework or libraries, written by people far cleverer than me. Akiniscope needed video and audio processing to be provided. Processing was the first I looked at, but I found this required more processing power than my poor little Raspberry Pi Zero W could provide.
Next I looked at pygame which provides video and audio tools for Python. I’ve used python a bit, professionally, but not much, so learning a bit more appealed. pygame could not provide all that i needed, so I next checked there were Python libraries for the other things needed.
picamera gives good control of the Raspberry Pi camera with it’s Python library, and also provides some graphic effects, using the GPU, which eases the load on the processor.
For digital inputs and outputs, I started by using RPi.GPIO, which did most of what I wanted, but then swapped to gpiozero. It was mainly to provide smooth brightness transitions for the LEDs that prompted the swap.
Debugging code is so much easier with a good log, so I was pleased to see how comprehensive the standard Python logging facility was. I’ve used the multi-level facility, where I can put logging in verbose, but detailed ‘debug’ mode, or the everyday ‘info’ mode.
The next thing is more a general programming practice, rather than just Python. I like to use finite-state machines (I’ve always called them ‘multi state machines’, when did they change that?) It sounds more complicated than it actually is. The principle is, rather than have a whole bunch of boolean variables, use one variable to reflect the current state. This can simplify a design a lot. I only use a couple: the current display state; and the current proximity sensor state. I’ll write a fuller blog about all this.
Finally, I want the machine start up and shutdown to look right. A lot of this is configuration, rather than written software, and some bits I’ve not worked out how to do, yet (how do I hide the desktop from appearing? probably use a light weight graphics framework, maybe?) I’m also writing a Plymouth theme, so startup will match the look and feel of the rest of Akiniscope.
I’ll write blogs on each of these elements, some time in the future…