diff options
author | Devaev Maxim <[email protected]> | 2020-09-05 14:24:02 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-09-05 14:24:02 +0300 |
commit | 54fe569ad112df4d18c672d903985d994bda81d7 (patch) | |
tree | ec9bc74e88e6485051c219181e5637e5fd8de654 /kvmd | |
parent | a06a1e40f49787fc9f7c5e498f668e148ec35642 (diff) |
fixed ugpio pin modes
Diffstat (limited to 'kvmd')
-rw-r--r-- | kvmd/apps/kvmd/ugpio.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/kvmd/apps/kvmd/ugpio.py b/kvmd/apps/kvmd/ugpio.py index b5124f78..34d83ea5 100644 --- a/kvmd/apps/kvmd/ugpio.py +++ b/kvmd/apps/kvmd/ugpio.py @@ -64,7 +64,7 @@ class GpioChannelIsBusyError(IsBusyError): class _GpioInput: def __init__(self, channel: str, config: Section, reader: gpio.BatchReader) -> None: self.__channel = channel - self.__pin: int = config.pin # gpio.set_input(config.pin) # Configured in UserGpio/BatchReader + self.__pin: int = config.pin self.__inverted: bool = config.inverted self.__reader = reader @@ -84,7 +84,7 @@ class _GpioInput: class _GpioOutput: # pylint: disable=too-many-instance-attributes def __init__(self, channel: str, config: Section, notifier: aiotools.AioNotifier) -> None: self.__channel = channel - self.__pin: int = gpio.set_output(config.pin, (config.initial ^ config.inverted)) + self.__pin: int = config.pin self.__inverted: bool = config.inverted self.__switch: bool = config.switch @@ -171,7 +171,14 @@ class UserGpio: self.__state_notifier = aiotools.AioNotifier() self.__reader = gpio.BatchReader( - pins=[gpio.set_input(ch_config.pin) for ch_config in config.scheme.values()], + pins=[ + ( + gpio.set_input(ch_config.pin) + if ch_config.mode == "input" else + gpio.set_output(ch_config.pin, (ch_config.initial ^ ch_config.inverted)) + ) + for ch_config in config.scheme.values() + ], interval=config.state_poll, notifier=self.__state_notifier, ) |