Skip to content

Commit

Permalink
Merge pull request #29 from deckerego/detect_i2s
Browse files Browse the repository at this point in the history
Detect i2s
  • Loading branch information
deckerego committed Mar 3, 2017
2 parents 9bee3a1 + 0034eef commit 83d13f3
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 34 deletions.
5 changes: 4 additions & 1 deletion README.md
Expand Up @@ -21,7 +21,7 @@ I'm assuming that you are starting with the Raspian Minimal Linux distribution.
1. Make sure your Raspberry Pi is up to date with the latest packages & firmware with `sudo apt-get update; sudo apt-get dist-upgrade`
2. Enable I2C by executing `sudo raspi-config` as described in Adafruit's tutorial: https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c
3. Add the necessary Python and GStreamer dependencies using the command: `sudo apt-get install wiringpi python-bottle python-requests python-oauth2client python-httplib2 python-setuptools python-pip python-dev python-dateutil python-smbus gstreamer0.10-x gstreamer-tools gstreamer0.10-plugins-base gstreamer0.10-plugins-good gstreamer0.10-plugins-bad gstreamer0.10-plugins-ugly python-gst0.10`
4. Install hack-clock via `wget https://github.com/deckerego/hack-clock/releases/download/2.1.6/python-hackclock_2.1.6-1_all.deb; sudo dpkg -i python-hackclock_2.1.6-1_all.deb`
4. Install hack-clock via `wget https://github.com/deckerego/hack-clock/releases/download/2.1.7/python-hackclock_2.1.7-1_all.deb; sudo dpkg -i python-hackclock_2.1.7-1_all.deb`
5. Tweak `/etc/hack-clock.conf` and `/etc/default/hack-clock` to fit your needs (GPIO pins, correct weather station, etc.). A list of observed weather stations is available at http://forecast.weather.gov/stations.php
6. Reboot your Pi to re-load modules and start the IDE web server

Expand Down Expand Up @@ -62,6 +62,9 @@ commenting out the I2S interfaces and un-commenting the `audio=on` parameter. Fo
#dtoverlay=hifiberry-dac
#dtoverlay=i2s-mmap

Once you have commented out the I2S settings as shown above, subsequent upgrades should
just skip the I2S changes so you don't need to keep re-commenting things out.

You will also need to remove the custom `/etc/asound.conf` configuration file on your Pi -
it does not need to be present if you are using the headphone jack.

Expand Down
5 changes: 3 additions & 2 deletions debian/changelog
@@ -1,5 +1,6 @@
hackclock (2.1.6-1) stable; urgency=low
hackclock (2.1.7-1) stable; urgency=low

* Fixed IFTTT event name trigger
* Detect if I2S is already _ignored_, then allow standard Pi audio to continue
* Changed icons for "save" and "restore" in IDE

-- DeckerEgo <john@deckerego.net> Tue, 01 Mar 2017 21:32:00 -0500
47 changes: 26 additions & 21 deletions debian/python-hackclock.postinst
Expand Up @@ -10,28 +10,33 @@ chown -R pi:pi /home/pi/hack-clock
echo "Installing missing Python modules..."
pip install -r /usr/share/doc/hack-clock/requirements.txt

# Set the hifiberry-dac i2s module
echo "Installing I2S audio..."
if [ -e $BOOT_CONFIG ] && grep -q "^dtoverlay=hifiberry-dac$" $BOOT_CONFIG; then
echo "hifiberry already installed"
# If I2S audio is already ignored, don't insert the I2S overlays
if [ -e /boot/config.txt ] && grep -q -E "^#.*dtoverlay=i2s-mmap" /boot/config.txt; then
echo "I2S already ignored, skipping I2S overlay"
else
echo "dtoverlay=hifiberry-dac" | sudo tee -a $BOOT_CONFIG
fi

# Enable (optional) i2s-mmap to get rid of popping and set volumes
if [ -e $BOOT_CONFIG ] && grep -q "^dtoverlay=i2s-mmap$" $BOOT_CONFIG; then
echo "i2s-mmap already installed"
else
echo "dtoverlay=i2s-mmap" | sudo tee -a $BOOT_CONFIG
fi

# Make sure old audio is disabled
if [ -e $BOOT_CONFIG ] && grep -q -E "^dtparam=audio=on$" $BOOT_CONFIG; then
echo "Commenting out dtparam=audio=on in $BOOT_CONFIG"
sudo sed -i "s|^dtparam=audio=on$|#dtparam=audio=on|" $BOOT_CONFIG &> /dev/null
elif [ -e $MOD_CONFIG ] && grep -q "^snd-bcm2835" $MOD_CONFIG; then
echo "Commenting out snd-bcm2835 in $MOD_CONFIG"
sudo sed -i "s|^snd-bcm2835|#snd-bcm2835|" $MOD_CONFIG &> /dev/null
# Set the hifiberry-dac i2s module
echo "Installing I2S audio..."
if [ -e $BOOT_CONFIG ] && grep -q "^dtoverlay=hifiberry-dac$" $BOOT_CONFIG; then
echo "hifiberry already installed"
else
echo "dtoverlay=hifiberry-dac" | sudo tee -a $BOOT_CONFIG
fi

# Enable (optional) i2s-mmap to get rid of popping and set volumes
if [ -e $BOOT_CONFIG ] && grep -q "^dtoverlay=i2s-mmap$" $BOOT_CONFIG; then
echo "i2s-mmap already installed"
else
echo "dtoverlay=i2s-mmap" | sudo tee -a $BOOT_CONFIG
fi

# Make sure old audio is disabled
if [ -e $BOOT_CONFIG ] && grep -q -E "^dtparam=audio=on$" $BOOT_CONFIG; then
echo "Commenting out dtparam=audio=on in $BOOT_CONFIG"
sudo sed -i "s|^dtparam=audio=on$|#dtparam=audio=on|" $BOOT_CONFIG &> /dev/null
elif [ -e $MOD_CONFIG ] && grep -q "^snd-bcm2835" $MOD_CONFIG; then
echo "Commenting out snd-bcm2835 in $MOD_CONFIG"
sudo sed -i "s|^snd-bcm2835|#snd-bcm2835|" $MOD_CONFIG &> /dev/null
fi
fi

# Boot upon start
Expand Down
2 changes: 1 addition & 1 deletion package.sh
Expand Up @@ -7,7 +7,7 @@ rm home/pi/hack-clock/backups/blocks_clock.*

cd ..
echo "Compressing file..."
tar Jcf hackclock_2.1.6.orig.tar.xz hack-clock/
tar Jcf hackclock_2.1.7.orig.tar.xz hack-clock/

cd hack-clock
dpkg-buildpackage -rfakeroot -uc -us
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -27,7 +27,7 @@ def all_files(newroot, oldroot):

setup(
name='HackClock',
version='2.1.6',
version='2.1.7',
description='A hackable alarm clock for the Raspberry Pi',
author='DeckerEgo',
author_email='john@deckerego.net',
Expand Down
8 changes: 4 additions & 4 deletions srv/hackclock/views/blocks/editor.tpl
Expand Up @@ -29,15 +29,15 @@
<div class="btn-group btn-group-lg" role="group" >
<button type="button" class="btn btn-default" aria-label="Save" onClick="saveBlocks(workspace, saveCallback);">
% if status == "Saved":
<span class="glyphicon glyphicon-floppy-saved" aria-hidden="true"></span>
<span class="glyphicon glyphicon-play" aria-hidden="true"></span>
% elif status == "Failed":
<span class="glyphicon glyphicon-floppy-remove" aria-hidden="true"></span>
<span class="glyphicon glyphicon-play" aria-hidden="true"></span>
% else:
<span class="glyphicon glyphicon-floppy-save" aria-hidden="true"></span>
<span class="glyphicon glyphicon-play" aria-hidden="true"></span>
% end
</button>
<button type="button" class="btn btn-default" aria-label="Restore" onClick="window.location='/blocks/backups';">
<span class="glyphicon glyphicon-floppy-open" aria-hidden="true"></span>
<span class="glyphicon glyphicon-folder-open" aria-hidden="true"></span>
</button>
<button type="button" class="btn btn-default" aria-label="Refresh" onClick="restartClock(this, 'runstatus');">
<span class="glyphicon glyphicon-refresh" aria-hidden="true"></span>
Expand Down
8 changes: 4 additions & 4 deletions srv/hackclock/views/python/editor.tpl
Expand Up @@ -32,15 +32,15 @@
<div class="btn-group btn-group-lg" role="group" >
<button type="button" class="btn btn-default" aria-label="Save" onClick="savePython(editor.getValue(), saveCallback);">
% if status == "Saved":
<span class="glyphicon glyphicon-floppy-saved" aria-hidden="true"></span>
<span class="glyphicon glyphicon-play" aria-hidden="true"></span>
% elif status == "Failed":
<span class="glyphicon glyphicon-floppy-remove" aria-hidden="true"></span>
<span class="glyphicon glyphicon-play" aria-hidden="true"></span>
% else:
<span class="glyphicon glyphicon-floppy-save" aria-hidden="true"></span>
<span class="glyphicon glyphicon-play" aria-hidden="true"></span>
% end
</button>
<button type="button" class="btn btn-default" aria-label="Restore" onClick="window.location='/python/backups';">
<span class="glyphicon glyphicon-floppy-open" aria-hidden="true"></span>
<span class="glyphicon glyphicon-folder-open" aria-hidden="true"></span>
</button>
<button type="button" class="btn btn-default" aria-label="Refresh" onClick="restartClock(this, 'runstatus');">
<span class="glyphicon glyphicon-refresh" aria-hidden="true"></span>
Expand Down

0 comments on commit 83d13f3

Please sign in to comment.