fixed AioPinsReader's main loop

This commit is contained in:
Devaev Maxim 2020-09-13 19:18:12 +03:00
parent 1e6ab4672f
commit 5464bc2297

View File

@ -93,16 +93,15 @@ class AioPinsReader(threading.Thread):
self.__loop.call_soon_threadsafe(self.__notifier.notify_sync) self.__loop.call_soon_threadsafe(self.__notifier.notify_sync)
while not self.__stop_event.is_set(): while not self.__stop_event.is_set():
ev_lines = lines.event_wait(10) ev_lines = lines.event_wait(1)
if ev_lines: if ev_lines:
for ev_lines in lines.event_wait(1): for ev_line in ev_lines:
for ev_line in ev_lines: event = ev_line.event_read()
event = ev_line.event_read() if event.type == gpiod.LineEvent.RISING_EDGE:
if event.type == gpiod.LineEvent.RISING_EDGE: value = True
value = True elif event.type == gpiod.LineEvent.FALLING_EDGE:
elif event.type == gpiod.LineEvent.FALLING_EDGE: value = False
value = False else:
else: raise RuntimeError(f"Invalid event {event} type: {event.type}")
raise RuntimeError(f"Invalid event {event} type: {event.type}") self.__state[event.source.offset()] = value
self.__state[event.source.offset()] = value self.__loop.call_soon_threadsafe(self.__notifier.notify_sync)
self.__loop.call_soon_threadsafe(self.__notifier.notify_sync)