Initial commit

This commit is contained in:
Noah
2018-12-21 08:12:54 +00:00
commit 30903a207b
26 changed files with 2851 additions and 0 deletions

16
raspberry-pi/gpio-shutdown.py Executable file
View File

@@ -0,0 +1,16 @@
#!/usr/bin/python
#
# Watch board pin number 5 for level changes and initiate a power-off
# when this pin goes low.
#
from RPi import GPIO
from subprocess import call
# https://pinout.xyz/pinout/i2c
pin = 5 # a.k.a BCM 3 a.k.a SCL
GPIO.setmode(GPIO.BOARD)
GPIO.setup(pin, GPIO.IN)
GPIO.wait_for_edge(pin, GPIO.FALLING)
print('Board pin number 5 dropped to low, initiating poweroff')
call(["/bin/systemctl","poweroff","--force"])

View File

@@ -0,0 +1,11 @@
[Unit]
Description=Shutdown Pi when GPIO 5 is tied to ground
After=network.target
[Service]
ExecStart=/home/pi/lamatrix/raspberry-pi/gpio-shutdown.py
User=pi
Group=pi
[Install]
WantedBy=basic.target

View File

@@ -0,0 +1,15 @@
[Unit]
Description=Run LaMatrix main loop
After=network.target
[Service]
ExecStart=/usr/bin/env python /home/pi/lamatrix/main.py
WorkingDirectory=/home/pi/lamatrix
StandardOutput=null
Restart=on-failure
RestartSec=60s
User=pi
Group=pi
[Install]
WantedBy=basic.target