Last active
September 4, 2018 18:08
-
-
Save aenniw/c74958f8e9ed7f8642c15de98bf57881 to your computer and use it in GitHub Desktop.
Volumio for OrangePiZero
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
verbosity=1 | |
logo=disabled | |
console=both | |
disp_mode=1920x1080p60 | |
overlay_prefix=sun8i-h3 | |
overlays=i2c0 usbhost2 usbhost3 spi-spidev | |
param_spidev_spi_bus=1 | |
rootdev=/dev/mmcblk0p2 | |
rootfstype=ext4 | |
user_overlays=sun8i-h3-i2s0 | |
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u | |
extraargs=imgpart=/dev/mmcblk0p2 imgfile=/volumio_current.sqsh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# DEPENDENCIES | |
# apt-get -y install fbi curl | |
# PINOUT: Display -> Raspberry Pi Zero | |
# BL -> pin 12 (GPIO 18) | |
# SCK -> pin 23 (GPIO 11) | |
# MISO -> pin 21 (GPIO 9) | |
# MOSI -> pin 19 (GPIO 10) | |
# CS -> pin 24 (GPIO 8) | |
# RST -> pin 22 (GPIO 25) | |
# D/C -> pin 18 (GPIO 24) | |
# VIN -> pin 17 (3.3v) | |
# GND -> pin 20 (GND) | |
# PINOUT: Display -> Orange Pi Zero | |
# BL -> pin 15 (GPIO 3) | |
# SCK -> pin 23 (GPIO 14) | |
# MOSI -> pin 19 (GPIO 15) | |
# CS -> pin 24 (GPIO 13) | |
# RST -> pin 11 (GPIO 1) | |
# D/C -> pin 13 (GPIO 0) | |
# VIN -> pin 2 (3.3v) | |
# GND -> pin 20 (GND) | |
VERBOSE=${VERBOSE:-false} | |
VOLUMIO_HOST="http://localhost:3000" | |
ALBUM_ART_FILE="/tmp/albumart.image" | |
DEFAULT_ALBUM_ART_FILE="${ALBUM_ART_FILE}.default" | |
FB=/dev/fb0 | |
function hasBinary() { | |
for arg in $@; do | |
hash ${1} || ( echo "Missing binary ${1}"; exit 1); | |
done | |
} | |
function restApiGet() { | |
curl "${VOLUMIO_HOST}/api/v1/getstate" 2> /dev/null | jq -r "${1}" | |
} | |
function downloadAlbumArt() { | |
curl ${1} > ${2} 2> /dev/null | |
} | |
hasBinary fbi curl | |
lsmod | grep -q fbtft_device || \ | |
modprobe fbtft_device custom name=fb_ili9341 gpios=reset:1,dc:0,led:3 speed=16000000 fps=25 rotate=90 busnum=1 | |
# opi-zero modprobe fbtft_device custom name=fb_ili9341 gpios=reset:1,dc:0,led:3 speed=16000000 fps=25 rotate=90 busnum=1 | |
# rpi-zero modprobe fbtft_device custom name=fb_ili9341 gpios=reset:25,dc:24,led:7 speed=16000000 bgr=1 rotate=90 | |
LAST_TRACK='none' | |
test -f ${DEFAULT_ALBUM_ART_FILE} || \ | |
downloadAlbumArt "${VOLUMIO_HOST}/albumart" ${DEFAULT_ALBUM_ART_FILE} | |
fbi -d ${FB} -T 1 -noverbose -a ${DEFAULT_ALBUM_ART_FILE} 2> /dev/null | |
while [[ true ]]; do | |
sleep 1 | |
CUR_TRACK=`restApiGet '.title,.artist,.album'` | |
if [[ "${LAST_TRACK}" == "${CUR_TRACK}" ]]; then | |
[ "${VERBOSE}" == "true" ] && echo -e "$(date)\tSkipping no change." | |
continue | |
else | |
LAST_TRACK=${CUR_TRACK} | |
fi | |
STATUS=`restApiGet '.status'` | |
if [[ "${STATUS}" == "play" ]] || [[ "${STATUS}" == "pause" ]]; then | |
[ "${VERBOSE}" == "true" ] && echo -e "$(date)\tDownloading current albumart." | |
ALBUM_ART_URI=`restApiGet '.albumart'` | |
echo ${ALBUM_ART_URI} | grep "^/albumart?" && ALBUM_ART_URI="${VOLUMIO_HOST}${ALBUM_ART_URI}" | |
downloadAlbumArt ${ALBUM_ART_URI} ${ALBUM_ART_FILE} | |
fbi -d ${FB} -T 1 -noverbose -a ${ALBUM_ART_FILE} 2> /dev/null || LAST_TRACK='' | |
else | |
[ "${VERBOSE}" == "true" ] && echo -e "$(date)\tChanging to stock albumart." | |
fbi -d ${FB} -T 1 -noverbose -a ${DEFAULT_ALBUM_ART_FILE} 2> /dev/null | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment