Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 | Use PirateHAT Display #2426

Open
jszust opened this issue Sep 16, 2024 · 3 comments
Open

🐛 | Use PirateHAT Display #2426

jszust opened this issue Sep 16, 2024 · 3 comments
Labels
legacy_v2 Issues, discussions and PRs related to Version 2.x Tips Tricks Hacks

Comments

@jszust
Copy link

jszust commented Sep 16, 2024

Version

2.7.0

Branch

master

OS

Raspberry Pi OS Lite - 32 Bit Bullseye

Pi model

Zero 1

Hardware

Raspberry Pi Zero WH + Pirate Audio Mini-Amp with Display for Headphones + PiSugar3 + HiLetGo USB RFID Reader

What happened?

I managed to get RPi-Jukebox installed (Spotify Edition) alongside the Pirate Audio mini-amp and have been having issues with the display. I tested the display with a mopidy-only install and confirmed that it, along with the Pirate HAT GPIO buttons, all worked well without issue.

I used the following procedure to have RPi-Jukebox work with the Pirate HAT:

  1. sudo apt update && upgrade on a fresh install
  2. Installed RPi-Jukebox Spotify edition
  3. Modified /boot/config.txt to:
    include:
gpio=25=op,dh
dtparam=i2c_arm=on
dtparam=i2s=on
dtparam=spi=on

Comment out:

#dtparam=audio=on

Modify the following to include the ,noaudio appended text:

dtoverlay=vc4-kms-v3d,noaudio
  1. Reboot

  2. sudo apt-get install the following python dependencies to assure they are all installed:

  • python3-rpi.gpio
  • python3-spidev
  • python3-pip
  • python3-pil
  • python3-numpy
sudo apt-get install python3-rpi.gpio python3-spidev python3-pip python3-pil python3-numpy
  1. Install the following numpy dependency for the ST7789 library (the display will show a blank screen without this installed):
sudo apt-get install libopenblas-dev
  1. Stop the GPIO Control Service with the following (this will fail if you chose not to install GPIO control during the phoniebox install):
sudo systemctl stop phoniebox-gpio-control.service
sudo systemctl disable phoniebox-gpio-control.service
  1. Modify /etc/mpd.conf to the following:
# An example of an ALSA output:
audio_output {
        enabled         "yes"
        type            "alsa"
        name            "HiFiBerry DAC+ Lite"
        device          "hifiberry"
        auto_resample   "no"
        auto_channels   "no"
        auto_format     "no"
        dop             "no"
}
#
audio_output {
        type            "alsa"
        name            "My ALSA Device"
#       device          "hw:0,0"        # optional
#       mixer_type      "hardware"      # optional
#       mixer_device    "default"       # optional
        mixer_control   "Master"                # optional
#       mixer_index     "0"             # optional
}
  1. Make sure SPI is activated even though the config boot line should enable it:
sudo raspi-config nonint do_spi 0
  1. Ensure iris is given root privileges consistent with Pirate Hat installation:
echo "mopidy ALL=NOPASSWD: /usr/local/lib/python3.9/dist-packages/mopidy_iris/system.sh" | sudo tee -a /etc/sudoers
  1. Install Pirate Display plugins (this may fail if you missed python dependencies):
sudo pip3 install Mopidy-PiDi pidi-display-pil pidi-display-st7789 mopidy-raspberry-gpio
  1. modify /etc/mopidy/mopidy.conf to map the GPIO buttons and enable the display (make sure your Pirate Audio is the newest version that uses GPIO 24 instead of 20, this is likely if it was made after 2022):
[raspberry-gpio]
enabled = true
bcm5 = play_pause,active_low,150
bcm6 = volume_down,active_low,150
bcm16 = next,active_low,150
bcm20 = 
bcm24 = volume_up,active_low,150

[pidi]
enabled = true
display = st7789
  1. Give Mopidy access to Pirate Audio
sudo usermod -a -G spi,i2c,gpio,video mopidy
  1. Modify the following file to correctly map the pause and play buttons (they are reversed by default):

/usr/local/lib/python3.9/dist-packages/mopidy_pidi/frontend.py

    def track_playback_ended(self, tl_track, time_position):
        self.update_elapsed(time_position)
        self.display.update(state="play")

    def track_playback_paused(self, tl_track, time_position):
        self.update_elapsed(time_position)
        self.display.update(state="play")

    def track_playback_resumed(self, tl_track, time_position):
        self.update_elapsed(time_position)
        self.display.update(state="pause")

    def track_playback_started(self, tl_track):
        self.update_track(tl_track.track, 0)
        self.display.update(state="pause")
  1. Reboot

This will work OK with a Pi Zero W (version 1), but if the GPIO buttons are pressed too quickly, or cards scanned very quickly, the display will stop working. The audio would also crash after some play time.

After upgrading to the Pi Zero W 2, everything works flawlessly. This is all put together with a PiSugar3 as well, so we have PhonieBox fun on the go 🥇

Logs

No response

Configuration

No response

More info

No response

@jszust jszust added bug legacy_v2 Issues, discussions and PRs related to Version 2.x needs triage labels Sep 16, 2024
@s-martin s-martin changed the title 🐛 | PirateHAT Display Issues 🐛 | Use PirateHAT Display Sep 16, 2024
@s-martin
Copy link
Collaborator

#1112 related

@s-martin
Copy link
Collaborator

Thanks for this howto!

@jszust
Copy link
Author

jszust commented Nov 4, 2024

@s-martin just wanted to follow up. I upgraded our phonieboxes from Pi Zero W to the Pi Zero 2 W and this is working flawlessly now. The screen is super responsive, tracks change instantaneously, and it is a complete treat. My kids absolutely love it and I cannot thank you and all the contributors enough for putting this all together. I updated my initial post with some additional steps to get it 100% there. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy_v2 Issues, discussions and PRs related to Version 2.x Tips Tricks Hacks
Projects
None yet
Development

No branches or pull requests

2 participants