small fixes
This commit is contained in:
parent
04c89778f3
commit
5e98f8e873
@ -165,16 +165,16 @@ for Spotify offline support install [ClSpotify](https://github.com/agent255/clsp
|
|||||||
```
|
```
|
||||||
printf "\n# setup hifiberry and i2s for Adafruit Speaker Bonnet\ndtoverlay=hifiberry-dac\ndtoverlay=i2s-mmap\n" | sudo tee -a /boot/config.txt
|
printf "\n# setup hifiberry and i2s for Adafruit Speaker Bonnet\ndtoverlay=hifiberry-dac\ndtoverlay=i2s-mmap\n" | sudo tee -a /boot/config.txt
|
||||||
```
|
```
|
||||||
- copy [contrib/config/asound.conf](contrib/config/asound.conf) to `/etc/asound.conf`.
|
- copy [contrib/config/adafruit/asound.conf](contrib/config/adafruit/asound.conf) to `/etc/asound.conf`.
|
||||||
|
|
||||||
```
|
```
|
||||||
cat /home/pi/luniebox/contrib/config/asound.conf | sudo tee /etc/asound.conf
|
cat /home/pi/luniebox/contrib/config/adafruit/asound.conf | sudo tee /etc/asound.conf
|
||||||
```
|
```
|
||||||
|
|
||||||
- copy [contrib/config/.asoundrc](contrib/config/.asoundrc) to `/home/pi/.asoundrc`.
|
- copy [contrib/config/adafruit/.asoundrc](contrib/config/adafruit/.asoundrc) to `/home/pi/.asoundrc`.
|
||||||
|
|
||||||
```
|
```
|
||||||
cat /home/pi/luniebox/contrib/config/.asoundrc | tee /home/pi/.asoundrc
|
cat /home/pi/luniebox/contrib/config/adafruit/.asoundrc | tee /home/pi/.asoundrc
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,6 +109,12 @@ class LunieboxDaemon(object):
|
|||||||
luniebox.stop()
|
luniebox.stop()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
def set_volume(self, volume):
|
||||||
|
volume_p = subprocess.Popen(
|
||||||
|
["amixer", "set", "PCM", volume + "%"], stdin=None,
|
||||||
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, close_fds=True, shell=False, group="pi", user="pi")
|
||||||
|
volume_p.wait()
|
||||||
|
|
||||||
def beep_sound(self):
|
def beep_sound(self):
|
||||||
self.play_sound("/home/pi/luniebox/audio/beep.wav",
|
self.play_sound("/home/pi/luniebox/audio/beep.wav",
|
||||||
str(self.luniebox.volume))
|
str(self.luniebox.volume))
|
||||||
@ -118,12 +124,10 @@ class LunieboxDaemon(object):
|
|||||||
self.luniebox.get_setting('luniebox', 'error_volume', self.luniebox.volume_max)))
|
self.luniebox.get_setting('luniebox', 'error_volume', self.luniebox.volume_max)))
|
||||||
|
|
||||||
def play_sound(self, path, volume):
|
def play_sound(self, path, volume):
|
||||||
volume_p = subprocess.Popen(
|
self.set_volume(volume)
|
||||||
["amixer", "set", "PCM", volume + "%"], stdin=None,
|
|
||||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, close_fds=True, shell=False, group="pi", user="pi")
|
|
||||||
volume_p.wait()
|
|
||||||
subprocess.Popen(["aplay", path], stdin=None,
|
subprocess.Popen(["aplay", path], stdin=None,
|
||||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, close_fds=True, shell=False, group="pi", user="pi")
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, close_fds=True, shell=False, group="pi", user="pi")
|
||||||
|
self.set_volume(100)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -9,6 +9,7 @@ import subprocess
|
|||||||
import time
|
import time
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
|
from turtle import update
|
||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
from spotifydl import SpotifyDL, SpotifyDLStatus
|
from spotifydl import SpotifyDL, SpotifyDLStatus
|
||||||
from mpd import MPDClient
|
from mpd import MPDClient
|
||||||
@ -369,6 +370,7 @@ class Luniebox(object):
|
|||||||
def mpd_list(self, path=''):
|
def mpd_list(self, path=''):
|
||||||
if self.mpd_connect():
|
if self.mpd_connect():
|
||||||
try:
|
try:
|
||||||
|
self.mpd(update(path))
|
||||||
result = self.mpd.listfiles(path)
|
result = self.mpd.listfiles(path)
|
||||||
return sorted(result, key=self.sort_mpd)
|
return sorted(result, key=self.sort_mpd)
|
||||||
except:
|
except:
|
||||||
|
@ -434,8 +434,8 @@ setup_adafruit() {
|
|||||||
echo "Setup Adafruit Speaker Bonnet"
|
echo "Setup Adafruit Speaker Bonnet"
|
||||||
sudo sed -i "/dtparam=audio=on/s/^/#/g" /boot/config.txt
|
sudo sed -i "/dtparam=audio=on/s/^/#/g" /boot/config.txt
|
||||||
printf "\n# setup hifiberry and i2s for Adafruit Speaker Bonnet\ndtoverlay=hifiberry-dac\ndtoverlay=i2s-mmap\n" | sudo tee -a /boot/config.txt 1>/dev/null
|
printf "\n# setup hifiberry and i2s for Adafruit Speaker Bonnet\ndtoverlay=hifiberry-dac\ndtoverlay=i2s-mmap\n" | sudo tee -a /boot/config.txt 1>/dev/null
|
||||||
cat /home/pi/luniebox/contrib/config/asound.conf | sudo tee /etc/asound.conf 1>/dev/null
|
cat /home/pi/luniebox/contrib/config/adafruit/asound.conf | sudo tee /etc/asound.conf 1>/dev/null
|
||||||
cat /home/pi/luniebox/contrib/config/.asoundrc | tee /home/pi/.asoundrc 1>/dev/null
|
cat /home/pi/luniebox/contrib/config/adafruit/.asoundrc | tee /home/pi/.asoundrc 1>/dev/null
|
||||||
REBOOT=true
|
REBOOT=true
|
||||||
echo "SETUP_AUDIO=true" | tee -a "${INSTALL_CONFIG_FILE}" 1>/dev/null
|
echo "SETUP_AUDIO=true" | tee -a "${INSTALL_CONFIG_FILE}" 1>/dev/null
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user