|
@@ -6986,11 +6986,11 @@ void plan_arc(
|
6986
|
6986
|
#if HAS_CONTROLLERFAN
|
6987
|
6987
|
|
6988
|
6988
|
void controllerFan() {
|
6989
|
|
- static millis_t lastMotor = 0; // Last time a motor was turned on
|
6990
|
|
- static millis_t lastMotorCheck = 0; // Last time the state was checked
|
|
6989
|
+ static millis_t lastMotorOn = 0; // Last time a motor was turned on
|
|
6990
|
+ static millis_t nextMotorCheck = 0; // Last time the state was checked
|
6991
|
6991
|
millis_t ms = millis();
|
6992
|
|
- if (ms >= lastMotorCheck + 2500) { // Not a time critical function, so we only check every 2500ms
|
6993
|
|
- lastMotorCheck = ms;
|
|
6992
|
+ if (ms >= nextMotorCheck) {
|
|
6993
|
+ nextMotorCheck = ms + 2500; // Not a time critical function, so only check every 2.5s
|
6994
|
6994
|
if (X_ENABLE_READ == X_ENABLE_ON || Y_ENABLE_READ == Y_ENABLE_ON || Z_ENABLE_READ == Z_ENABLE_ON || soft_pwm_bed > 0
|
6995
|
6995
|
|| E0_ENABLE_READ == E_ENABLE_ON // If any of the drivers are enabled...
|
6996
|
6996
|
#if EXTRUDERS > 1
|
|
@@ -7006,9 +7006,12 @@ void plan_arc(
|
7006
|
7006
|
#endif
|
7007
|
7007
|
#endif
|
7008
|
7008
|
) {
|
7009
|
|
- lastMotor = ms; //... set time to NOW so the fan will turn on
|
|
7009
|
+ lastMotorOn = ms; //... set time to NOW so the fan will turn on
|
7010
|
7010
|
}
|
7011
|
|
- uint8_t speed = (lastMotor == 0 || ms >= lastMotor + ((CONTROLLERFAN_SECS) * 1000UL)) ? 0 : CONTROLLERFAN_SPEED;
|
|
7011
|
+
|
|
7012
|
+ // Fan off if no steppers have been enabled for CONTROLLERFAN_SECS seconds
|
|
7013
|
+ uint8_t speed = (lastMotorOn == 0 || ms >= lastMotorOn + (CONTROLLERFAN_SECS) * 1000UL) ? 0 : CONTROLLERFAN_SPEED;
|
|
7014
|
+
|
7012
|
7015
|
// allows digital or PWM fan output to be used (see M42 handling)
|
7013
|
7016
|
digitalWrite(CONTROLLERFAN_PIN, speed);
|
7014
|
7017
|
analogWrite(CONTROLLERFAN_PIN, speed);
|