From b355f4605eb177c7f9f4b3503dcafa91e85c2607 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 19 Jan 2021 20:58:50 -0600 Subject: [PATCH] Move singlenozzle temp/fan (#20829) --- Marlin/src/gcode/temp/M104_M109.cpp | 4 ++-- Marlin/src/inc/SanityCheck.h | 8 ++++---- Marlin/src/lcd/menu/menu_item.h | 2 +- Marlin/src/lcd/menu/menu_temperature.cpp | 2 +- Marlin/src/lcd/menu/menu_tune.cpp | 2 +- Marlin/src/module/temperature.cpp | 25 ++++++++++++++++++++++++ Marlin/src/module/temperature.h | 8 ++++++++ Marlin/src/module/tool_change.cpp | 23 +--------------------- Marlin/src/module/tool_change.h | 8 -------- 9 files changed, 43 insertions(+), 39 deletions(-) diff --git a/Marlin/src/gcode/temp/M104_M109.cpp b/Marlin/src/gcode/temp/M104_M109.cpp index 300777051..07e46e177 100644 --- a/Marlin/src/gcode/temp/M104_M109.cpp +++ b/Marlin/src/gcode/temp/M104_M109.cpp @@ -88,7 +88,7 @@ void GcodeSuite::M104() { if (got_temp) { #if ENABLED(SINGLENOZZLE_STANDBY_TEMP) - singlenozzle_temp[target_extruder] = temp; + thermalManager.singlenozzle_temp[target_extruder] = temp; if (target_extruder != active_extruder) return; #endif thermalManager.setTargetHotend(temp, target_extruder); @@ -166,7 +166,7 @@ void GcodeSuite::M109() { if (got_temp) { #if ENABLED(SINGLENOZZLE_STANDBY_TEMP) - singlenozzle_temp[target_extruder] = temp; + thermalManager.singlenozzle_temp[target_extruder] = temp; if (target_extruder != active_extruder) return; #endif thermalManager.setTargetHotend(temp, target_extruder); diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 1e4b4753f..2d4b073e1 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1935,16 +1935,16 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal * Basic multi hotend duplication mode */ #if ENABLED(MULTI_NOZZLE_DUPLICATION) - #if HOTENDS < 2 - #error "MULTI_NOZZLE_DUPLICATION requires 2 or more hotends." + #if ENABLED(SINGLENOZZLE) + #error "MULTI_NOZZLE_DUPLICATION is incompatible with SINGLENOZZLE." #elif ENABLED(DUAL_X_CARRIAGE) #error "MULTI_NOZZLE_DUPLICATION is incompatible with DUAL_X_CARRIAGE." - #elif ENABLED(SINGLENOZZLE) - #error "MULTI_NOZZLE_DUPLICATION is incompatible with SINGLENOZZLE." #elif ENABLED(MIXING_EXTRUDER) #error "MULTI_NOZZLE_DUPLICATION is incompatible with MIXING_EXTRUDER." #elif ENABLED(SWITCHING_EXTRUDER) #error "MULTI_NOZZLE_DUPLICATION is incompatible with SWITCHING_EXTRUDER." + #elif HOTENDS < 2 + #error "MULTI_NOZZLE_DUPLICATION requires 2 or more hotends." #endif #endif diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h index 1d9a2f6b2..6873f209b 100644 --- a/Marlin/src/lcd/menu/menu_item.h +++ b/Marlin/src/lcd/menu/menu_item.h @@ -485,7 +485,7 @@ class MenuItem_bool : public MenuEditItemBase { #if SNFAN(1) || SNFAN(2) || SNFAN(3) || SNFAN(4) || SNFAN(5) || SNFAN(6) || SNFAN(7) #define DEFINE_SINGLENOZZLE_ITEM() \ auto singlenozzle_item = [&](const uint8_t f) { \ - editable.uint8 = singlenozzle_fan_speed[f]; \ + editable.uint8 = thermalManager.singlenozzle_fan_speed[f]; \ EDIT_ITEM_FAST_N(percent, f, MSG_STORED_FAN_N, &editable.uint8, 0, 255, on_fan_update); \ } #else diff --git a/Marlin/src/lcd/menu/menu_temperature.cpp b/Marlin/src/lcd/menu/menu_temperature.cpp index 7c8668d95..01c1f8f54 100644 --- a/Marlin/src/lcd/menu/menu_temperature.cpp +++ b/Marlin/src/lcd/menu/menu_temperature.cpp @@ -159,7 +159,7 @@ void menu_temperature() { #if ENABLED(SINGLENOZZLE_STANDBY_TEMP) LOOP_S_L_N(e, 1, EXTRUDERS) - EDIT_ITEM_FAST_N(uint16_3, e, MSG_NOZZLE_STANDBY, &singlenozzle_temp[e], 0, thermalManager.heater_maxtemp[0] - (HOTEND_OVERSHOOT)); + EDIT_ITEM_FAST_N(uint16_3, e, MSG_NOZZLE_STANDBY, &thermalManager.singlenozzle_temp[e], 0, thermalManager.heater_maxtemp[0] - (HOTEND_OVERSHOOT)); #endif // diff --git a/Marlin/src/lcd/menu/menu_tune.cpp b/Marlin/src/lcd/menu/menu_tune.cpp index 8028442a0..cccb352d8 100644 --- a/Marlin/src/lcd/menu/menu_tune.cpp +++ b/Marlin/src/lcd/menu/menu_tune.cpp @@ -127,7 +127,7 @@ void menu_tune() { #if ENABLED(SINGLENOZZLE_STANDBY_TEMP) LOOP_S_L_N(e, 1, EXTRUDERS) - EDIT_ITEM_FAST_N(uint16_3, e, MSG_NOZZLE_STANDBY, &singlenozzle_temp[e], 0, thermalManager.heater_maxtemp[0] - HOTEND_OVERSHOOT); + EDIT_ITEM_FAST_N(uint16_3, e, MSG_NOZZLE_STANDBY, &thermalManager.singlenozzle_temp[e], 0, thermalManager.heater_maxtemp[0] - HOTEND_OVERSHOOT); #endif // diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 85222a346..c15270f5e 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -377,6 +377,13 @@ volatile bool Temperature::raw_temps_ready = false; Temperature::soft_pwm_count_fan[FAN_COUNT]; #endif +#if ENABLED(SINGLENOZZLE_STANDBY_TEMP) + uint16_t Temperature::singlenozzle_temp[EXTRUDERS]; + #if HAS_FAN + uint8_t Temperature::singlenozzle_fan_speed[EXTRUDERS]; + #endif +#endif + #if ENABLED(PROBING_HEATERS_OFF) bool Temperature::paused; #endif @@ -2195,6 +2202,24 @@ void Temperature::disable_all_heaters() { #endif // PROBING_HEATERS_OFF +#if ENABLED(SINGLENOZZLE_STANDBY_TEMP) + + void Temperature::singlenozzle_change(const uint8_t old_tool, const uint8_t new_tool) { + #if HAS_FAN + singlenozzle_fan_speed[old_tool] = fan_speed[0]; + fan_speed[0] = singlenozzle_fan_speed[new_tool]; + #endif + singlenozzle_temp[old_tool] = temp_hotend[0].target; + if (singlenozzle_temp[new_tool] && singlenozzle_temp[new_tool] != singlenozzle_temp[old_tool]) { + setTargetHotend(singlenozzle_temp[new_tool], 0); + TERN_(AUTOTEMP, planner.autotemp_update()); + TERN_(HAS_DISPLAY, set_heating_message(0)); + (void)wait_for_hotend(0, false); // Wait for heating or cooling + } + } + +#endif + #if HAS_MAX6675 #ifndef THERMOCOUPLE_MAX_ERRORS diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index f570fe210..86c202cad 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -335,6 +335,14 @@ class Temperature { FORCE_INLINE static bool hotEnoughToExtrude(const uint8_t e) { return !tooColdToExtrude(e); } FORCE_INLINE static bool targetHotEnoughToExtrude(const uint8_t e) { return !targetTooColdToExtrude(e); } + #if ENABLED(SINGLENOZZLE_STANDBY_FAN) + static uint16_t singlenozzle_temp[EXTRUDERS]; + #if HAS_FAN + static uint8_t singlenozzle_fan_speed[EXTRUDERS]; + #endif + static void singlenozzle_change(const uint8_t old_tool, const uint8_t new_tool); + #endif + #if HEATER_IDLE_HANDLER // Heater idle handling. Marlin creates one per hotend and one for the heated bed. diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 95f32f2fa..052b8cd34 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -49,14 +49,6 @@ bool toolchange_extruder_ready[EXTRUDERS]; #endif -#if ENABLED(SINGLENOZZLE_STANDBY_TEMP) - uint16_t singlenozzle_temp[EXTRUDERS]; -#endif - -#if BOTH(HAS_FAN, SINGLENOZZLE_STANDBY_FAN) - uint8_t singlenozzle_fan_speed[EXTRUDERS]; -#endif - #if ENABLED(MAGNETIC_PARKING_EXTRUDER) || defined(EVENT_GCODE_AFTER_TOOLCHANGE) || (ENABLED(PARKING_EXTRUDER) && PARKING_EXTRUDER_SOLENOIDS_DELAY > 0) #include "../gcode/gcode.h" #endif @@ -1081,20 +1073,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { const bool should_move = safe_to_move && !no_move && IsRunning(); if (should_move) { - #if BOTH(HAS_FAN, SINGLENOZZLE_STANDBY_FAN) - singlenozzle_fan_speed[old_tool] = thermalManager.fan_speed[0]; - thermalManager.fan_speed[0] = singlenozzle_fan_speed[new_tool]; - #endif - - #if ENABLED(SINGLENOZZLE_STANDBY_TEMP) - singlenozzle_temp[old_tool] = thermalManager.temp_hotend[0].target; - if (singlenozzle_temp[new_tool] && singlenozzle_temp[new_tool] != singlenozzle_temp[old_tool]) { - thermalManager.setTargetHotend(singlenozzle_temp[new_tool], 0); - TERN_(AUTOTEMP, planner.autotemp_update()); - TERN_(HAS_DISPLAY, thermalManager.set_heating_message(0)); - (void)thermalManager.wait_for_hotend(0, false); // Wait for heating or cooling - } - #endif + TERN_(SINGLENOZZLE_STANDBY_TEMP, thermalManager.singlenozzle_change(old_tool, new_tool)); #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) if (should_swap && !too_cold) { diff --git a/Marlin/src/module/tool_change.h b/Marlin/src/module/tool_change.h index 6b739604f..4f88ca743 100644 --- a/Marlin/src/module/tool_change.h +++ b/Marlin/src/module/tool_change.h @@ -114,14 +114,6 @@ #endif -#if ENABLED(SINGLENOZZLE_STANDBY_TEMP) - extern uint16_t singlenozzle_temp[EXTRUDERS]; -#endif - -#if BOTH(HAS_FAN, SINGLENOZZLE_STANDBY_FAN) - extern uint8_t singlenozzle_fan_speed[EXTRUDERS]; -#endif - TERN_(ELECTROMAGNETIC_SWITCHING_TOOLHEAD, void est_init()); TERN_(SWITCHING_TOOLHEAD, void swt_init());