diff --git a/pi_mqtt_gpio/modules/__init__.py b/pi_mqtt_gpio/modules/__init__.py index 0c8265eb18d06ec0fed5ecc006841b95f9261e00..acdff19a26fb46a0ef4664f1153560e40bb858bc 100644 --- a/pi_mqtt_gpio/modules/__init__.py +++ b/pi_mqtt_gpio/modules/__init__.py @@ -9,8 +9,9 @@ class PinDirection(Enum): class PinPullup(Enum): - UP = 0 - DOWN = 1 + OFF = 0 + UP = 1 + DOWN = 2 class GenericGPIO(object): diff --git a/pi_mqtt_gpio/modules/raspberrypi.py b/pi_mqtt_gpio/modules/raspberrypi.py index 61ebfd80e413d5c34f480ce529567bcea460b50a..1520a2cce1e54b639411006d5b8005cb2e91077e 100644 --- a/pi_mqtt_gpio/modules/raspberrypi.py +++ b/pi_mqtt_gpio/modules/raspberrypi.py @@ -21,6 +21,7 @@ class GPIO(GenericGPIO): } PULLUPS = { + PinPullup.OFF: gpio.PUD_OFF, PinPullup.UP: gpio.PUD_UP, PinPullup.DOWN: gpio.PUD_DOWN } @@ -29,8 +30,12 @@ class GPIO(GenericGPIO): def setup_pin(self, pin, direction, pullup, pin_config): direction = DIRECTIONS[direction] - if pullup is not None: + + if pullup is None: + pullup = PULLUPS[0] + else: pullup = PULLUPS[pullup] + self.io.setup(pin, direction, pull_up_down=pullup) def set_pin(self, pin, value):