Skip to content

Commit

Permalink
Update filament_switch_sensor.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeanon committed Oct 14, 2023
1 parent c401446 commit 73aa147
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion klippy/extras/filament_switch_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ def __init__(self, config, defined_sensor, runout_distance=0):
self.runout_pause = config.getboolean('pause_on_runout', True)
if self.runout_pause:
self.printer.load_object(config, 'pause_resume')
self.runout_gcode = self.insert_gcode = None
self.runout_gcode = None
self.immediate_runout_gcode = None
self.insert_gcode = None
gcode_macro = self.printer.load_object(config, 'gcode_macro')
if self.runout_pause or config.get('runout_gcode', None) is not None:
self.runout_gcode = gcode_macro.load_template(
config, 'runout_gcode', '')
if config.get('immediate_runout_gcode', None) is not None:
self.immediate_runout_gcode = gcode_macro.load_template(
config, 'immediate_runout_gcode', '')
if config.get('insert_gcode', None) is not None:
self.insert_gcode = gcode_macro.load_template(
config, 'insert_gcode')
Expand Down Expand Up @@ -58,6 +63,8 @@ def _runout_event_handler(self, eventtime):
# of pause_resume execute immediately.
if self.runout_distance > 0:
if self.runout_distance_timer is None:
if self.immediate_runout_gcode is not None:
self._exec_gcode("", self.immediate_runout_gcode)
self.runout_position = (self.defined_sensor
.get_extruder_pos(eventtime))
self.runout_distance_timer = self.reactor.register_timer(
Expand Down

0 comments on commit 73aa147

Please sign in to comment.