mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 09:10:30 +08:00
optional gpio initial
This commit is contained in:
parent
c2831853a0
commit
1353ca2e97
@ -200,8 +200,8 @@ def _patch_dynamic( # pylint: disable=too-many-locals
|
|||||||
if mode == "output":
|
if mode == "output":
|
||||||
ch_scheme.update({
|
ch_scheme.update({
|
||||||
"busy_delay": Option(0.2, type=valid_float_f01),
|
"busy_delay": Option(0.2, type=valid_float_f01),
|
||||||
"initial": Option(False, type=valid_bool),
|
"initial": Option(False, type=(lambda arg: (None if arg is None else valid_bool(arg)))),
|
||||||
"switch": Option(True, type=valid_bool),
|
"switch": Option(True, type=valid_bool),
|
||||||
"pulse": {
|
"pulse": {
|
||||||
"delay": Option(0.1, type=valid_float_f0),
|
"delay": Option(0.1, type=valid_float_f0),
|
||||||
"min_delay": Option(0.1, type=valid_float_f01),
|
"min_delay": Option(0.1, type=valid_float_f01),
|
||||||
|
|||||||
@ -112,7 +112,7 @@ class _GpioOutput: # pylint: disable=too-many-instance-attributes
|
|||||||
self.__channel = channel
|
self.__channel = channel
|
||||||
self.__pin: int = config.pin
|
self.__pin: int = config.pin
|
||||||
self.__inverted: bool = config.inverted
|
self.__inverted: bool = config.inverted
|
||||||
self.__initial: bool = config.initial
|
self.__initial: Optional[bool] = config.initial
|
||||||
|
|
||||||
self.__switch: bool = config.switch
|
self.__switch: bool = config.switch
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ class _GpioOutput: # pylint: disable=too-many-instance-attributes
|
|||||||
self.__busy_delay: float = config.busy_delay
|
self.__busy_delay: float = config.busy_delay
|
||||||
|
|
||||||
self.__driver = driver
|
self.__driver = driver
|
||||||
self.__driver.register_output(self.__pin, (config.initial ^ config.inverted))
|
self.__driver.register_output(self.__pin, (None if config.initial is None else (config.initial ^ config.inverted)))
|
||||||
|
|
||||||
self.__region = aiotools.AioExclusiveRegion(GpioChannelIsBusyError, notifier)
|
self.__region = aiotools.AioExclusiveRegion(GpioChannelIsBusyError, notifier)
|
||||||
|
|
||||||
@ -156,10 +156,11 @@ class _GpioOutput: # pylint: disable=too-many-instance-attributes
|
|||||||
}
|
}
|
||||||
|
|
||||||
def cleanup(self) -> None:
|
def cleanup(self) -> None:
|
||||||
try:
|
if self.__initial is not None:
|
||||||
self.__driver.write(self.__pin, (self.__initial ^ self.__inverted))
|
try:
|
||||||
except Exception:
|
self.__driver.write(self.__pin, (self.__initial ^ self.__inverted))
|
||||||
get_logger().exception("Can't cleanup %s", self)
|
except Exception:
|
||||||
|
get_logger().exception("Can't cleanup %s", self)
|
||||||
|
|
||||||
async def switch(self, state: bool) -> bool:
|
async def switch(self, state: bool) -> bool:
|
||||||
if not self.__switch:
|
if not self.__switch:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user