Browse Source

Merge pull request #3196 from thinkyhead/rc_controllerfan_bug

Make DISABLE_INACTIVE_X, etc., true if missing
Scott Lahteine 9 years ago
parent
commit
f774420488
2 changed files with 25 additions and 6 deletions
  1. 16
    0
      Marlin/Conditionals.h
  2. 9
    6
      Marlin/Marlin_main.cpp

+ 16
- 0
Marlin/Conditionals.h View File

@@ -360,6 +360,22 @@
360 360
     #undef SD_DETECT_INVERTED
361 361
   #endif
362 362
 
363
+  /**
364
+   * Set defaults for missing (newer) options
365
+   */
366
+  #ifndef DISABLE_INACTIVE_X
367
+    #define DISABLE_INACTIVE_X DISABLE_X
368
+  #endif
369
+  #ifndef DISABLE_INACTIVE_Y
370
+    #define DISABLE_INACTIVE_Y DISABLE_Y
371
+  #endif
372
+  #ifndef DISABLE_INACTIVE_Z
373
+    #define DISABLE_INACTIVE_Z DISABLE_Z
374
+  #endif
375
+  #ifndef DISABLE_INACTIVE_E
376
+    #define DISABLE_INACTIVE_E DISABLE_E
377
+  #endif
378
+
363 379
   // Power Signal Control Definitions
364 380
   // By default use ATX definition
365 381
   #ifndef POWER_SUPPLY

+ 9
- 6
Marlin/Marlin_main.cpp View File

@@ -6997,11 +6997,11 @@ void plan_arc(
6997 6997
 #if HAS_CONTROLLERFAN
6998 6998
 
6999 6999
   void controllerFan() {
7000
-    static millis_t lastMotor = 0;      // Last time a motor was turned on
7001
-    static millis_t lastMotorCheck = 0; // Last time the state was checked
7000
+    static millis_t lastMotorOn = 0; // Last time a motor was turned on
7001
+    static millis_t nextMotorCheck = 0; // Last time the state was checked
7002 7002
     millis_t ms = millis();
7003
-    if (ms >= lastMotorCheck + 2500) { // Not a time critical function, so we only check every 2500ms
7004
-      lastMotorCheck = ms;
7003
+    if (ms >= nextMotorCheck) {
7004
+      nextMotorCheck = ms + 2500; // Not a time critical function, so only check every 2.5s
7005 7005
       if (X_ENABLE_READ == X_ENABLE_ON || Y_ENABLE_READ == Y_ENABLE_ON || Z_ENABLE_READ == Z_ENABLE_ON || soft_pwm_bed > 0
7006 7006
           || E0_ENABLE_READ == E_ENABLE_ON // If any of the drivers are enabled...
7007 7007
           #if EXTRUDERS > 1
@@ -7017,9 +7017,12 @@ void plan_arc(
7017 7017
             #endif
7018 7018
           #endif
7019 7019
       ) {
7020
-        lastMotor = ms; //... set time to NOW so the fan will turn on
7020
+        lastMotorOn = ms; //... set time to NOW so the fan will turn on
7021 7021
       }
7022
-      uint8_t speed = (lastMotor == 0 || ms >= lastMotor + ((CONTROLLERFAN_SECS) * 1000UL)) ? 0 : CONTROLLERFAN_SPEED;
7022
+
7023
+      // Fan off if no steppers have been enabled for CONTROLLERFAN_SECS seconds
7024
+      uint8_t speed = (lastMotorOn == 0 || ms >= lastMotorOn + (CONTROLLERFAN_SECS) * 1000UL) ? 0 : CONTROLLERFAN_SPEED;
7025
+
7023 7026
       // allows digital or PWM fan output to be used (see M42 handling)
7024 7027
       digitalWrite(CONTROLLERFAN_PIN, speed);
7025 7028
       analogWrite(CONTROLLERFAN_PIN, speed);

Loading…
Cancel
Save