From 73aa14726d07f0bbde39cbc94436626188603553 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Sat, 14 Oct 2023 21:44:36 +0200 Subject: [PATCH] Update filament_switch_sensor.py --- klippy/extras/filament_switch_sensor.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/klippy/extras/filament_switch_sensor.py b/klippy/extras/filament_switch_sensor.py index f0908ca51fc3..8094f48e3e31 100644 --- a/klippy/extras/filament_switch_sensor.py +++ b/klippy/extras/filament_switch_sensor.py @@ -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') @@ -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(