gpio view and refactoring

This commit is contained in:
Devaev Maxim
2020-08-31 09:01:40 +03:00
parent 9feb353150
commit 7782668944
6 changed files with 39 additions and 15 deletions

View File

@@ -167,6 +167,8 @@ class _GpioOutput: # pylint: disable=too-many-instance-attributes
# =====
class UserGpio:
def __init__(self, config: Section) -> None:
self.__view = config.view
self.__state_notifier = aiotools.AioNotifier()
self.__reader = gpio.BatchReader(
pins=[gpio.set_input(ch_config.pin) for ch_config in config.scheme.values()],
@@ -189,6 +191,9 @@ class UserGpio:
"outputs": {channel: gout.get_scheme() for (channel, gout) in self.__outputs.items()},
}
async def get_view(self) -> Dict:
return self.__view
async def get_state(self) -> Dict:
return {
"inputs": {channel: gin.get_state() for (channel, gin) in self.__inputs.items()},