Skip to content

Commit

Permalink
Potential fix for MCP23017 Pump Output
Browse files Browse the repository at this point in the history
  • Loading branch information
kizniche committed Jun 7, 2024
1 parent fa11b9c commit 9f5566e
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions mycodo/outputs/pump_mcp23017.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ def initialize(self):
from adafruit_mcp230xx.mcp23017 import MCP23017
from adafruit_extended_bus import ExtendedI2C

self.setup_output_variables(OUTPUT_INFORMATION)

try:
self.setup_output_variables(OUTPUT_INFORMATION)

self.logger.debug(f"I2C: Address: {self.output.i2c_location}, Bus: {self.output.i2c_bus}")
if self.output.i2c_location:
self.sensor = MCP23017(
Expand All @@ -186,16 +186,25 @@ def initialize(self):
return

for pin in range(0, 16):
self.pins.append(self.sensor.get_pin(pin))
try:
self.pins.append(self.sensor.get_pin(pin))
except:
self.logger.exception("Setting pin")
return

for channel in channels_dict:
self.currently_dispensing[channel] = False
if self.options_channels['state_startup'][channel] == 1:
self.turn_on_off(channel, "on")
elif self.options_channels['state_startup'][channel] == 0:
self.turn_on_off(channel, "off")
else: # Default state: Off
self.turn_on_off(channel, "off")
try:
self.currently_dispensing[channel] = False
self.output_states[channel] = False
if self.options_channels['state_startup'][channel] == 1:
self.turn_on_off(channel, "on")
elif self.options_channels['state_startup'][channel] == 0:
self.turn_on_off(channel, "off")
else: # Default state: Off
self.turn_on_off(channel, "off")
except:
self.logger.exception("Initializing startup state")
return

self.output_setup = True

Expand Down

1 comment on commit 9f5566e

@kizniche
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Radical DIY Forum. There might be relevant details there:

https://forum.radicaldiy.com/t/need-help-configuring-mcp23017-for-peristaltic-pumps-in-mycodo/1879/9

Please sign in to comment.