Interface


I need to control two Relays, one to switch the amp on and off, and two other to switch the speakers on and off. Some means of output and control would be nice too. Most interfacing is done via MPD anyway, but basic control on the Device would be nice.

Outtakes: First Try


I had a 2*16 text display with the common hd44780 controllor and a rotary encode at hand, so i used them. A humble ATTiny2313 controls them. That one is just barely enough. I have two Pins left, and with 128 bytes of ram holding a buffer for a larger display would be a problem.
  • ATTiny2313 (better use a ATMega8 or something alike)
  • a hd44780 display (better use a small one with Tiny)
  • a rotary encoder (i have a ALPS STEC11B)
  • 3 1k resistors
  • a 10k trimmer
  • a DIP socket and some headers
  • two relays and the stuff to drive them
  • some perfboard

The circuit is pretty straightforward. Have a look at $file heere (de) to connect the Display. Be sure to use a trimmer/poti for the contrast, i had the weirdest troubles when i did not use one.
The rotary encode has a 3 Pin header and a two Pin header. The two Pin head is just a switch for the click. The two Pin header is the actual encoder. Have a look $file heere (de) or $file heere (en). The middle Pin is VSS, the other are data.

Later i added a Transistor to drive the background light. Not shown here.

Software


The software for the microcontroller is pretty simple, it can show Text on the Display, switch the relays and read the rotary encoder. Communication is done by a very simple protocol.
  • After reset: show every line from serial on the display, until "+X+" is read. then:
    • pTEXT|TEXT2: show TEXT in line 1, and TEXT2 in line 2
    • sXY: switch Relay Y on (X=1) or off (x=0)
    • send "left"/"right" when encode is turned
    • send "click" when encoder is pressed

So, anything smart has to happen on the server. Currently i have three pretty simple bash scripts
  • mp_ctrl.sh: initialize (+X+), switch on/off
  • mp_rotary: raiser/lower Volume when encoder is turned, toggle play/pause when encoder is pressed
  • mp_display: display Artist in line 1 and Title in line two (or Volume if just changed)

https://github.com/0mark/mivuuauad
Path: 29.704, Handler: 13.389, Options: 11.641, Content: 15.536, Template: 0.031, Render: 8.326