summaryrefslogtreecommitdiff
path: root/kvmd/gpio.py
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-09-06 08:47:43 +0300
committerDevaev Maxim <[email protected]>2020-09-07 05:54:25 +0300
commita6dac4bd8495bc04f762a3ad415d301fb10498c9 (patch)
treeea81c6a9a9ea2521cc4b9bdfaee9b00d5b6e9c6d /kvmd/gpio.py
parente8bd1e264822967e1ddc628bf507664a5f4b9679 (diff)
ugpio plugins
Diffstat (limited to 'kvmd/gpio.py')
-rw-r--r--kvmd/gpio.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/kvmd/gpio.py b/kvmd/gpio.py
index ea99149e..f3ef8ba2 100644
--- a/kvmd/gpio.py
+++ b/kvmd/gpio.py
@@ -24,7 +24,7 @@ import asyncio
import contextlib
from typing import Tuple
-from typing import List
+from typing import Set
from typing import Generator
from typing import Optional
@@ -48,7 +48,7 @@ def bcm() -> Generator[None, None, None]:
logger.info("GPIO cleaned")
-def set_output(pin: int, initial: bool=False) -> int:
+def set_output(pin: int, initial: Optional[bool]) -> int:
assert pin >= 0, pin
GPIO.setup(pin, GPIO.OUT, initial=initial)
return pin
@@ -71,10 +71,10 @@ def write(pin: int, state: bool) -> None:
class BatchReader:
- def __init__(self, pins: List[int], interval: float, notifier: aiotools.AioNotifier) -> None:
- self.__pins = pins
- self.__flags: Tuple[Optional[bool], ...] = (None,) * len(pins)
- self.__state = {pin: read(pin) for pin in pins}
+ def __init__(self, pins: Set[int], interval: float, notifier: aiotools.AioNotifier) -> None:
+ self.__pins = sorted(pins)
+ self.__flags: Tuple[Optional[bool], ...] = (None,) * len(self.__pins)
+ self.__state = {pin: read(pin) for pin in self.__pins}
self.__interval = interval
self.__notifier = notifier