From 1570559bbac0cf2b6a326471ef649405b7e5dc14 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 5 Dec 2020 18:33:39 -0500 Subject: [PATCH] Add safety temperature for nozzle as probe --- Marlin/Configuration.h | 7 +++++++ Marlin/src/module/probe.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index ebc3311d9e..94d4615a93 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -884,6 +884,13 @@ * nozzle system or a piezo-electric smart effector. */ //#define NOZZLE_AS_PROBE +#if ENABLED(NOZZLE_AS_PROBE) + #define PROBE_REQUIRES_MINTEMP // Require a minimum temperature when using the nozzle as a probe + #if ENABLED(PROBE_REQUIRES_MINTEMP) + #define PROBE_REQUIRES_MINTEMP_NOZZLE 150 + #define PROBE_REQUIRES_MINTEMP_BED 50 + #endif +#endif /** * Z Servo Probe, such as an endstop switch on a rotating arm. diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 400206f83a..96b3545edc 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -348,6 +348,34 @@ bool Probe::set_deployed(const bool deploy) { constexpr bool deploy_stow_condition = true; #endif + #if BOTH(NOZZLE_AS_PROBE, PROBE_REQUIRES_MINTEMP) + bool setting_hotend, setting_bed = false; + #if defined(PROBE_REQUIRES_MINTEMP_NOZZLE) && PROBE_REQUIRES_MINTEMP_NOZZLE < 0 && HAS_TEMP_HOTEND + if (thermalManager.degTargetHotend(0) < PROBE_REQUIRES_MINTEMP_NOZZLE) { + uint16_t hotendTemperature = AUTOLEVEL_PREHEAT_NOZZLE_TEMP; + SERIAL_ECHOLNPAIR("Preheating hot-end to ", hotendTemperature); + thermalManager.setTargetHotend(hotendTemperature, 0); + setting_hotend = true; + } + #endif + + #if defined(PROBE_REQUIRES_MINTEMP_BED) && PROBE_REQUIRES_MINTEMP_BED < 0 && HAS_HEATED_BED + if (thermalManager.degBed() < PROBE_REQUIRES_MINTEMP_BED) { + uint16_t bedTemperature = AUTOLEVEL_PREHEAT_BED_TEMP; + SERIAL_ECHOLNPAIR("Preheating bed to ", bedTemperature); + thermalManager.setTargetBed(bedTemperature); + setting_bed = true; + } + #endif + + #if HAS_TEMP_HOTEND + if (setting_hotend) thermalManager.wait_for_hotend(0); + #endif + #if HAS_HEATED_BED + if (setting_bed) thermalManager.wait_for_bed_heating(); + #endif + #endif + // For beds that fall when Z is powered off only raise for trusted Z #if ENABLED(UNKNOWN_Z_NO_RAISE) const bool unknown_condition = axis_is_trusted(Z_AXIS);