|
|
@@ -3,6 +3,7 @@ |
|
|
|
Linux box with a loudspeaker and an emergency light to be used for announcements and notifications. |
|
|
|
|
|
|
|
## Hardware |
|
|
|
### Overview |
|
|
|
* SBC with GPIOs and sound output :: OrangePi Zero with an expansion board |
|
|
|
* PA system |
|
|
|
* speaker :: 30W, 4 Ohms horn loudspeaker |
|
|
@@ -11,12 +12,30 @@ Linux box with a loudspeaker and an emergency light to be used for announcements |
|
|
|
* Warning Light system |
|
|
|
* warning light :: 12V 10W rotary orange warning light |
|
|
|
* relay module :: 12V low trigger relay |
|
|
|
|
|
|
|
* System Activity Light system |
|
|
|
* indicator LED |
|
|
|
* Human Activity Sensor system |
|
|
|
* PIR module |
|
|
|
|
|
|
|
### Building |
|
|
|
TBD |
|
|
|
|
|
|
|
## Software |
|
|
|
### Overview |
|
|
|
* Operating System - Linux :: Armbian Bullseye for the OrangePi Zero |
|
|
|
* PA System |
|
|
|
* Voice Synthesizer :: Festival / ESpeak |
|
|
|
|
|
|
|
### Installation |
|
|
|
Run as root: |
|
|
|
```bash |
|
|
|
cp toolkit/* /usr/local/bin/ |
|
|
|
|
|
|
|
cp etc/systemd/system /etc/systemd/system |
|
|
|
systemctl enable --now system-activity-light.service |
|
|
|
systemctl enable --now human-activity-sensor.service |
|
|
|
``` |
|
|
|
|
|
|
|
## Implementation Notes |
|
|
|
|
|
|
|
### Armbian + OrangePi Zero Installation |
|
|
@@ -44,21 +63,6 @@ cd wiringOP |
|
|
|
./build |
|
|
|
``` |
|
|
|
|
|
|
|
#### Initialize GPIOs |
|
|
|
```bash |
|
|
|
# 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 |
|
|
|
``` |
|
|
|
|
|
|
|
### PA System |
|
|
|
#### Enabling mixed sound output |
|
|
|
```bash |
|
|
@@ -90,78 +94,10 @@ espeak -f ssml.txt -m |
|
|
|
sox infile.wav outfile.wav downsample echo 0.5 1 1 1 |
|
|
|
``` |
|
|
|
|
|
|
|
#### Playing a sound file |
|
|
|
```bash |
|
|
|
aplay file.wav |
|
|
|
mplayer file.mp3 |
|
|
|
``` |
|
|
|
|
|
|
|
### Emergency Light |
|
|
|
#### Control Script |
|
|
|
```bash |
|
|
|
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 |
|
|
|
``` |
|
|
|
|
|
|
|
### System Activity Light |
|
|
|
#### System Usage |
|
|
|
```bash |
|
|
|
uptime | head -n 1 | cut -f3 -d, | cut -f2 -d: |
|
|
|
``` |
|
|
|
|
|
|
|
#### Daemon |
|
|
|
```bash |
|
|
|
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 |
|
|
|
``` |
|
|
|
|
|
|
|
```bash |
|
|
|
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 |
|
|
|
``` |
|
|
|
### Human Activity Sensor |
|
|
|
|
|
|
|
#### Reading File Timestamp |
|
|
|
```bash |
|
|
|
sudo systemctl enable --now system-activity-light.service |
|
|
|
stat /var/tmp/human_last_seen --format=%Y |
|
|
|
``` |
|
|
|
|