Small bugfix while waiting for first two interrupts before entering mainloop
This commit is contained in:
parent
771cc49e2d
commit
284e8d8209
36
pi/power.py
36
pi/power.py
@ -26,23 +26,25 @@ def trans():
|
|||||||
|
|
||||||
|
|
||||||
def readgpio():
|
def readgpio():
|
||||||
gpio = open("/sys/class/gpio/gpio24/value", "r")
|
gpio = open("/sys/class/gpio/gpio24/value", "r")
|
||||||
gpiopoll = poll()
|
gpiopoll = poll()
|
||||||
gpiopoll.register(gpio, POLLERR)
|
gpiopoll.register(gpio, POLLERR)
|
||||||
if sys.stdout.isatty():
|
if sys.stdout.isatty():
|
||||||
print("wait for 2 interrupts...")
|
print("wait for 2 interrupts...")
|
||||||
gpioevent = gpiopoll.poll()
|
gpioevent = gpiopoll.poll()
|
||||||
gpio.read()
|
gpio.read()
|
||||||
gpio.seek(0)
|
gpio.seek(0)
|
||||||
last = time.time()
|
if sys.stdout.isatty():
|
||||||
gpioevent = gpiopoll.poll()
|
print("wait for 1 interrupt....")
|
||||||
gpio.read()
|
gpioevent = gpiopoll.poll()
|
||||||
gpio.seek(0)
|
last = time.time()
|
||||||
if sys.stdout.isatty():
|
gpio.read()
|
||||||
print("start readgpio mainloop")
|
gpio.seek(0)
|
||||||
while True:
|
if sys.stdout.isatty():
|
||||||
gpioevent = gpiopoll.poll()
|
print("start readgpio mainloop")
|
||||||
gpioval = gpio.read(1)
|
while True:
|
||||||
|
gpioevent = gpiopoll.poll()
|
||||||
|
gpioval = gpio.read(1)
|
||||||
gpio.seek(0)
|
gpio.seek(0)
|
||||||
if gpioval == '0':
|
if gpioval == '0':
|
||||||
now = time.time()
|
now = time.time()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user