Bladeren bron

Reorganize check_axes_activity

Scott Lahteine 7 jaren geleden
bovenliggende
commit
04419af419
2 gewijzigde bestanden met toevoegingen van 77 en 67 verwijderingen
  1. 1
    1
      .travis.yml
  2. 76
    66
      Marlin/planner.cpp

+ 1
- 1
.travis.yml Bestand weergeven

@@ -215,7 +215,7 @@ script:
215 215
   - opt_set_adv FAN_MIN_PWM 50
216 216
   - opt_set_adv FAN_KICKSTART_TIME 100
217 217
   - opt_set_adv XY_FREQUENCY_LIMIT  15
218
-  - opt_enable_adv SHOW_TEMP_ADC_VALUES HOME_Y_BEFORE_X EMERGENCY_PARSER
218
+  - opt_enable_adv SHOW_TEMP_ADC_VALUES HOME_Y_BEFORE_X EMERGENCY_PARSER FAN_KICKSTART_TIME
219 219
   - opt_enable_adv ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED ADVANCED_OK
220 220
   - opt_enable_adv VOLUMETRIC_DEFAULT_ON NO_WORKSPACE_OFFSETS ACTION_ON_KILL
221 221
   - opt_enable_adv EXTRA_FAN_SPEED FWERETRACT Z_DUAL_STEPPER_DRIVERS Z_DUAL_ENDSTOPS

+ 76
- 66
Marlin/planner.cpp Bestand weergeven

@@ -407,24 +407,77 @@ void Planner::check_axes_activity() {
407 407
   unsigned char axis_active[NUM_AXIS] = { 0 },
408 408
                 tail_fan_speed[FAN_COUNT];
409 409
 
410
-  #if FAN_COUNT > 0
411
-    for (uint8_t i = 0; i < FAN_COUNT; i++) tail_fan_speed[i] = fanSpeeds[i];
412
-  #endif
413
-
414 410
   #if ENABLED(BARICUDA)
415 411
     #if HAS_HEATER_1
416
-      uint8_t tail_valve_pressure = baricuda_valve_pressure;
412
+      uint8_t tail_valve_pressure;
417 413
     #endif
418 414
     #if HAS_HEATER_2
419
-      uint8_t tail_e_to_p_pressure = baricuda_e_to_p_pressure;
415
+      uint8_t tail_e_to_p_pressure;
420 416
     #endif
421 417
   #endif
422 418
 
423 419
   if (blocks_queued()) {
424 420
 
425 421
     #if FAN_COUNT > 0
426
-      for (uint8_t i = 0; i < FAN_COUNT; i++) tail_fan_speed[i] = block_buffer[block_buffer_tail].fan_speed[i];
427
-    #endif
422
+
423
+      for (uint8_t i = 0; i < FAN_COUNT; i++)
424
+        tail_fan_speed[i] = block_buffer[block_buffer_tail].fan_speed[i];
425
+
426
+      #ifdef FAN_KICKSTART_TIME
427
+
428
+        static millis_t fan_kick_end[FAN_COUNT] = { 0 };
429
+
430
+        #define KICKSTART_FAN(f)                         \
431
+          if (tail_fan_speed[f]) {                       \ // is the fan turned on?
432
+            millis_t ms = millis();                      \
433
+            if (fan_kick_end[f] == 0) {                  \ // not yet kickstarted?
434
+              fan_kick_end[f] = ms + FAN_KICKSTART_TIME; \ // kickstart until this time
435
+              tail_fan_speed[f] = 255;                   \ // full speed
436
+            } else if (PENDING(ms, fan_kick_end[f]))     \ // kickstart in progress?
437
+              tail_fan_speed[f] = 255;                   \ // keep full speed going
438
+          } else fan_kick_end[f] = 0                       // fan off? kick next time
439
+
440
+        #if HAS_FAN0
441
+          KICKSTART_FAN(0);
442
+        #endif
443
+        #if HAS_FAN1
444
+          KICKSTART_FAN(1);
445
+        #endif
446
+        #if HAS_FAN2
447
+          KICKSTART_FAN(2);
448
+        #endif
449
+
450
+      #endif // FAN_KICKSTART_TIME
451
+
452
+      #ifdef FAN_MIN_PWM
453
+        #define CALC_FAN_SPEED(f) (tail_fan_speed[f] ? ( FAN_MIN_PWM + (tail_fan_speed[f] * (255 - FAN_MIN_PWM)) / 255 ) : 0)
454
+      #else
455
+        #define CALC_FAN_SPEED(f) tail_fan_speed[f]
456
+      #endif
457
+
458
+      #if ENABLED(FAN_SOFT_PWM)
459
+        #if HAS_FAN0
460
+          thermalManager.soft_pwm_amount_fan[0] = CALC_FAN_SPEED(0);
461
+        #endif
462
+        #if HAS_FAN1
463
+          thermalManager.soft_pwm_amount_fan[1] = CALC_FAN_SPEED(1);
464
+        #endif
465
+        #if HAS_FAN2
466
+          thermalManager.soft_pwm_amount_fan[2] = CALC_FAN_SPEED(2);
467
+        #endif
468
+      #else
469
+        #if HAS_FAN0
470
+          analogWrite(FAN_PIN, CALC_FAN_SPEED(0));
471
+        #endif
472
+        #if HAS_FAN1
473
+          analogWrite(FAN1_PIN, CALC_FAN_SPEED(1));
474
+        #endif
475
+        #if HAS_FAN2
476
+          analogWrite(FAN2_PIN, CALC_FAN_SPEED(2));
477
+        #endif
478
+      #endif
479
+
480
+    #endif // FAN_COUNT > 0
428 481
 
429 482
     block_t* block;
430 483
 
@@ -443,6 +496,21 @@ void Planner::check_axes_activity() {
443 496
       LOOP_XYZE(i) if (block->steps[i]) axis_active[i]++;
444 497
     }
445 498
   }
499
+  else {
500
+    #if FAN_COUNT > 0
501
+      for (uint8_t i = 0; i < FAN_COUNT; i++) tail_fan_speed[i] = fanSpeeds[i];
502
+    #endif
503
+
504
+    #if ENABLED(BARICUDA)
505
+      #if HAS_HEATER_1
506
+        tail_valve_pressure = baricuda_valve_pressure;
507
+      #endif
508
+      #if HAS_HEATER_2
509
+        tail_e_to_p_pressure = baricuda_e_to_p_pressure;
510
+      #endif
511
+    #endif
512
+  }
513
+
446 514
   #if ENABLED(DISABLE_X)
447 515
     if (!axis_active[X_AXIS]) disable_X();
448 516
   #endif
@@ -456,64 +524,6 @@ void Planner::check_axes_activity() {
456 524
     if (!axis_active[E_AXIS]) disable_e_steppers();
457 525
   #endif
458 526
 
459
-  #if FAN_COUNT > 0
460
-
461
-    #ifdef FAN_MIN_PWM
462
-      #define CALC_FAN_SPEED(f) (tail_fan_speed[f] ? ( FAN_MIN_PWM + (tail_fan_speed[f] * (255 - FAN_MIN_PWM)) / 255 ) : 0)
463
-    #else
464
-      #define CALC_FAN_SPEED(f) tail_fan_speed[f]
465
-    #endif
466
-
467
-    #ifdef FAN_KICKSTART_TIME
468
-
469
-      static millis_t fan_kick_end[FAN_COUNT] = { 0 };
470
-
471
-      #define KICKSTART_FAN(f) \
472
-        if (tail_fan_speed[f]) { \
473
-          millis_t ms = millis(); \
474
-          if (fan_kick_end[f] == 0) { \
475
-            fan_kick_end[f] = ms + FAN_KICKSTART_TIME; \
476
-            tail_fan_speed[f] = 255; \
477
-          } else if (PENDING(ms, fan_kick_end[f])) \
478
-            tail_fan_speed[f] = 255; \
479
-        } else fan_kick_end[f] = 0
480
-
481
-      #if HAS_FAN0
482
-        KICKSTART_FAN(0);
483
-      #endif
484
-      #if HAS_FAN1
485
-        KICKSTART_FAN(1);
486
-      #endif
487
-      #if HAS_FAN2
488
-        KICKSTART_FAN(2);
489
-      #endif
490
-
491
-    #endif // FAN_KICKSTART_TIME
492
-
493
-    #if ENABLED(FAN_SOFT_PWM)
494
-      #if HAS_FAN0
495
-        thermalManager.soft_pwm_amount_fan[0] = CALC_FAN_SPEED(0);
496
-      #endif
497
-      #if HAS_FAN1
498
-        thermalManager.soft_pwm_amount_fan[1] = CALC_FAN_SPEED(1);
499
-      #endif
500
-      #if HAS_FAN2
501
-        thermalManager.soft_pwm_amount_fan[2] = CALC_FAN_SPEED(2);
502
-      #endif
503
-    #else
504
-      #if HAS_FAN0
505
-        analogWrite(FAN_PIN, CALC_FAN_SPEED(0));
506
-      #endif
507
-      #if HAS_FAN1
508
-        analogWrite(FAN1_PIN, CALC_FAN_SPEED(1));
509
-      #endif
510
-      #if HAS_FAN2
511
-        analogWrite(FAN2_PIN, CALC_FAN_SPEED(2));
512
-      #endif
513
-    #endif
514
-
515
-  #endif // FAN_COUNT > 0
516
-
517 527
   #if ENABLED(AUTOTEMP)
518 528
     getHighESpeed();
519 529
   #endif

Laden…
Annuleren
Opslaan