Skip to content

Commit

Permalink
Initial version of I2S digital audio
Browse files Browse the repository at this point in the history
  • Loading branch information
deckerego committed Jan 14, 2017
1 parent f47b0ba commit 94f9aa6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
37 changes: 37 additions & 0 deletions debian/python-hackclock.postinst
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
#!/bin/bash

chown -R pi:pi /home/pi/hack-clock

# Also modify /boot/config.txt
# Turn off audio and add dtoverlay=hifiberry-dac
# As well as dtoverlay=i2s-mmap
CONFIG=/boot/config.txt

if [ -e $CONFIG ] && grep -q "^dtoverlay=hifiberry-dac$" $CONFIG; then
echo "dtoverlay already active"
else
echo "dtoverlay=hifiberry-dac" | sudo tee -a $CONFIG
ASK_TO_REBOOT=true
fi

if [ -e $CONFIG ] && grep -q -E "^dtparam=audio=on$" $CONFIG; then
bcm2835off="no"
newline
echo "Disabling default sound driver"
sudo sed -i "s|^dtparam=audio=on$|#dtparam=audio=on|" $CONFIG &> /dev/null
if [ -e $LOADMOD ] && grep -q "^snd-bcm2835" $LOADMOD; then
sudo sed -i "s|^snd-bcm2835|#snd-bcm2835|" $LOADMOD &> /dev/null
fi
ASK_TO_REBOOT=true
elif [ -e $LOADMOD ] && grep -q "^snd-bcm2835" $LOADMOD; then
bcm2835off="no"
newline
echo "Disabling default sound module"
sudo sed -i "s|^snd-bcm2835|#snd-bcm2835|" $LOADMOD &> /dev/null
ASK_TO_REBOOT=true
else
newline
echo "Default sound driver currently not loaded"
bcm2835off="yes"
fi

speaker-test -l5 -c2 -t wav

amixer set PCM -- 85%
6 changes: 6 additions & 0 deletions etc/asound.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pcm.!default {
type hw card 0
}
ctl.!default {
type hw card 0
}
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def all_files(newroot, oldroot):
return fdtuples

base_data_files = [
('/etc', ['etc/hack-clock.conf']),
('/etc', ['etc/hack-clock.conf', 'etc/asound.conf']),
('/etc/init.d', ['etc/init.d/hack-clock']),
('/etc/default', ['etc/default/hack-clock']),
('/usr/share/doc/hack-clock', ['README.md', 'LICENSE', 'MANIFEST', 'requirements.txt'])
Expand Down

0 comments on commit 94f9aa6

Please sign in to comment.