Kaynağa Gözat

Fix #8579

Fan speed code fell into a curly brace
Scott Lahteine 7 yıl önce
ebeveyn
işleme
16baa48699
1 değiştirilmiş dosya ile 65 ekleme ve 73 silme
  1. 65
    73
      Marlin/src/module/planner.cpp

+ 65
- 73
Marlin/src/module/planner.cpp Dosyayı Görüntüle

@@ -423,75 +423,23 @@ void Planner::check_axes_activity() {
423 423
 
424 424
   #if ENABLED(BARICUDA)
425 425
     #if HAS_HEATER_1
426
-      uint8_t tail_valve_pressure;
426
+      uint8_t tail_valve_pressure = baricuda_valve_pressure;
427 427
     #endif
428 428
     #if HAS_HEATER_2
429
-      uint8_t tail_e_to_p_pressure;
429
+      uint8_t tail_e_to_p_pressure = baricuda_e_to_p_pressure;
430 430
     #endif
431 431
   #endif
432 432
 
433
+  #if FAN_COUNT > 0
434
+    for (uint8_t i = 0; i < FAN_COUNT; i++) tail_fan_speed[i] = fanSpeeds[i];
435
+  #endif
436
+
433 437
   if (blocks_queued()) {
434 438
 
435 439
     #if FAN_COUNT > 0
436
-
437 440
       for (uint8_t i = 0; i < FAN_COUNT; i++)
438 441
         tail_fan_speed[i] = block_buffer[block_buffer_tail].fan_speed[i];
439
-
440
-      #ifdef FAN_KICKSTART_TIME
441
-
442
-        static millis_t fan_kick_end[FAN_COUNT] = { 0 };
443
-
444
-        #define KICKSTART_FAN(f) \
445
-          if (tail_fan_speed[f]) { \
446
-            millis_t ms = millis(); \
447
-            if (fan_kick_end[f] == 0) { \
448
-              fan_kick_end[f] = ms + FAN_KICKSTART_TIME; \
449
-              tail_fan_speed[f] = 255; \
450
-            } else if (PENDING(ms, fan_kick_end[f])) \
451
-              tail_fan_speed[f] = 255; \
452
-          } else fan_kick_end[f] = 0
453
-
454
-        #if HAS_FAN0
455
-          KICKSTART_FAN(0);
456
-        #endif
457
-        #if HAS_FAN1
458
-          KICKSTART_FAN(1);
459
-        #endif
460
-        #if HAS_FAN2
461
-          KICKSTART_FAN(2);
462
-        #endif
463
-
464
-      #endif // FAN_KICKSTART_TIME
465
-
466
-      #ifdef FAN_MIN_PWM
467
-        #define CALC_FAN_SPEED(f) (tail_fan_speed[f] ? ( FAN_MIN_PWM + (tail_fan_speed[f] * (255 - FAN_MIN_PWM)) / 255 ) : 0)
468
-      #else
469
-        #define CALC_FAN_SPEED(f) tail_fan_speed[f]
470
-      #endif
471
-
472
-      #if ENABLED(FAN_SOFT_PWM)
473
-        #if HAS_FAN0
474
-          thermalManager.soft_pwm_amount_fan[0] = CALC_FAN_SPEED(0);
475
-        #endif
476
-        #if HAS_FAN1
477
-          thermalManager.soft_pwm_amount_fan[1] = CALC_FAN_SPEED(1);
478
-        #endif
479
-        #if HAS_FAN2
480
-          thermalManager.soft_pwm_amount_fan[2] = CALC_FAN_SPEED(2);
481
-        #endif
482
-      #else
483
-        #if HAS_FAN0
484
-          analogWrite(FAN_PIN, CALC_FAN_SPEED(0));
485
-        #endif
486
-        #if HAS_FAN1
487
-          analogWrite(FAN1_PIN, CALC_FAN_SPEED(1));
488
-        #endif
489
-        #if HAS_FAN2
490
-          analogWrite(FAN2_PIN, CALC_FAN_SPEED(2));
491
-        #endif
492
-      #endif
493
-
494
-    #endif // FAN_COUNT > 0
442
+    #endif
495 443
 
496 444
     block_t* block;
497 445
 
@@ -510,20 +458,6 @@ void Planner::check_axes_activity() {
510 458
       LOOP_XYZE(i) if (block->steps[i]) axis_active[i]++;
511 459
     }
512 460
   }
513
-  else {
514
-    #if FAN_COUNT > 0
515
-      for (uint8_t i = 0; i < FAN_COUNT; i++) tail_fan_speed[i] = fanSpeeds[i];
516
-    #endif
517
-
518
-    #if ENABLED(BARICUDA)
519
-      #if HAS_HEATER_1
520
-        tail_valve_pressure = baricuda_valve_pressure;
521
-      #endif
522
-      #if HAS_HEATER_2
523
-        tail_e_to_p_pressure = baricuda_e_to_p_pressure;
524
-      #endif
525
-    #endif
526
-  }
527 461
 
528 462
   #if ENABLED(DISABLE_X)
529 463
     if (!axis_active[X_AXIS]) disable_X();
@@ -538,6 +472,64 @@ void Planner::check_axes_activity() {
538 472
     if (!axis_active[E_AXIS]) disable_e_steppers();
539 473
   #endif
540 474
 
475
+  #if FAN_COUNT > 0
476
+
477
+    #if FAN_KICKSTART_TIME > 0
478
+
479
+      static millis_t fan_kick_end[FAN_COUNT] = { 0 };
480
+
481
+      #define KICKSTART_FAN(f) \
482
+        if (tail_fan_speed[f]) { \
483
+          millis_t ms = millis(); \
484
+          if (fan_kick_end[f] == 0) { \
485
+            fan_kick_end[f] = ms + FAN_KICKSTART_TIME; \
486
+            tail_fan_speed[f] = 255; \
487
+          } else if (PENDING(ms, fan_kick_end[f])) \
488
+            tail_fan_speed[f] = 255; \
489
+        } else fan_kick_end[f] = 0
490
+
491
+      #if HAS_FAN0
492
+        KICKSTART_FAN(0);
493
+      #endif
494
+      #if HAS_FAN1
495
+        KICKSTART_FAN(1);
496
+      #endif
497
+      #if HAS_FAN2
498
+        KICKSTART_FAN(2);
499
+      #endif
500
+
501
+    #endif // FAN_KICKSTART_TIME > 0
502
+
503
+    #ifdef FAN_MIN_PWM
504
+      #define CALC_FAN_SPEED(f) (tail_fan_speed[f] ? ( FAN_MIN_PWM + (tail_fan_speed[f] * (255 - FAN_MIN_PWM)) / 255 ) : 0)
505
+    #else
506
+      #define CALC_FAN_SPEED(f) tail_fan_speed[f]
507
+    #endif
508
+
509
+    #if ENABLED(FAN_SOFT_PWM)
510
+      #if HAS_FAN0
511
+        thermalManager.soft_pwm_amount_fan[0] = CALC_FAN_SPEED(0);
512
+      #endif
513
+      #if HAS_FAN1
514
+        thermalManager.soft_pwm_amount_fan[1] = CALC_FAN_SPEED(1);
515
+      #endif
516
+      #if HAS_FAN2
517
+        thermalManager.soft_pwm_amount_fan[2] = CALC_FAN_SPEED(2);
518
+      #endif
519
+    #else
520
+      #if HAS_FAN0
521
+        analogWrite(FAN_PIN, CALC_FAN_SPEED(0));
522
+      #endif
523
+      #if HAS_FAN1
524
+        analogWrite(FAN1_PIN, CALC_FAN_SPEED(1));
525
+      #endif
526
+      #if HAS_FAN2
527
+        analogWrite(FAN2_PIN, CALC_FAN_SPEED(2));
528
+      #endif
529
+    #endif
530
+
531
+  #endif // FAN_COUNT > 0
532
+
541 533
   #if ENABLED(AUTOTEMP)
542 534
     getHighESpeed();
543 535
   #endif

Loading…
İptal
Kaydet