a webcam with a 5 second, 30 minute, or 24 hour delay
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mirror-to-yesterday/lines_test.py

45 lines
1.3 KiB

import gpiod, time
from gpiod.line import Direction, Value
#lines_test.py
lines = {
"five_second": 2,
"thirty_second": 3,
"five_minute": 4,
"twelve_hour": 5,
"twenty_four_hour": 6
}
def tellme(iolines, label):
value = iolines.get_value(lines[label])
if not value:
print(f"{label} is inactive with value {value}")
return True
return False
#with keep.presenting():
with gpiod.request_lines(
"/dev/gpiochip4",
consumer="mirror-to-yesterday",
config={
lines["five_second"]: gpiod.LineSettings(direction=Direction.INPUT),
lines["thirty_second"]: gpiod.LineSettings(direction=Direction.INPUT),
lines["five_minute"]: gpiod.LineSettings(direction=Direction.INPUT),
lines["twelve_hour"]: gpiod.LineSettings(direction=Direction.INPUT),
lines["twenty_four_hour"]: gpiod.LineSettings(direction=Direction.INPUT)
}
) as io_lines:
while True:
if tellme(io_lines, "five_second"):
pass
elif tellme(io_lines, "thirty_second"):
pass
elif tellme(io_lines, "five_minute"):
pass
elif tellme(io_lines, "twelve_hour"):
pass
elif tellme(io_lines, "twenty_four_hour"):
pass
else:
print("none are active")
time.sleep(0.5)