From 947e3350b2567223512d6be6c35c1d8858cf2f20 Mon Sep 17 00:00:00 2001 From: Shawn Bruce Date: Mon, 19 Apr 2021 12:02:18 -0400 Subject: [PATCH] Setup sensing before switching. This replicated old behavior. #9 --- octoprint_psucontrol_rpigpio/__init__.py | 26 ++++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/octoprint_psucontrol_rpigpio/__init__.py b/octoprint_psucontrol_rpigpio/__init__.py index 0fa19ab..677c7ec 100644 --- a/octoprint_psucontrol_rpigpio/__init__.py +++ b/octoprint_psucontrol_rpigpio/__init__.py @@ -122,19 +122,6 @@ def configure_gpio(self): else: return - if self.config['onoffGPIOPin'] > 0: - self._logger.info("Configuring GPIO for pin {}".format(self.config['onoffGPIOPin'])) - try: - if not self.config['invertonoffGPIOPin']: - initial_pin_output=GPIO.LOW - else: - initial_pin_output=GPIO.HIGH - - GPIO.setup(self._gpio_get_pin(self.config['onoffGPIOPin']), GPIO.OUT, initial=initial_pin_output) - self._configuredGPIOPins.append(self.config['onoffGPIOPin']) - except (RuntimeError, ValueError) as e: - self._logger.error(e) - if self.config['senseGPIOPin'] > 0: self._logger.info("Configuring GPIO for pin {}".format(self.config['senseGPIOPin'])) @@ -151,6 +138,19 @@ def configure_gpio(self): except (RuntimeError, ValueError) as e: self._logger.error(e) + if self.config['onoffGPIOPin'] > 0: + self._logger.info("Configuring GPIO for pin {}".format(self.config['onoffGPIOPin'])) + try: + if not self.config['invertonoffGPIOPin']: + initial_pin_output=GPIO.LOW + else: + initial_pin_output=GPIO.HIGH + + GPIO.setup(self._gpio_get_pin(self.config['onoffGPIOPin']), GPIO.OUT, initial=initial_pin_output) + self._configuredGPIOPins.append(self.config['onoffGPIOPin']) + except (RuntimeError, ValueError) as e: + self._logger.error(e) + def cleanup_gpio(self): GPIO.setwarnings(False)