From 0c217a78442bc9921048f1d9a3867e8d8ee860ae Mon Sep 17 00:00:00 2001 From: Herb Peyerl <hpeyerl+github@beer.org> Date: Mon, 3 Apr 2017 09:37:30 -0600 Subject: [PATCH] outputs must have PUD_OFF. Enforced on RPi.GPIO-0.6.3. (#2) * outputs must have PUD_OFF. Enforced on RPi.GPIO-0.6.3. * <tab> vs <spaces> snuck in --- pi_mqtt_gpio/modules/__init__.py | 5 +++-- pi_mqtt_gpio/modules/raspberrypi.py | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pi_mqtt_gpio/modules/__init__.py b/pi_mqtt_gpio/modules/__init__.py index 0c8265e..acdff19 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 61ebfd8..1520a2c 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): -- GitLab