From 7a53f1445619fc471c2823e7081de8b6039b938e Mon Sep 17 00:00:00 2001 From: Maxim Devaev Date: Wed, 18 Sep 2024 04:37:43 +0300 Subject: refactoring --- kvmd/aiogp.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'kvmd/aiogp.py') diff --git a/kvmd/aiogp.py b/kvmd/aiogp.py index 7ebe4ade..3ee0ea2b 100644 --- a/kvmd/aiogp.py +++ b/kvmd/aiogp.py @@ -83,9 +83,9 @@ class AioReader: # pylint: disable=too-many-instance-attributes self.__path, consumer=self.__consumer, config={tuple(pins): gpiod.LineSettings(edge_detection=gpiod.line.Edge.BOTH)}, - ) as line_request: + ) as line_req: - line_request.wait_edge_events(0.1) + line_req.wait_edge_events(0.1) self.__values = { pin: _DebouncedValue( initial=bool(value.value), @@ -93,14 +93,14 @@ class AioReader: # pylint: disable=too-many-instance-attributes notifier=self.__notifier, loop=self.__loop, ) - for (pin, value) in zip(pins, line_request.get_values(pins)) + for (pin, value) in zip(pins, line_req.get_values(pins)) } self.__loop.call_soon_threadsafe(self.__notifier.notify) while not self.__stop_event.is_set(): - if line_request.wait_edge_events(1): + if line_req.wait_edge_events(1): new: dict[int, bool] = {} - for event in line_request.read_edge_events(): + for event in line_req.read_edge_events(): (pin, value) = self.__parse_event(event) new[pin] = value for (pin, value) in new.items(): @@ -110,7 +110,7 @@ class AioReader: # pylint: disable=too-many-instance-attributes # Размер буфера ядра - 16 эвентов на линии. При превышении этого числа, # новые эвенты потеряются. Это не баг, это фича, как мне объяснили в LKML. # Штош. Будем с этим жить и синхронизировать состояния при таймауте. - for (pin, value) in zip(pins, line_request.get_values(pins)): + for (pin, value) in zip(pins, line_req.get_values(pins)): self.__values[pin].set(bool(value.value)) # type: ignore def __parse_event(self, event: gpiod.EdgeEvent) -> tuple[int, bool]: -- cgit v1.2.3