[Plugin] pirate audio

Hey there, great plugin, works flawlessly, and even enables me to shutdown without browser.

There’s however 2 things i’d like to see:

  1. Scrollable song name - most songs display name is longer than one screen, so you don’t see everything…
  2. Turning off screen after shutdown - when I shutdown it with power still connected, last screen is shown. I’ve read somewhere that i can do that with some gpio plugin but i’m clueless…

@pixxel,

i am glad to hear you are enjoying my plugin.

To 1st: Scrolling text is possible (in general) but takes a lot of cpu power for the python script. Also 240 x 240px is a limitation, where not everything is possible to display (even with scrolling text). I am not planing to add scrolling text in the near future.
To 2nd: This is because of the backlight pin (see userconfig.txt -> gpio=13=op,dl), i dont know how to tell raspberry pi to keep the state after fully shutdown. I have a portable volumio solution with adafruit powerboost pcb, which cuts the power after a few seconds after shutdown.

Regards

AxLED

1 Like

Thanks for the info… I’ll double-check turning off, maybe there’s simpler solution :wink:

Amazing work @AxLED, thanks for the plugin.
One quick remark: the remaining track time only updates if I click one of the buttons. Is that expected?

@garatuja,

i know. The remaining time only refreshes, if a websocket message is received. This can be varius events:

  • clicking one of the buttons of pirate audio hat
  • new song from playlist or webradio
  • any clicks from web UI or smartphone app

Maybe i have to include a timer within the next release, which refreshes remaining time every x-seconds.

AxLED

Hi AxLED,
First of all thank you for this plugin very handy tool for Pirate Audio line out board.
I just finished the first ever project with a Raspberry PI4, a Volumio player with the Pirate Audio line in board and noticed something that might be useful to add to your plugin.
It will be very handy to add a small function for the display backlight , meaning controlling the brightness of the led, something like an on/off or a dimmer control bar.
Let say I wanna listen music on the player and being in the bedroom for example , you might wanna have no light or a dimmed light on the display.
Found a small script on pirate audio github for the display led control via PWM but no idea how to add it as a function for the display.
https://github.com/pimoroni/pirate-audio/blob/master/examples/backlight-pwm.py
I’m quite good with the wires and hardware part but no clue regarding coding.
I don’t know how hard is it, but it will be very useful.
Another issue:
After shutting down the PI the display light stays on and is very disturbing if you leave the PI on.
Any idea how this can be sorted?
Let me know what you think.
Thank you!

@sandmanhuck,

am glad to hear you are enjoying my plugin.

to your first suggestion: I tried the code you mentioned above already some time ago, but with my pi zero a had the problem, that the display was flickering if brightness wasn’t 0% or 100%. If i use unchanged backlight-pwm.py it is not noticeable, because brightness loops from 100% to 0% to 100%.
For backlight control (on/off) have look at volumio-plugins/display.py at master · Ax-LED/volumio-plugins · GitHub here is some code to set the backlight to false.

to your second suggestion: This is because of the backlight pin (see userconfig.txt → gpio=13=op,dl), i dont know how to tell raspberry pi to keep the state after fully shutdown. I have a portable volumio solution with adafruit powerboost pcb, which cuts the power after a few seconds after shutdown.

Regards

AxLED

1 Like

Hi AlexD,
Thank you for the fast reply.
First suggestion: That code is an example and for testing puropose was wrote with a function to demonstrate how it works, probably that function needs to be adapted to your needs.
Took a look at your code as you suggested, but is quite a chinese language for me, I will dig more to understand.
The idea was to have an option in the plugin for the display to be controlled at least as an on/off function if not possible to control the brightness. Like how is in GPIO plugin for Volumio who let’s you choose a GPIO pin to control a function.
I will try to find more info how to do it.
Second suggestion: You are right, since the software is shutdown, nothing is telling to the PI what to do with the display, so indeed a solution is to have a physical device who is cutting the PI power. I will dig more maybe I wil figure it out…
Thank you!

Hi AlexD,

Could you please share step by step process to install Volumio on Raspberry Pi Zero W with Pirate Audio DAC? Currently I am running Mopidy and its little painful to play any song.

I do not want to use a separate mobile every time. I should get option to plug and play directly from Pirate Audio screen. Currently it just shows the ip address, until and unless you access that ip from a phone browser to play some songs from internet radio or spotify.

1 Like

@100rin ,

normally you should install pirate audio plugin via plugin section (using webbrowser within the same network) and reboot your pi.
So lets try to debug.
Can you please tell me, which pi model you are using and which volumio version.

Regards

AxLED

Thanks for your reply AxLED, appreciate it. Hope and wish you are doing good.

Yes, I have installed Spotify then restarted Raspberry Pi Zero W from web browser. Then installed Volumio Spotify Connect2 and restarted.

Current issues:
Nothing is displaying on Pirate Audio (Pimoroni Pirate Audio Headphone Amplifier HAT with 3.5 mm Jack)

Pi Model: Raspberry Pi Zero W
Volumio Version: volumio-2.882-2021-04-24-pi.img
HAT: Pimoroni Pirate Audio Headphone Amplifier HAT with 3.5 mm Jack

  • The low-gain mode is recommended for most use-cases.
  • The DAC can be configured by adding dtoverlay=hifiberry-dac to the /boot/config.txt file.
  • There is a DAC enable pin—BCM 25— that must be driven high to enable the DAC. You can do this by adding gpio=25=op,dh to the /boot/config.txt file.
  • The buttons are active low, and connected to pins BCM 5, 6, 16, and 24.
  • The display uses SPI, and you’ll need to enable SPI through the Raspberry Pi configuration menu.
  • If you want to use these boards with a Pibow Coupé case (either for the Zero / Zero W or Pi 4), then you’ll need to use a booster header to raise it up a little.

volumio@100rin:/boot$ cat config.txt

initramfs volumio.initrd

gpu_mem=32

max_usb_current=1

dtparam=audio=on

audio_pwm_mode=2

dtparam=i2c_arm=on

disable_splash=1

hdmi_force_hotplug=1

include userconfig.txt

Volumio i2s setting below: do not alter

dtoverlay=hifiberry-dac

volumio@100rin:/boot$ cat userconfig.txt

Add your custom config.txt options to this file, which will be preserved during updates

@100rin

i am confused with your answer. Are we talking about plugin “pirate audio” or plugin “spotifiy”?

AxLED

Sorry for the confusion, looks like I installed the incorrect plugin. Your plugin is available in miscellaneous section which I did not search, will try and get back.

I have installed “pirate audio” plugin, but still nothing is appearing on screen. headphone jack is working though.

volumio@100rin:/boot$ cat userconfig.txt

Start of parameters for pirateaudio plugin

dtparam=spi=on

gpio=25=op,dh

gpio=13=op,dl

End of parameters for pirateaudio plugin

Add your custom config.txt options to this file, which will be preserved during updates

volumio@100rin:/boot$ cat config.txt

initramfs volumio.initrd

gpu_mem=32

max_usb_current=1

dtparam=audio=on

audio_pwm_mode=2

dtparam=i2c_arm=on

disable_splash=1

hdmi_force_hotplug=1

include userconfig.txt

Volumio i2s setting below: do not alter

dtoverlay=hifiberry-dac

Looks like I am not able to deduct Y button: test_gpio.py:27: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.

GPIO.setup(BUTTONS, GPIO.IN, pull_up_down=GPIO.PUD_UP)

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

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

@100rin

the informations of userconfig.txt and config.txt look good.
So there are still 2 problems

A. display not working
B. Y Button not working

to A: please try following.

  • disable pirate audio plugin
  • open SSH session and enter commands:
    cd /data/plugins/miscellanea/pirateaudio
    python display.py
  • post output

to B: you can change the GPIO Pin of Y Button in configuration of pirate audio plugin (20 or 24)

AxLED

Thanks for replying AxLED, one thing which I forgot to mention earlier. Mopidy still works perfect on the device.

Issue A:

volumio@100rin:~$ cd /data/plugins/miscellanea/pirateaudio

volumio@100rin:/data/plugins/miscellanea/pirateaudio$ python display.py

An incompatible websocket library is conflicting with the one we need.

You can remove the incompatible library and install the correct one

by running the following commands:

yes | pip uninstall websocket websocket-client

pip install -U websocket-client

Post seeing above I tried below:
volumio@100rin:~$ yes | pip uninstall websocket websocket-client
Traceback (most recent call last):
File “/usr/bin/pip”, line 9, in
load_entry_point(‘pip==1.5.6’, ‘console_scripts’, ‘pip’)()
File “/usr/lib/python2.7/dist-packages/pkg_resources.py”, line 356, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File “/usr/lib/python2.7/dist-packages/pkg_resources.py”, line 2476, in load_entry_point
return ep.load()
File “/usr/lib/python2.7/dist-packages/pkg_resources.py”, line 2190, in load
[‘name’])
File “/usr/lib/python2.7/dist-packages/pip/init.py”, line 74, in
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File “/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py”, line 9, in
from pip.download import path_to_url
File “/usr/lib/python2.7/dist-packages/pip/download.py”, line 25, in
from requests.compat import IncompleteRead
ImportError: cannot import name IncompleteRead

Issue B: ( I already tested this before, Y is not working with both the numbers)

Y button set to 24:
volumio@100rin:~$ 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: 16 label: X

initalisiere Shutdown

Button press detected on pin: 6 label: B

^CTraceback (most recent call last):

File “test_gpio.py”, line 47, in

signal.pause()

KeyboardInterrupt

Set to 20
volumio@100rin:~$ 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: 16 label: X

initalisiere Shutdown

Button press detected on pin: 6 label: B

^CTraceback (most recent call last):

File “test_gpio.py”, line 47, in

signal.pause()

KeyboardInterrupt

@100rin,

is this a fresh install of volumio and plugin pirate audio for your pi zero?
If not, try to format your sd card and start with a fresh install.
In my install script of pirate audio plugin i install sudo pip install socketIO-client

AxLED

Yes, both are fresh installs, though I will try again and let you know.

Any sequence I should follow which I may be missing?

Thanks,
100rin

I have the same problem as 100rin in Issue A. I use a RPi Zero with fresh and clean Volumio and plugin install.
See also https://github.com/Ax-LED/volumio-pirate-audio/issues/10
How to fix this?

1 Like

@100rin and @tigger-gg ,

i can confirm something changed in volumio or pip or depencies, so my plugin pirate audio dont work anymore. Let me check that, i will come back if i found a workaround and/or solution.

I guess i found a workaround, executing pip freeze > requirement.txt give me differences in webscoket-client. I have a working installation with websocket-client==0.58.0 and a broken installation with websocket-client==1.0.1. So please try:

  • disable pirate audio plugin (via web GUI)
  • login via ssh
  • check if pip is correctly installed by command pip --version
    • if you get an error, fix it by command sudo easy_install -U pip and run pip --version again, now you should get an version information.
  • uninstall websocket-client with following command: sudo pip uninstall websocket-client
  • install a specific version of websocket-client with the following command: sudo pip install websocket-client==0.58.0
  • enable pirate audio plugin (via web GUI)
  • tell me the results

AxLED

2 Likes