Hacking a Mopidy media player.

The aim is to have a number of buttons that can control the player. Main functions are:

  1. Stop/Start player.
  2. Next/Previous track
  3. Volume up/Down
  4. Select Genre. The RFID tag will select the genre.
  5. Scroll through Albums from those available.
  6. Play an album.
  7. Control display
  8. … Lots more.

Pirate Audio software gives a start, but I need to reverse engineer it to see how it works. First question is where is it located? How is it built? There is a lot of good documentation on the Mopidy site, but lacks the file locations I need to get my head round.

Only one hit for sudo find / -name rotencoder.py shows this location. Here are the relevant folders:

/usr/local/lib/python3.9/dist-packages/mopidy
/usr/local/lib/python3.9/dist-packages/mopidy_raspberry_gpio/
/usr/local/lib/python3.9/dist-packages/mopidy_irisĀ 
/usr/local/lib/python3.9/dist-packages/mopidy_local
/usr/local/lib/python3.9/dist-packages/mopidy_pidi 
/usr/local/lib/python3.9/dist-packages/musicbrainzngs
/usr/local/lib/python3.9/dist-packages/pidi_display_pil
/usr/local/lib/python3.9/dist-packages/pidi_display_st7789
/usr/local/lib/python3.9/dist-packages/uritools

Make the files easier to remote edit:

sudo su

find /etc/mopidy -exec chmod o+w {} \;

find /usr/local/lib/python3.9/dist-packages/mopidy_raspberry_gpio/  -exec chmod o+w {} \;

find /usr/local/lib/python3.9/dist-packages/mopidy_irisĀ   -exec chmod o+w {} \;

find /usr/local/lib/python3.9/dist-packages/mopidy_local /usr/local/lib/python3.9 -exec chmod o+w {} \;

find /usr/locallib/python3.9/dist-packages/mopidy_pidi -exec chmod o+w {} \;

find /usr/local/lib/python3.9/dist-packages/musicbrainzngs  -exec chmod o+w {} \;

find /usr/local/lib/python3.9/dist-packages/pidi_display_pil  -exec chmod o+w {} \;

find /usr/local/lib/python3.9/dist-packages/pidi_display_st7789  -exec chmod o+w {} \;

find /usr/localfind /lib/python3.9/dist-packages/uritools -exec chmod o+w {} \;

find /etc/mopidy -exec chmod o+w {} \;

Looking at the Pirate Audio installer script. It does the following:

  • Modify /etc/modipy/modpi.cont
  • Installs the following python libraries:
    • python3-rpi.gpio- Extensions for GPIO
    • python3-spidev- Extensions for the SPI interface used by display
    • python3-pip- PIP installer
    • python3-pil- Package installer for Python.
    • python3-numpy- Package for dealing with arrays.
    • libopenjp2-7 – JPEG and JPG200 image library.
    • Enables SPI interface
    • Modifies config.txt for GPIO pins and the DAC.
    • Installs Mopidy and spotify plugins.
    • Installs and updates modpi_iris for image display.
    • Installs plugins for Pirate Audio:
      • Mopidy-PiDi
      • Mopidy-Local
      • pidi-display-pil
      • pidi-display-st7789
      • mopidy-raspberry-gpio
      • mopidy_iris
    • Modifies the mopidy config file to configure the various modules:
      • raspberry-gpio – define pin mappings
      • file – specify where to find music files
      • pidi – specify display controller
      • mpd – music player daemon on local machine.
      • http – web server interface
      • audio – output audio device & volume
      • spotify – connection details

So now I start to see what is needed. I need:

  • mopidy_raspberry_gpio
    Replace with mopidy_Chronos to map the IR to mopidy commands .
  • modipy local

 

Display is handled