filament_runout_sensor: Auto load pause_resume module if pause_on_runout enabled

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-06-07 11:10:27 -04:00
parent 3f4190c792
commit d0be48da74
1 changed files with 3 additions and 2 deletions

View File

@ -14,6 +14,7 @@ class BaseSensor(object):
self.insert_gcode = config.get('insert_gcode', None) self.insert_gcode = config.get('insert_gcode', None)
self.runout_pause = config.getboolean('pause_on_runout', True) self.runout_pause = config.getboolean('pause_on_runout', True)
if self.runout_pause: if self.runout_pause:
self.printer.try_load_module(config, 'pause_resume')
if self.runout_gcode is None: if self.runout_gcode is None:
self.runout_gcode = "PAUSE" self.runout_gcode = "PAUSE"
else: else:
@ -46,8 +47,8 @@ class BaseSensor(object):
self.event_running = True self.event_running = True
# Pausing from inside an event requires that the pause portion # Pausing from inside an event requires that the pause portion
# of pause_resume execute immediately. # of pause_resume execute immediately.
pause_resume = self.printer.lookup_object('pause_resume', None) if self.runout_pause:
if self.runout_pause and pause_resume is not None: pause_resume = self.printer.lookup_object('pause_resume')
pause_resume.send_pause_command() pause_resume.send_pause_command()
self._exec_gcode(self.runout_gcode) self._exec_gcode(self.runout_gcode)
self.event_running = False self.event_running = False