diff options
author | Devaev Maxim <[email protected]> | 2020-09-14 21:51:53 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-09-14 21:51:53 +0300 |
commit | 6ef53e48c56af680e6efbfd1002a2bb144d2043f (patch) | |
tree | 345fad8e56ffbb3d60fb4401e67203dca17b2821 /kvmd/aiogp.py | |
parent | 50d0612f82ad03222518dd08cd2f1a11565de443 (diff) |
notify only on change
Diffstat (limited to 'kvmd/aiogp.py')
-rw-r--r-- | kvmd/aiogp.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/kvmd/aiogp.py b/kvmd/aiogp.py index 7b0a2e74..7dfe4fa9 100644 --- a/kvmd/aiogp.py +++ b/kvmd/aiogp.py @@ -102,12 +102,16 @@ class AioPinsReader: # pylint: disable=too-many-instance-attributes while not self.__stop_event.is_set(): ev_lines = lines.event_wait(1) if ev_lines: + changed = False for ev_line in ev_lines: events = ev_line.event_read_multiply() if events: (pin, value) = self.__parse_event(events[-1]) - self.__state[pin] = value - self.__notify() + if self.__state[pin] != value: + self.__state[pin] = value + changed = True + if changed: + self.__notify() def __parse_event(self, event: gpiod.LineEvent) -> Tuple[int, bool]: pin = event.source.offset() |