Dejvino 4208bc54c7 | 3 years ago | |
---|---|---|
bin | 3 years ago | |
sounds | 3 years ago | |
toolkit | 3 years ago | |
README.md | 3 years ago |
Linux box with a loudspeaker and an emergency light to be used for announcements and notifications.
sudo armbian-config
# System > Hardware > [*] analog-codec
apt install mplayer espeak-ng
# upstream:
#git clone https://github.com/orangepi-xunlong/wiringOP
# enhanced:
git clone https://github.com/Dejvino/wiringOP
cd wiringOP
./build clean
./build
# System Activity Indicator
PIN_SALIGHT=11
gpio mode $PIN_SALIGHT output
# Emergency Light system
PIN_ELIGHT=7
gpio mode $PIN_ELIGHT output
# PA system
PIN_PASOUND=5
gpio mode $PIN_PASOUND output
cat ~/.asoundrc
pcm.!default plug:dmix
## Festival
# reading
...
# to file
text2wave text.txt > wave.wav
## ESpeak
# voices:
ls /usr/lib/arm-linux-gnueabihf/espeak-data/voices/
# reading
espeak -f text.txt -p 40 -s 160 -v "en-us"
# to file
espeak -f text.txt -p 40 -s 160 -k15 -g 1 -w wave.wav
# using SSML (e.g.: https://www.xml.com/pub/a/2004/10/20/ssml.html)
espeak -f ssml.txt -m
sox infile.wav outfile.wav downsample echo 0.5 1 1 1
aplay file.wav
mplayer file.mp3
cat /usr/local/bin/emergency-light
#!/bin/bash
PIN_ELIGHT=7
# init
gpio mode $PIN_ELIGHT output
# command
if [[ "$1" == "on" ]]; then
gpio write $PIN_ELIGHT 1
elif [[ "$1" == "off" ]]; then
gpio write $PIN_ELIGHT 0
elif [[ "$1" == "read" ]]; then
gpio read $PIN_ELIGHT
else
gpio toggle $PIN_ELIGHT
fi
uptime | head -n 1 | cut -f3 -d, | cut -f2 -d:
cat /etc/systemd/system/system-activity-light.service
[Unit]
Description=System Activity Light Daemon
[Service]
ExecStart=/usr/sbin/system-activity-light-daemon
[Install]
WantedBy=multi-user.target
cat /usr/sbin/system-activity-light-daemon
#!/bin/bash
DELAY=10000
while [[ true ]]; do
ACTIVITY=2000
TOP=`system-usage`
if (( $(echo "$TOP > 1.0" | bc -l) )); then
ACTIVITY=50
elif (( $(echo "$TOP > 0.75" | bc -l) )); then
ACTIVITY=100
elif (( $(echo "$TOP > 0.5" | bc -l) )); then
ACTIVITY=500
elif (( $(echo "$TOP > 0.2" | bc -l) )); then
ACTIVITY=1000
fi
echo $TOP
system-activity-light blink $ACTIVITY $DELAY
done
sudo systemctl enable --now system-activity-light.service