summaryrefslogtreecommitdiff
path: root/kvmd/aiogp.py
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-09-14 14:23:14 +0300
committerDevaev Maxim <[email protected]>2020-09-14 14:23:14 +0300
commitddb60e5a73c0860bf4187571e0e2458a6e9a6d77 (patch)
tree5843b242cfc55e16a7c1dfd343fade75f80891c2 /kvmd/aiogp.py
parent51ca4bc936e7005e466de7b12f9167287ae5cf88 (diff)
read multiply events
Diffstat (limited to 'kvmd/aiogp.py')
-rw-r--r--kvmd/aiogp.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/kvmd/aiogp.py b/kvmd/aiogp.py
index 2f988e67..f23fc36b 100644
--- a/kvmd/aiogp.py
+++ b/kvmd/aiogp.py
@@ -103,12 +103,14 @@ class AioPinsReader(threading.Thread):
ev_lines = lines.event_wait(1)
if ev_lines:
for ev_line in ev_lines:
- event = ev_line.event_read()
- if event.type == gpiod.LineEvent.RISING_EDGE:
- value = True
- elif event.type == gpiod.LineEvent.FALLING_EDGE:
- value = False
- else:
- raise RuntimeError(f"Invalid event {event} type: {event.type}")
- self.__state[event.source.offset()] = value
+ events = ev_line.event_read_multiply()
+ if events:
+ event = events[-1]
+ if event.type == gpiod.LineEvent.RISING_EDGE:
+ value = True
+ elif event.type == gpiod.LineEvent.FALLING_EDGE:
+ value = False
+ else:
+ raise RuntimeError(f"Invalid event {event} type: {event.type}")
+ self.__state[event.source.offset()] = value
self.__loop.call_soon_threadsafe(self.__notifier.notify_sync)