The next thing wa to get rid of the hanging hardware on a charger so i opened up the Logitech pod with all the controls and found some 5v power pads on the inside. The power was also available when the amplifier was on standby so i decided that this must be my lucky day.
And he PI booted without problems from the 5V supplied by the Logitech.
After playing some music it was time for more, how about controllling the volume and power from the PI's GPIO pins. Now that we share the same ground we should be able to simulate the pressing of hardware buttons and the turning of the rotary encoder. After some fiddling i found they where al wired with pull up resistors to 5V, the button and gray encoder connected to the ground. So i got a some diodes and hacked them up to the proper terminals. The diode was there to lower the voltage a bit and prevent the short that could be created by pressing the button and having the PI send out a HIGH 3.3V signal (not that the software does this).
I've made the audio take the inside route, by hooking it up to the 3.5mm front line input and started to look for a way to see if it was on or off. At first i was hoping for a good signal from the power led, but that wasn't available on the front of the control PCB. The back was obscured with a secondary PCB for all the logic from 2002 to decode DTS etc. and i didn't want to take the whole thing apart. There was also display turning on and of so i checked the display connector and found a pin on the display connector that gave a 4.3v or 0v when the thing was on or off. I decided a 10K resistor and a diode should make that digestible for a 3.3V PI (i'm a hobbyist, i know ;)).
Ater that it was time to connect it all up to the GPIO's of the PI, i used the back of the pHAT DAC, because i found a nice spot for it in the back of the POD.
The GPIO header fitted exactly in the ventilation hole.
So now i could fit the PI on the back, having it powered from the inside
And now I have a neatly working music streamer which automaticly turns itself on if there is music stream through the DAC and it turns itself off after 10 seconds of silence. Volume and "Power on" are synced to the Mopidy player (Power connected to the mute function). By turning the GPIO's in input mode it is also still possible to use the hardware rotary encoder to adjust volume and have it synced to Mopidy.
Next time i will write about the software (which I've already put up on my Github account). It consists of a C++ service driving the GPIO and a Python Mopidy plugin to control it through shared memory.
For the software part i wanted something that would follow the state of the Mopidy player. The Mopidy software is written in Python and i didn't have any experience with Python. I wanted the state of the volume to be controllable from more than Mopidy alone so i made a C++ program that tracks a piece of shared memory. The standby state and the volume are kept in that shared memory and if they change the c++ program changes the state of the logitech to reflect that sending the right grey codes over the GPIO's and turning the logitech on or off. The C++ program also spies on the output of the DAC by reading the data output GPIO (which worked to my surprise) if there is audio playing it wil turn on the Logitech and if there is no audio it will turn it of after a few seconds.
The Python plugin needed acces to this shared memory, luckily there is a posix_ipc library that handles that. After installing it it was just a case of using the ALSA volume control as an example and changing it to use the shared memory for controlling volume. Later on i also coupled the mute function to the standby control so you can turn the amplifier on or off with the mute button.
It's been running for over a month now and still works nicely. I control it with Mopidy Mobile from an Android Phone.