From f5ff9c142a46c1fface9ffa3176e2f99a2ec7931 Mon Sep 17 00:00:00 2001 From: Maxim Devaev Date: Thu, 1 Jun 2023 20:10:47 +0300 Subject: gpio: const mode for outputs --- kvmd/apps/kvmd/ugpio.py | 15 +++++++++++++-- 1 file 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]: -- cgit v1.2.3