Note that this code will only run on a Raspberry Pi (tested on a Pi Zero 2 and a Pi 4), needs Python 3.9+
-
Enable SPI in
sudo raspi-config(under Interface options) -
Install dependencies:
sudo apt install mpv bluez-alsa-utils python3-dev -
create and activate venv:
python -m venv ./venvandsource ./venv/bin/activate -
Install Python dependencies:
pip install -r requirements.txt -
Added
dtoverlay=spi0-0csto the bottom of/boot/firmware/config.txt(see raspberrypi/bookworm-feedback#179 ) -
The lookup tables for Pervasive displays are not open source. You need to contact them and then add to
src/display/pervasive_luts.py. It needs to have 2 arrays with hex codeints like:fastLUT=[0x00,0x23] globalLUT=[0x12,0x34] -
(optional) raise BT codec quality: Run
sudo systemctl edit bluealsafollow instructions and add--sbc-quality=xqto bluealsa's startup parameter. -
(optional) The radio has a small built-in webserver to control it, you can access it on port 80. This port is only accessible for root users, to circumvent this:
- run
which python - run
realpath [which result] - run
sudo setcap 'cap_net_bind_service=+ep' [realpath result]
- run
python3 main.py
You can set it to auto-run on startup e.g. cron:
- Log in as the user you want to run it.
- run
crontab -eand enter here:@reboot cd /home/[PATH_TO_REPO]/pi-radio/ && start_radio.sh(set it to executable withchmod +x, debug withjournalctl -u cron.service)
audio output: https://www.adafruit.com/product/3678
eink display: https://www.pervasivedisplays.com/product/5-81-e-ink-displays/
-
Check
alsamixer, it should display the Adafruit card. If not you can change it with sudo and run the program as root. -
Try connecting your BT speaker manually with
bluetoothctland check for errors. -
bluealsa-aplay --list-devices-- should list your BT device -
/bin/echo -e "show\ninfo 12:23:34:45:56" | bluetoothctl-- should list your BT device -
dbus-monitor --system-- Lists dbus messages. You should see here when BT connects -
sudo btmon-- shows low level BT messages. You should see button presses here -
Uninstall
pulseaudio, it conflicts withbluealsa
- Check with
evtestwhere your BT device is connected to, now its looking for a device whose name contains 'AVRCP'
check whats using it with cat /sys/kernel/debug/gpio
- use
libmpvinstead ofmpv, so it doesnt depends on distro updates - show errors/exceptions on the web control interface Add New features:
- Add "Audio Jack" to menu, when selected play via Jack.
Current BT/Jack logic: On startup try to connect to a saved BT device. When connected/disconnected to a BT device OR pressing play on a device OR changing channel play on BT if its connected, on Jack if its not.