From 79dcfe5455717a2a1cbc4ff1af86067cd0cd2bd7 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Mon, 17 Oct 2022 18:39:02 -0400 Subject: [PATCH] Init values to FAN_OFF_PWM, compare for greater than instead of not equal to in order to catch edge cases --- Marlin/src/feature/controllerfan.cpp | 2 +- Marlin/src/module/planner.cpp | 2 +- Marlin/src/module/temperature.cpp | 14 +++++++------- Marlin/src/module/tool_change.cpp | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Marlin/src/feature/controllerfan.cpp b/Marlin/src/feature/controllerfan.cpp index 1e0836ce2a..2f25832cdc 100644 --- a/Marlin/src/feature/controllerfan.cpp +++ b/Marlin/src/feature/controllerfan.cpp @@ -76,7 +76,7 @@ void ControllerFan::update() { #if FAN_KICKSTART_TIME static millis_t fan_kick_end = 0; - if (speed != FAN_OFF_PWM) { + if (speed > FAN_OFF_PWM) { if (!fan_kick_end) { fan_kick_end = ms + FAN_KICKSTART_TIME; // May be longer based on slow update interval for controller fn check. Sets minimum speed = FAN_KICKSTART_POWER; diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 8433245f32..38c16d6ae2 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1300,7 +1300,7 @@ void Planner::recalculate(TERN_(HINTS_SAFE_EXIT_SPEED, const_float_t safe_exit_s void Planner::kickstart_fan(uint8_t (&fan_speed)[FAN_COUNT], const millis_t &ms, const uint8_t f) { static millis_t fan_kick_end[FAN_COUNT] = { 0 }; - if (fan_speed[f] != FAN_OFF_PWM) { + if (fan_speed[f] > FAN_OFF_PWM) { if (fan_kick_end[f] == 0) { fan_kick_end[f] = ms + FAN_KICKSTART_TIME; fan_speed[f] = FAN_KICKSTART_POWER; diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 7954611bc4..c3918eca6e 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -309,19 +309,19 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #endif #if EITHER(AUTO_POWER_E_FANS, HAS_FANCHECK) - uint8_t Temperature::autofan_speed[HOTENDS]; // = { 0 } + uint8_t Temperature::autofan_speed[HOTENDS] = {FAN_OFF_PWM}; #endif #if ENABLED(AUTO_POWER_CHAMBER_FAN) - uint8_t Temperature::chamberfan_speed; // = 0 + uint8_t Temperature::chamberfan_speed = {FAN_OFF_PWM} #endif #if ENABLED(AUTO_POWER_COOLER_FAN) - uint8_t Temperature::coolerfan_speed; // = 0 + uint8_t Temperature::coolerfan_speed = {FAN_OFF_PWM}; #endif #if BOTH(FAN_SOFT_PWM, USE_CONTROLLER_FAN) - uint8_t Temperature::soft_pwm_controller_speed; + uint8_t Temperature::soft_pwm_controller_speed = {FAN_OFF_PWM}; #endif // Init fans according to whether they're native PWM or Software PWM @@ -345,11 +345,11 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); // HAS_FAN does not include CONTROLLER_FAN #if HAS_FAN - uint8_t Temperature::fan_speed[FAN_COUNT]; // = { 0 } + uint8_t Temperature::fan_speed[FAN_COUNT] = {FAN_OFF_PWM}; #if ENABLED(EXTRA_FAN_SPEED) - Temperature::extra_fan_t Temperature::extra_fan_speed[FAN_COUNT]; + Temperature::extra_fan_t Temperature::extra_fan_speed[FAN_COUNT] = {FAN_OFF_PWM}; /** * Handle the M106 P T command: @@ -376,7 +376,7 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #if EITHER(PROBING_FANS_OFF, ADVANCED_PAUSE_FANS_PAUSE) bool Temperature::fans_paused; // = false; - uint8_t Temperature::saved_fan_speed[FAN_COUNT]; // = { 0 } + uint8_t Temperature::saved_fan_speed[FAN_COUNT] = {FAN_OFF_PWM}; #endif #if ENABLED(ADAPTIVE_FAN_SLOWING) diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 4eb72a5b7d..80aedd3bdd 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -917,7 +917,7 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. #if HAS_FAN && TOOLCHANGE_FS_FAN >= 0 thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = toolchange_settings.fan_speed; gcode.dwell(SEC_TO_MS(toolchange_settings.fan_time)); - thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = 0; + thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = FAN_OFF_PWM; #endif }