Initial commit
This commit is contained in:
16
raspberry-pi/gpio-shutdown.py
Executable file
16
raspberry-pi/gpio-shutdown.py
Executable 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"])
|
||||
11
raspberry-pi/gpio-shutdown.service
Normal file
11
raspberry-pi/gpio-shutdown.service
Normal 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
|
||||
15
raspberry-pi/lamatrix.service
Normal file
15
raspberry-pi/lamatrix.service
Normal 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
|
||||
Reference in New Issue
Block a user