Interface


Same Task, different approach.

Second try


The idea to control a 50GB+ music library via a 2x40 display, a rotary encoder and some bash scripts was kinda naive. Not only that, it never worked stable (I learned why only while I was working on this second approach). I also disliked to do everything via a menu. I soon noticed that I only wanted to control volume, toggle play/pause and power and maybe skip a track.
I decided I wanted simple Buttons for each of those tasks.
  • 5 Buttons
    • Amp on/off
    • Speaker on/off
    • Previous track
    • Play / pause
    • Next track
  • 1 LED's
    • Amp on/off
    • Speaker on/off, unavailable (when the Amp is freshly turned on)
    • Playing
  • 1 Pot (volume control)

This was simple enough to build. And yet it never worked reliable at first, and I tinkered a lot, for quite a while. Until I learned two things:
  • My solder was bad. Not my soldering skills, my actual solder. It had a very high resistance and made wonky contacts.
  • The internal oscillator of an AVR is not suitable for serial communications. It works a while and then loses sync.

Wiring


Was easy. 5 Buttons via voltage dividers onto one analogue port. A Pot to another analogue port. Two LEDs and two relays to four digital ports, a 16MHz (just the value I had lying around) Quarts to the xtal ports, serial to RXTX. Simple as that.

Software


Even more easy. The buttons are read as an analogue value, debounced and converted into discreet values. A state machine manages the relays and corresponding buttons (one for power and one for the speakers) so that the amp is always at least 20 seconds on before the speakers are connected to prevent pop, and the speakers are at least 1 second disconnected before the amp is powered off. The pot value (and the remaining three buttons) are just send as text via serial. The LEDs and amp/speaker states can be set via serial. A simple bash script reacts to button presses and sets the LEDs.
It worked quite well, although the serial connection stops working after a few days without actions. The obvious solution would probably have been to send something every now and then. I never tried that, though. I was never really happy with it. It lacked to much in CPU performance and ram for certain ideas I had for it and ran a very old Debian version.
Path: 30.169, Handler: 12.733, Options: 11.88, Content: 6.963, Template: 0.026, Render: 13.157