New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Less active wait #3

Merged
merged 2 commits into from Sep 26, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+4 −2
Diff settings

Always

Just for now

Next

Patch to sleep in active wait loop, prevents LowBatteryShutdown from …

…consuming processor

pi@picam:~ $ top
top - 08:38:10 up 3 min,  2 users,  load average: 1.41, 1.41, 0.66
Tasks:  99 total,   2 running,  67 sleeping,   0 stopped,   1 zombie
%Cpu(s): 98.7 us,  1.3 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :   378904 total,    50872 free,   120048 used,   207984 buff/cache
KiB Swap:   102396 total,   102396 free,        0 used.   203500 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
  309 root      20   0   17376   5036   3348 R 90.1  1.3   2:33.96 python

pi@picam:~ $ ps -ef | grep 309
root       309   294 55 08:34 ?        00:01:13 python /home/pi/LowBatteryShutdown/LowBatteryShutdown.py
  • Loading branch information...
doyleyoung committed Sep 14, 2018
commit 7a36db2142a0464f8f4655ea93fe148130dae388
Copy path View file
@@ -7,6 +7,7 @@
# There is also no warranty provided of any kind with this code.

import os
import time
import RPi.GPIO as GPIO

# This is going to let us use the BCM pin numbers. The number on JuiceBox
@@ -31,13 +32,14 @@ def shutdown_callback_function( shutdown_pin ):
# HIGH and that the callback function has been entered. This is mostly
# useful for debugging.
#print("the low battery pin is HIGH now, shutting down.")

os.system("sudo shutdown -h now")

# This is the magic line that adds pin 16 so it is always being watched.
GPIO.add_event_detect(shutdown_pin, GPIO.RISING, callback=shutdown_callback_function)

# Now we wait here for something amazing to happen
while True:
# Do Nothing
# Do Nothing - slowly
time.sleep(1)
pass
ProTip! Use n and p to navigate between commits in a pull request.