summaryrefslogtreecommitdiff
path: root/kvmd/plugins/atx/gpio.py
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-09-13 18:23:28 +0300
committerDevaev Maxim <[email protected]>2020-09-13 18:23:28 +0300
commit1e6ab4672f0980f073ab7e1c6f48fb9bf43b0856 (patch)
treee2b1253063d813ca6119097ce0cdfea576a2f8fa /kvmd/plugins/atx/gpio.py
parent41223fa8b24be7978f320781c4b0e3d7b2347c75 (diff)
refactoring and reuse gpio pulse code
Diffstat (limited to 'kvmd/plugins/atx/gpio.py')
-rw-r--r--kvmd/plugins/atx/gpio.py15
1 files changed, 5 insertions, 10 deletions
diff --git a/kvmd/plugins/atx/gpio.py b/kvmd/plugins/atx/gpio.py
index 70354da4..5ca611ef 100644
--- a/kvmd/plugins/atx/gpio.py
+++ b/kvmd/plugins/atx/gpio.py
@@ -20,8 +20,6 @@
# ========================================================================== #
-import asyncio
-
from typing import Dict
from typing import AsyncGenerator
from typing import Optional
@@ -77,8 +75,10 @@ class Plugin(BaseAtx): # pylint: disable=too-many-instance-attributes
self.__reader = aiogp.AioPinsReader(
path="/dev/gpiochip0",
consumer="kvmd/atx-gpio/leds",
- pins=[power_led_pin, hdd_led_pin],
- inverted=[power_led_inverted, hdd_led_inverted],
+ pins={
+ power_led_pin: power_led_inverted,
+ hdd_led_pin: hdd_led_inverted,
+ },
notifier=self.__notifier,
)
@@ -185,10 +185,5 @@ class Plugin(BaseAtx): # pylint: disable=too-many-instance-attributes
@aiotools.atomic
async def __inner_click(self, name: str, line: gpiod.Line, delay: float) -> None:
- try:
- line.set_value(1)
- await asyncio.sleep(delay)
- finally:
- line.set_value(0)
- await asyncio.sleep(1)
+ await aiogp.pulse(line, delay, 1)
get_logger(0).info("Clicked ATX button %r", name)