diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index d5508401de..4b0ee355d4 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -907,11 +907,10 @@ volatile bool Temperature::raw_temps_ready = false; SERIAL_ECHOPGM(STR_MPC_AUTOTUNE); SERIAL_ECHOLNPGM(STR_MPC_AUTOTUNE_INTERRUPTED); TERN_(DWIN_LCD_PROUI, DWIN_MPCTuning(MPC_INTERRUPTED)); - return false; + return true; } - wait_for_heatup = false; - return true; + return false; }; struct OnExit { @@ -964,7 +963,7 @@ volatile bool Temperature::raw_temps_ready = false; wait_for_heatup = true; for (;;) { // Can be interrupted with M108 - if (!housekeeping(ms, current_temp, next_report_ms)) return; + if (housekeeping(ms, current_temp, next_report_ms)) return; if (ELAPSED(ms, next_test_ms)) { if (current_temp >= ambient_temp) { @@ -975,6 +974,7 @@ volatile bool Temperature::raw_temps_ready = false; next_test_ms += 10000UL; } } + wait_for_heatup = false; #if HAS_FAN set_fan_speed(EITHER(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 0); @@ -986,7 +986,7 @@ volatile bool Temperature::raw_temps_ready = false; SERIAL_ECHOLNPGM(STR_MPC_HEATING_PAST_200); TERN(DWIN_LCD_PROUI, LCD_ALERTMESSAGE(MSG_MPC_HEATING_PAST_200), LCD_MESSAGE(MSG_HEATING)); hotend.target = 200.0f; // So M105 looks nice - hotend.soft_pwm_amount = MPC_MAX >> 1; + hotend.soft_pwm_amount = (MPC_MAX) >> 1; const millis_t heat_start_time = next_test_ms = ms; celsius_float_t temp_samples[16]; uint8_t sample_count = 0; @@ -995,7 +995,7 @@ volatile bool Temperature::raw_temps_ready = false; wait_for_heatup = true; for (;;) { // Can be interrupted with M108 - if (!housekeeping(ms, current_temp, next_report_ms)) return; + if (housekeeping(ms, current_temp, next_report_ms)) return; if (ELAPSED(ms, next_test_ms)) { // Record samples between 100C and 200C @@ -1017,6 +1017,8 @@ volatile bool Temperature::raw_temps_ready = false; next_test_ms += 1000UL * sample_distance; } } + wait_for_heatup = false; + hotend.soft_pwm_amount = 0; // Calculate physical constants from three equally-spaced samples @@ -1052,7 +1054,7 @@ volatile bool Temperature::raw_temps_ready = false; wait_for_heatup = true; for (;;) { // Can be interrupted with M108 - if (!housekeeping(ms, current_temp, next_report_ms)) return; + if (housekeeping(ms, current_temp, next_report_ms)) return; if (ELAPSED(ms, next_test_ms)) { hotend.soft_pwm_amount = (int)get_pid_output_hotend(active_extruder) >> 1; @@ -1082,6 +1084,7 @@ volatile bool Temperature::raw_temps_ready = false; break; } } + wait_for_heatup = false; const float power_fan0 = total_energy_fan0 * 1000 / test_duration; mpc.ambient_xfer_coeff_fan0 = power_fan0 / (hotend.target - ambient_temp); diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index c947a6789a..afbf656a7a 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -1162,6 +1162,12 @@ class Temperature { static void auto_job_check_timer(const bool can_start, const bool can_stop); #endif + #if ENABLED(TEMP_TUNING_MAINTAIN_FAN) + static bool adaptive_fan_slowing; + #elif ENABLED(ADAPTIVE_FAN_SLOWING) + static constexpr bool adaptive_fan_slowing = true; + #endif + /** * Perform auto-tuning for hotend or bed in response to M303 */ @@ -1173,12 +1179,6 @@ class Temperature { static void PID_autotune(const celsius_t target, const heater_id_t heater_id, const int8_t ncycles, const bool set_result=false); - #if ENABLED(TEMP_TUNING_MAINTAIN_FAN) - static bool adaptive_fan_slowing; - #elif ENABLED(ADAPTIVE_FAN_SLOWING) - static constexpr bool adaptive_fan_slowing = true; - #endif - // Update the temp manager when PID values change #if ENABLED(PIDTEMP) static void updatePID() { HOTEND_LOOP() temp_hotend[e].pid.reset(); }