[FEAT] frame: --bird-weather draws the collage from a ZIP code, no mic (#12)

This commit is contained in:
Teddy Warner
2026-06-19 19:52:21 -07:00
committed by GitHub
parent 3cf7ac191b
commit 10548dbca7
5 changed files with 384 additions and 25 deletions
+67 -7
View File
@@ -1,10 +1,31 @@
#!/usr/bin/env bash
# Install the AvianVisitors e-ink frame (display side) on a Raspberry Pi.
# Enables SPI + I2C, installs deps, makes a venv, installs the systemd timer.
#
# Default mode mirrors a local bird mic (set the image source in the config).
# Pass --bird-weather --zip <ZIP> to instead run the frame standalone from
# BirdWeather data for that ZIP: it renders on the Pi and pulls cutouts from the
# repo's raw GitHub URLs, so no mic and no local illustration folder are needed.
set -euo pipefail
cd "$(dirname "$0")"
FRAME="$(pwd)"
BIRD_WEATHER=0
ZIP=""
while [ $# -gt 0 ]; do
case "$1" in
--bird-weather) BIRD_WEATHER=1 ;;
--zip) ZIP="${2:-}"; shift ;;
--zip=*) ZIP="${1#*=}" ;;
*) echo "unknown argument: $1" >&2; exit 1 ;;
esac
shift
done
if [ "$BIRD_WEATHER" = 1 ] && [ -z "$ZIP" ]; then
echo "--bird-weather needs --zip <ZIP code>, e.g. install.sh --bird-weather --zip 94107" >&2
exit 1
fi
CONFIG_TXT=/boot/firmware/config.txt
[ -f "$CONFIG_TXT" ] || CONFIG_TXT=/boot/config.txt
@@ -21,24 +42,63 @@ echo "3/5 Creating venv and installing Python deps..."
python3 -m venv .venv
.venv/bin/pip install -q --upgrade pip
.venv/bin/pip install -q -r requirements-frame.txt
if [ "$BIRD_WEATHER" = 1 ]; then
echo " BirdWeather mode: installing Playwright + Chromium for on-Pi rendering (a few minutes)..."
.venv/bin/pip install -q playwright
sudo .venv/bin/playwright install-deps chromium
.venv/bin/playwright install chromium
fi
echo "4/5 Setting up config..."
mkdir -p "$HOME/.birdframe"
[ -f "$HOME/.birdframe/config.toml" ] || cp config.example.toml "$HOME/.birdframe/config.toml"
echo "5/5 Installing systemd timer..."
sed "s|/home/monalisa/AvianVisitors/frame|$FRAME|g; s|/home/monalisa|$HOME|g; s|User=monalisa|User=$USER|" \
systemd/birdframe.service | sudo tee /etc/systemd/system/birdframe.service >/dev/null
sudo cp systemd/birdframe.timer /etc/systemd/system/birdframe.timer
sudo systemctl daemon-reload
sudo systemctl enable birdframe.timer
echo "5/5 Installing systemd service + timer..."
if [ "$BIRD_WEATHER" = 1 ]; then
PY="$FRAME/.venv/bin/python"
PNG="$HOME/.birdframe/frame.png"
sudo tee /etc/systemd/system/birdframe.service >/dev/null <<SERVICE
[Unit]
Description=AvianVisitors frame, BirdWeather mode (ZIP $ZIP)
Documentation=https://github.com/Twarner491/AvianVisitors
Wants=network-online.target
After=network-online.target
cat <<DONE
[Service]
Type=oneshot
User=$USER
WorkingDirectory=$FRAME
ExecStart=/bin/sh -c '$PY $FRAME/shoot.py --bird-weather --zip "$ZIP" --out $PNG && $PY $FRAME/display.py --config $HOME/.birdframe/config.toml --image-url $PNG --no-signature --force'
Environment=PYTHONUNBUFFERED=1
Nice=10
TimeoutStartSec=300
SERVICE
# BirdWeather's recent-species list drifts slowly, so refresh a few times a day.
sed 's|OnUnitActiveSec=.*|OnUnitActiveSec=6h|' systemd/birdframe.timer \
| sudo tee /etc/systemd/system/birdframe.timer >/dev/null
else
sed "s|/home/monalisa/AvianVisitors/frame|$FRAME|g; s|/home/monalisa|$HOME|g; s|User=monalisa|User=$USER|" \
systemd/birdframe.service | sudo tee /etc/systemd/system/birdframe.service >/dev/null
sudo cp systemd/birdframe.timer /etc/systemd/system/birdframe.timer
fi
sudo systemctl daemon-reload
sudo systemctl enable --now birdframe.timer # --now starts it immediately, not only on the next boot
if [ "$BIRD_WEATHER" = 1 ]; then
cat <<DONE
Installed in BirdWeather mode for ZIP $ZIP. The frame renders the top birds
near you on the Pi and refreshes every 6 hours. Cutouts come from the repo on
GitHub, so add illustrations there for any local birds it is missing.
DONE
else
cat <<DONE
Installed. Set your image source in ~/.birdframe/config.toml (your /frame.png
key, or shoot = true); the panel fills itself in and refreshes every 15 min,
only when the birds change.
DONE
fi
# SPI only takes effect on a reboot, so do it for the user. Skip if SPI is
# already up (e.g. a re-run) so we don't bounce a working frame.