Skip to content

Commit 7be3683

Browse files
committed
Add settings update after save
1 parent 30a3084 commit 7be3683

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

octoprint_filamentreload/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,19 @@ def get_settings_defaults(self):
6565
after_resume_gcode = '',
6666
)
6767

68+
def on_settings_save(self, data):
69+
octoprint.plugin.SettingsPlugin.on_settings_save(self, data)
70+
71+
if self.mode == 0:
72+
GPIO.setmode(GPIO.BOARD)
73+
else:
74+
GPIO.setmode(GPIO.BCM)
75+
76+
if self._settings.get(["pin"]) != "-1": # If a pin is defined
77+
self._logger.info("Filament Sensor active on GPIO Pin [%s]"%self.pin)
78+
GPIO.setup(self.pin, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Initialize GPIO as INPUT
79+
80+
6881
def sensor_enabled(self):
6982
return self.pin != -1
7083

0 commit comments

Comments
 (0)