diff options
author | Maxim Devaev <[email protected]> | 2023-06-01 20:10:47 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2023-06-01 20:11:11 +0300 |
commit | f5ff9c142a46c1fface9ffa3176e2f99a2ec7931 (patch) | |
tree | 2495dd8133842327c52749c5e9d038b50f988ed3 /kvmd/apps | |
parent | caba1d33a24b23ad10dc5a7bd8381129c198b5bf (diff) |
gpio: const mode for outputs
Diffstat (limited to 'kvmd/apps')
-rw-r--r-- | kvmd/apps/kvmd/ugpio.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/kvmd/apps/kvmd/ugpio.py b/kvmd/apps/kvmd/ugpio.py index 78592324..bda9cef6 100644 --- a/kvmd/apps/kvmd/ugpio.py +++ b/kvmd/apps/kvmd/ugpio.py @@ -136,6 +136,9 @@ class _GpioOutput: # pylint: disable=too-many-instance-attributes self.__region = aiotools.AioExclusiveRegion(GpioChannelIsBusyError, notifier) + def is_const(self) -> bool: + return (not self.__switch and not self.__pulse_delay) + def get_scheme(self) -> dict: return { "switch": self.__switch, @@ -257,7 +260,11 @@ class UserGpio: return { "scheme": { "inputs": {channel: gin.get_scheme() for (channel, gin) in self.__inputs.items()}, - "outputs": {channel: gout.get_scheme() for (channel, gout) in self.__outputs.items()}, + "outputs": { + channel: gout.get_scheme() + for (channel, gout) in self.__outputs.items() + if not gout.is_const() + }, }, "view": self.__make_view(), } @@ -265,7 +272,11 @@ class UserGpio: async def get_state(self) -> dict: return { "inputs": {channel: await gin.get_state() for (channel, gin) in self.__inputs.items()}, - "outputs": {channel: await gout.get_state() for (channel, gout) in self.__outputs.items()}, + "outputs": { + channel: await gout.get_state() + for (channel, gout) in self.__outputs.items() + if not gout.is_const() + }, } async def poll_state(self) -> AsyncGenerator[dict, None]: |