From 62c280a60f8edcd0a7890f1225e6b601eca9d835 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 15 Oct 2022 10:03:10 -0400 Subject: [PATCH] Update controllerfan.cpp Update controllerfan.cpp --- Marlin/src/feature/controllerfan.cpp | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/Marlin/src/feature/controllerfan.cpp b/Marlin/src/feature/controllerfan.cpp index a37147747b..1d86ca3421 100644 --- a/Marlin/src/feature/controllerfan.cpp +++ b/Marlin/src/feature/controllerfan.cpp @@ -73,9 +73,9 @@ void ControllerFan::update() { ); #if FAN_MIN_PWM != 0 || FAN_MAX_PWM != 255 - #define CALC_FAN_SPEED (speed ? map(speed, 1, 255, FAN_MIN_PWM, FAN_MAX_PWM) : FAN_OFF_PWM) + speed = (speed ? map(speed, 1, 255, FAN_MIN_PWM, FAN_MAX_PWM) : FAN_OFF_PWM); #else - #define CALC_FAN_SPEED (speed ?: FAN_OFF_PWM) + speed = (speed ?: FAN_OFF_PWM); #endif do{ @@ -84,7 +84,7 @@ void ControllerFan::update() { static millis_t fan_kick_end = { 0 }; if (speed) { if (fan_kick_end == 0) { - fan_kick_end = ms + FAN_KICKSTART_TIME; + fan_kick_end = ms + FAN_KICKSTART_TIME; // May be longer based on slow update interval for controller fn check. Sets minimum fan_speed = 255; } else if (PENDING(ms, fan_kick_end)) @@ -92,18 +92,17 @@ void ControllerFan::update() { } else fan_kick_end = 0; + #endif - #endif - - #if ENABLED(FAN_SOFT_PWM) - thermalManager.soft_pwm_controller_speed = speed; - #else - if (PWM_PIN(CONTROLLER_FAN_PIN)) - hal.set_pwm_duty(pin_t(CONTROLLER_FAN_PIN), speed); - else - WRITE(CONTROLLER_FAN_PIN, speed > 0); - #endif - }while(0) + #if ENABLED(FAN_SOFT_PWM) + thermalManager.soft_pwm_controller_speed = speed; + #else + if (PWM_PIN(CONTROLLER_FAN_PIN)) + hal.set_pwm_duty(pin_t(CONTROLLER_FAN_PIN), speed); + else + WRITE(CONTROLLER_FAN_PIN, speed > 0); + #endif + }while(0); } }