From 49779f13a23be766b3a131a285f7fb5447488c74 Mon Sep 17 00:00:00 2001 From: Arksine Date: Sat, 7 Sep 2019 08:33:44 -0400 Subject: [PATCH] filament_switch_sensor: Add a delay between dispatch of pause and execution of pause gcode Signed-off-by: Eric Callahan --- config/example-extras.cfg | 5 +++++ klippy/extras/filament_switch_sensor.py | 2 ++ 2 files changed, 7 insertions(+) diff --git a/config/example-extras.cfg b/config/example-extras.cfg index 4f220502..bf91e113 100644 --- a/config/example-extras.cfg +++ b/config/example-extras.cfg @@ -1683,6 +1683,11 @@ # The minimum amount of time in seconds to delay between events. # Events triggered during this time period will be silently # ignored. The default is 3 seconds. +#pause_delay: 0.5 +# The amount of time to delay, in seconds, between the pause command +# dispatch and execution of the runout_gcode. It may be useful to +# increase this delay if Octoprint exhibits strange pause behavior. +# Default is 0.5 seconds. #switch_pin: # The pin on which the switch is connected. This parameter must be # provided. diff --git a/klippy/extras/filament_switch_sensor.py b/klippy/extras/filament_switch_sensor.py index a5b189df..257980a8 100644 --- a/klippy/extras/filament_switch_sensor.py +++ b/klippy/extras/filament_switch_sensor.py @@ -21,6 +21,7 @@ class BaseSensor(object): if config.get('insert_gcode', None) is not None: self.insert_gcode = gcode_macro.load_template( config, 'insert_gcode') + self.pause_delay = config.getfloat('pause_delay', .5, above=.0) self.runout_enabled = False self.insert_enabled = self.insert_gcode is not None self.event_running = False @@ -52,6 +53,7 @@ class BaseSensor(object): pause_resume = self.printer.lookup_object('pause_resume') pause_resume.send_pause_command() pause_prefix = "PAUSE\n" + self.printer.get_reactor().pause(eventtime + self.pause_delay) self._exec_gcode(pause_prefix, self.runout_gcode) self.event_running = False def _insert_event_handler(self, eventtime):