From 16922c26433b9aec9e09f4cc60fe5d5dd09a691a Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sun, 15 Jan 2023 17:32:56 +0100 Subject: [PATCH] TM: Restore extruder autofan state when stopping/resuming During thermal errors all fans are set to full speed. When the print is resumed or stopped *and* the thermal error is gone, also restore the autofan state. Fixes #3893 --- Firmware/fancheck.cpp | 10 ++++++++++ Firmware/fancheck.h | 1 + Firmware/ultralcd.cpp | 10 +++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Firmware/fancheck.cpp b/Firmware/fancheck.cpp index 12724582..ad14e3b4 100755 --- a/Firmware/fancheck.cpp +++ b/Firmware/fancheck.cpp @@ -294,3 +294,13 @@ void hotendFanSetFullSpeed() #endif //FAN_SOFT_PWM fanSpeed = 255; } + +void hotendDefaultAutoFanState() +{ +#if (defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1) +#ifdef EXTRUDER_ALTFAN_DETECT + altfanStatus.altfanOverride = eeprom_read_byte((uint8_t*)EEPROM_ALTFAN_OVERRIDE); +#endif + setExtruderAutoFanState(1); +#endif +} diff --git a/Firmware/fancheck.h b/Firmware/fancheck.h index 31214397..0e0f2743 100755 --- a/Firmware/fancheck.h +++ b/Firmware/fancheck.h @@ -33,3 +33,4 @@ void checkExtruderAutoFans(); void checkFans(); void hotendFanSetFullSpeed(); +void hotendDefaultAutoFanState(); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index de20edaf..67f9d4af 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -5435,7 +5435,12 @@ void lcd_resume_print() st_synchronize(); custom_message_type = CustomMsg::Resuming; isPrintPaused = false; - Stopped = false; // resume processing USB commands again + + // resume processing USB commands again and restore hotend fan state (in case the print was + // stopped due to a thermal error) + hotendDefaultAutoFanState(); + Stopped = false; + restore_print_from_ram_and_continue(default_retraction); pause_time += (_millis() - start_pause_print); //accumulate time when print is paused for correct statistics calculation refresh_cmd_timeout(); @@ -6073,6 +6078,9 @@ void lcd_print_stop_finish() } else { // Turn off the print fan fanSpeed = 0; + + // restore the auto hotend state + hotendDefaultAutoFanState(); } if (mmu_enabled) extr_unload(); //M702 C