forked from pi-desktop/deb-make
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Note reboot but and suggested workaround * Update install.md * Reimplemented systemd services and scripts, cleaning up naming and comments
- Loading branch information
1 parent
0464430
commit ec7e816
Showing
11 changed files
with
90 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
Package: pidesktop-base | ||
Version: 0.1.3 | ||
Version: 0.1.4 | ||
Section: free | ||
Priority: optional | ||
Architecture: all | ||
Maintainer: hoopsurfer | ||
Description: PiDeskTop Case Power Support and mSATA Support | ||
|
||
Description: Pi DeskTop Case Power+RTC+mSATA Support |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
pidesktop-base/lib/systemd/system/pidesktop-powerkey.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[Unit] | ||
Description=PiDesktop Power Button Service | ||
After=local-fs.target | ||
|
||
[Service] | ||
Type=simple | ||
ExecStart=/usr/bin/python /usr/share/pidesktop/python/pd-powerkey.py | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
11 changes: 0 additions & 11 deletions
11
pidesktop-base/lib/systemd/system/pidesktop-rtcsync.service
This file was deleted.
Oops, something went wrong.
12 changes: 6 additions & 6 deletions
12
pidesktop-base/lib/systemd/system/pidesktop-shutdown.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
[Unit] | ||
Description=PiDesktop Shutdown Restart | ||
After=local-fs.target | ||
Description=PiDesktop Shutdown Reboot Service | ||
DefaultDependencies=no | ||
Before=shutdown.target | ||
|
||
[Service] | ||
Type=simple | ||
ExecStart=/usr/bin/python /usr/share/pidesktop/python/pd-restart.py | ||
Type=oneshot | ||
ExecStart=/usr/bin/python /usr/share/pidesktop/python/pd-shutdown.py | ||
|
||
[Install] | ||
WantedBy=multi-user.target | ||
|
||
WantedBy=reboot.target shutdown.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/user/bin/env python | ||
# | ||
# pd-powerkey.py - monitor GPIO to detect power key press | ||
# | ||
|
||
import RPi.GPIO as GPIO | ||
import time,os,sys | ||
|
||
GPIO.setwarnings(False) | ||
GPIO.setmode(GPIO.BOARD) | ||
GPIO.setup(31,GPIO.OUT) # Pi to Power MCU - start shutdown timer | ||
GPIO.setup(33,GPIO.IN) # Power MCU to Pi - power key pressed | ||
|
||
GPIO.output(31,GPIO.LOW) # tell PCU we are alive | ||
GPIO.output(31,GPIO.HIGH) # cause blink by starting shutdown timer | ||
time.sleep(0.5) | ||
GPIO.output(31,GPIO.LOW) # clear timer we really are alive | ||
|
||
# callback function | ||
def powerkey_pressed(channels): | ||
os.system("sync") | ||
os.system("shutdown -h now") | ||
sys.exit() | ||
|
||
# wait for power key press | ||
GPIO.add_event_detect(33,GPIO.RISING,callback=powerkey_pressed) | ||
|
||
# idle - TODO: use wait | ||
while True: | ||
time.sleep(10) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/user/bin/env python | ||
|
||
# pd-shutdown.py - oneshot service so do your thing and exit | ||
# | ||
# We are in shutdown processing either because shutdown or reboot is running or because | ||
# the power button was pressed. If we're here because the power button was pressed then | ||
# Power MCU is already in Waiting OFF state and will turn off immediately if it sees | ||
# pin 31 go high. If power button has not been pressed we should inform power MCU | ||
# shutdown/reboot is taking place so the shutdown timer can start. | ||
# | ||
# Note: The timer will reset when the Pi powers off so the only purpose REALLY for doing | ||
# this is to force a power off if shutdown hangs for some reason - somewhat lame. | ||
|
||
import RPi.GPIO as GPIO | ||
|
||
GPIO.setwarnings(False) | ||
GPIO.setmode(GPIO.BOARD) # Use physical board pin numbering | ||
GPIO.setup(31,GPIO.OUT) # Pi to Power MCU communication | ||
GPIO.setup(33,GPIO.IN) # Power MCU to Pi on power button press | ||
|
||
if GPIO.input(33): | ||
# Power Key was already pressed - shut the system down immediately | ||
else: | ||
# shutdown or reboot not related to power key | ||
GPIO.output(31,GPIO.HIGH) # tell power MCU and exit immediately |