Skip to content

Commit

Permalink
Setup sensing before switching. This replicated old behavior. #9
Browse files Browse the repository at this point in the history
  • Loading branch information
kantlivelong committed Apr 19, 2021
1 parent 4f3c9c4 commit 947e335
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions octoprint_psucontrol_rpigpio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']))

Expand All @@ -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)
Expand Down

0 comments on commit 947e335

Please sign in to comment.