parent
03c3f1a9f1
commit
996f417185
@ -0,0 +1,45 @@ |
||||
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) |
||||
|
Loading…
Reference in new issue