From 4ad7a8814228e30ccd23fa3b32494b580b20479b Mon Sep 17 00:00:00 2001 From: Alexander Wellbrock <a.wellbrock@mailbox.org> Date: Mon, 11 Jan 2021 16:55:48 +0100 Subject: [PATCH] refactor setup_pin function Make it more readable / simplify. --- pi_mqtt_gpio/modules/gpiod.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pi_mqtt_gpio/modules/gpiod.py b/pi_mqtt_gpio/modules/gpiod.py index 410ac7c..25450b5 100644 --- a/pi_mqtt_gpio/modules/gpiod.py +++ b/pi_mqtt_gpio/modules/gpiod.py @@ -49,21 +49,18 @@ class GPIO(GenericGPIO): direction: input or output pullup: pullup settings are not supported """ - line_direction = DIRECTIONS[direction] - offset = pin - # Pullup settings are called bias in libgpiod and are only # available since Linux Kernel 5.5. They are as of now not # yet part of python3-gpiod. - pin = self.chip.get_line(offset) + line = self.chip.get_line(pin) config = self.io.line_request() config.consumer = 'pi-mqtt-gpio' - config.request_type = line_direction + config.request_type = DIRECTIONS[direction] - pin.request(config) - self.pins[offset] = pin + line.request(config) + self.pins[pin] = line def setup_interrupt(self, handle, pin, edge, callback, bouncetime=100): """ -- GitLab