For pimoroni pirate audio device users - python code to unleash the power of your hat

@spinkman

so your button Y is not working (so far), and it isn’t pin 20 (and not 5,6,16)
Your hat: pirate audio amp 3W

Please try the following:

  • stop pirateaudio plugin via volumio GUI
  • change line 20 in test_gpio from BUTTONS = [5, 6, 16, 20] to BUTTONS = [5, 6, 16, 18]
  • change line in /boot/userconfig.txt from gpio=20=pu to gpio=18=pu
  • start test script by python test_gpio.py in commandline
  • press your buttons, the script should output the GPIO number

AxLED

@AxLED

My hat: Pirate Audio 3w

Changed button 20 to 18.
output

volumio@ohc-speaker:~$ python test_gpio.py
buttons.py - Detect which button has been pressed
This example should demonstrate how to:
1. set up RPi.GPIO to read buttons,
2. determine which button has been pressed
Press Ctrl+C to exit!

Button press detected on pin: 5 label: A
Button press detected on pin: 6 label: B
Button press detected on pin: 16 label: X
initalisiere Shutdown
Button press detected on pin: 6 label: B
Button press detected on pin: 6 label: B
Button press detected on pin: 16 label: X
initalisiere Shutdown
Button press detected on pin: 5 label: A

The difference this time is that after the X button is pressed, I’m able to continue to press other buttons. still no Y button tho…

Oh!
success!!
Changed button 18/20 to 24

Button press detected on pin: 5 label: A
Button press detected on pin: 6 label: B
Button press detected on pin: 16 label: X
initalisiere Shutdown    
Button press detected on pin: 24 label: Y
Button press detected on pin: 24 label: Y

so, it is back to the link I posted that mentions the Y button is on GPIO 24 but I didn’t understand how to assign the button… I’ll play around some more.

@spinkman

thanks for your response, so your Y button is 24.
Your hat: pirate audio amp 3W

Please try the following:

  • stop pirateaudio plugin via volumio GUI
  • change directory to path /data/plugins/miscellanea/pirateaudio
  • change line 80 in display.py from BUTTONS = [5, 6, 16, 20] to BUTTONS = [5, 6, 16, 24]
  • change line 436 in display.py from if pin == 20: to if pin == 24:
  • change line in /boot/userconfig.txt from gpio=20=pu to gpio=24=pu
  • reboot your pi
  • activate pirateaudio plugin via volumio GUI

AxLED

100% success!

change line 80 in display.py from BUTTONS = [5, 6, 16, 20] to BUTTONS = [5, 6, 16, 24]
change line 436 in display.py from if pin == 20: to if pin == 24:
change line 458 in display.py from for x in [5, 6, 16, 20]: to for x in [5, 6, 16, 24]:

I had already changed line 80 in testing but didn’t venture that far down in display.py
Thank you @AxLED for your support. much appreciated.

In my attempts to free up some GPIO pins by wiring the Pimoroni to the pi rather than plugging it into the pi socket I used this diagram from the web (although I can’t remember where I found it)

However, after much fiddling, I found that my board also needs pin 17 (3.3v) to work. Hope this saves someone some time!

For info: the image above can be found at Pirate Audio 3W Amp at Raspberry Pi GPIO Pinout.

1 Like

Hey @AxLED thanks for your great work. Does your plugin also works with the pirateaudio headphone Amp?

@KingQuestable

yes the plugin should work on pirate audio headphone amp as well.
According to https://pinout.xyz/pinout/pirate_audio_headphone_amp# there are two versions, which use different GPIO for Y Button. So the worst thing could happen, that Y Button is not working (so far).
But here are the good news, i am working on a update for the plugin, where you can choose the GPIO Pin for Y Button via volumio GUI.

AxLED

Hey @AxLED,

thanks for the fast reply. I set up a new volumio with the pirate headphone dac and installed your plugin. Works great! :slight_smile: Thanks for your work

Only problem I have found, is that Button Y isn’t working as you mentioned. I have tested the GPIOs with your test_gpio.py and it seems that my hat also uses gpio 24, like the one from @spinkman.
Unfortunately the steps you mention above:

  • stop pirateaudio plugin via volumio GUI
  • change directory to path /data/plugins/miscellanea/pirateaudio
  • change line 80 in display.py from BUTTONS = [5, 6, 16, 20] to BUTTONS = [5, 6, 16, 24]
  • change line 436 in display.py from if pin == 20: to if pin == 24:
  • change line in /boot/userconfig.txt from gpio=20=pu to gpio=24=pu
  • reboot your pi
  • activate pirateaudio plugin via volumio GUI

doesn’t work for me. I have double checked the lines, but Button Y still doesn’t work after a reboot. Have you any suggestions how i can fix the problem?

@KingQuestable

did test_gpio.py show 24 for your Y button ?
If yes, try to deactived and activate pirateaudio plugin via GUI (no reboot).
Is there any other hardware attached to the GPIOs?
Which plugins are installed?

Can you attach the following files:

  • display.py
  • userconfig.txt
  • /boot/config.txt

So i can have a look at it.

AxLED

Did you get the one on line 458?

@spinkman Aaah thanks! I have missed that line. Thanks a lot.

@AxLED so now the buttons are working well.
I just have the spotify plugin installed. When I use the buttons to navigate to a song in spotify, I can’t play it. So the A button seems to not work here. Is this a known bug oder does this suppose to be working?

Yes, spinkman is right,

in addition to the modifications you did, you have to:

  • change line 458 in display.py from for x in [5, 6, 16, 20]: to for x in [5, 6, 16, 24]:

AxLED

@KingQuestable

as i dont use spotify i couldnt test it.
But i changed the play function in my release anyway. If someone can send me some sample outputs from spotify i could implement this.
Give me some days for the update.
AxLED

@AxLED
Thanks for the info. Since I mainly use Spotify, I’ll take a look at Mopidy. Maybe that is better suited for my project. And I’m switching from volumio to Mopidy. But thanks a lot for your efforts.

Hi,

i released a new version v 0.0.3 and moved conversation to a new thread under plugin section of this forum: https://community.volumio.com/t/plugin-pirate-audio/44336
@spinkman now you can configure your GPIO Pin of Y Button via GUI.

AxLED

1 Like

Hi AxLED,
Thanks for your efforts, works great !

Hi Everyone,

Thanks for building this plugin, its great to get the pirate audio up and running on volumio.

I managed to get everything installed and working - however, the volume is very low, much lower than when i had the original software running on the pirate audio. Is there something im missed with the mixer - i have it set to hifiberry dac and software mixer. I need to set it to the high 70s to get any kind of decent volume out…

any help would be really appreciated.
Thanks,
Mark

@makearne

moved topic to https://community.volumio.com/t/plugin-pirate-audio/44336/5

AxLED