diff --git a/docs/Config_Reference.md b/docs/Config_Reference.md index f797d2b06905..925b83ed2017 100644 --- a/docs/Config_Reference.md +++ b/docs/Config_Reference.md @@ -2352,6 +2352,15 @@ Tool to disable heaters when homing or probing an axis. # A comma separated list of heaters to disable during homing/probing # moves. The default is to disable all heaters. # Typical example: extruder, heater_bed +#threshold: +# If this is set then the printer will wait until the heaters have +# reached their target temperatures before continuing. If set then the +# number indicates the threshold (+/-) before needing to re-heat. +# This is useful for when performing bed mesh calinbration probing for +# probes that are sensitive to EMI, while still allowing the bed to +# maintain a constant temperature. +# Note that it is typically more convenient to set this via the +# SET_HOMING_HEATERS [gcode command](G-Codes.md#set_homing_heaters) ``` ### [thermistor] diff --git a/docs/G-Codes.md b/docs/G-Codes.md index d44017deac9c..fe123c4539e5 100644 --- a/docs/G-Codes.md +++ b/docs/G-Codes.md @@ -736,6 +736,13 @@ above the supplied MINIMUM and/or at or below the supplied MAXIMUM. [TARGET=]`: Sets the target temperature for a heater. If a target temperature is not supplied, the target is 0. +### [homing_heaters] + +#### SET_HOMING_HEATERS [THRESHOLD=] +`SET_HOMING_HEATERS [THRESHOLD=]`: Setting this to any value at all causes homing procedures to wait until the heaters have reached +thier target temperatures AFTER probing has occurred. +This is helpful during bed mesh calibration in the event that the probe is sensitive to the EMI caused by the bed but the bed temperature must be maintained during probing. To disable this, simply run the `SET_HOMING_HEATERS` command while omitting the `THRESHOLD` parameter. + ### [idle_timeout] The idle_timeout module is automatically loaded. diff --git a/klippy/extras/homing_heaters.py b/klippy/extras/homing_heaters.py index 4bb9ba040158..bd55d5e55990 100644 --- a/klippy/extras/homing_heaters.py +++ b/klippy/extras/homing_heaters.py @@ -18,7 +18,12 @@ def __init__(self, config): self.disable_heaters = config.getlist("heaters", None) self.flaky_steppers = config.getlist("steppers", None) self.pheaters = self.printer.load_object(config, 'heaters') + self.threshold = config.getfloat("threshold", None) self.target_save = {} + self.gcode = self.printer.lookup_object('gcode') + self.gcode.register_command("SET_HOMING_HEATERS", + self.cmd_SET_HOMING_HEATERS, + desc=self.cmd_SET_HOMING_HEATERS_desc) def handle_connect(self): # heaters to disable @@ -56,9 +61,32 @@ def handle_homing_move_begin(self, hmove): def handle_homing_move_end(self, hmove): if not self.check_eligible(hmove.get_mcu_endstops()): return + + # Switch all the heaters back on first for heater_name in self.disable_heaters: heater = self.pheaters.lookup_heater(heater_name) heater.set_temp(self.target_save[heater_name]) + if self.threshold is None: + return + + # Now wait for them to re-heat if we need to + for heater_name in self.disable_heaters: + heater = self.pheaters.lookup_heater(heater_name) + heater_target = self.target_save[heater_name] + heater_threshold = heater_target - self.threshold + current_temp = heater.get_temp( + self.printer.get_reactor().monotonic())[0] + if current_temp < heater_threshold: + self.gcode.respond_raw( + "echo: Waiting for '%s' to reheat" % heater_name) + self.pheaters.set_temperature(heater, heater_target, True) + + cmd_SET_HOMING_HEATERS_desc = "Set the reheat threshold for homing heaters" + def cmd_SET_HOMING_HEATERS(self, gcmd): + self.threshold = gcmd.get("THRESHOLD", None) + if self.threshold is not None: + self.threshold = float(self.threshold) + def load_config(config): return HomingHeaters(config)