Skip to content

Commit

Permalink
Add components folder to installation and docs. First component is hi…
Browse files Browse the repository at this point in the history
…fiberry sound card
  • Loading branch information
pabera committed Dec 19, 2023
1 parent 9dceb84 commit 705c277
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 86 deletions.
3 changes: 3 additions & 0 deletions documentation/builders/components/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Phoniebox components directory

* [Hifberry](./hifiberry.md)
41 changes: 41 additions & 0 deletions documentation/builders/components/hifiberry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# HiFiBerry

## Automatic setup

Use this install script to enable your HiFiBerry board.

```
$ cd; cd ~/RPi-Jukebox-RFID/installation/components && chmod +x setup-hifiberry.sh && sudo ./setup_hifiberry.sh
```

## Manual steps to enable sound through HiFiBerry board

1. Make sure your onboard sound of your Raspberry Pi is disabled. Check `/boot/config.txt`. The installation

```
dtparam=audio=off
```
2. Run the following command to enable HiFiBerry boards.
```
echo "dtoverlay=hifiberry-dac" | sudo tee -a /boot/config.txt
```
3. Enable volume control. Create or edit the following file: `sudo vi /etc/asound.conf`
```
pcm.hifiberry {
type softvol
slave.pcm "plughw:0"
control.name "HifiBerry"
control.card 0
}
pcm.!default {
type plug
slave.pcm "hifiberry"
}
```
4. Restart your device.
38 changes: 38 additions & 0 deletions installation/components/setup_hifiberry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

# Check if the script is run as root
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi

# Disable onboard sound of Raspberry Pi
echo "Disabling onboard sound..."
sed -i '/dtparam=audio=on/c\dtparam=audio=off' /boot/config.txt

# Enable HiFiBerry board
echo "Enabling HiFiBerry board..."
grep -qxF 'dtoverlay=hifiberry-dac' /boot/config.txt || echo 'dtoverlay=hifiberry-dac' >> /boot/config.txt

# Backup asound.conf
if [ -f /etc/asound.conf ]; then
echo "Backing up existing asound.conf..."
cp /etc/asound.conf "/etc/asound.conf.backup.$(date +%Y%m%d%H%M%S)"
fi

echo "Configuring sound settings..."
cat > /etc/asound.conf << EOF
pcm.hifiberry {
type softvol
slave.pcm "plughw:0"
control.name "HifiBerry"
control.card 0
}
pcm.!default {
type plug
slave.pcm "hifiberry"
}
EOF

echo "Configuration complete. Please restart your device."
Loading

0 comments on commit 705c277

Please sign in to comment.