Bläddra i källkod

Reorganize check_axes_activity

Scott Lahteine 7 år sedan
förälder
incheckning
04419af419
2 ändrade filer med 77 tillägg och 67 borttagningar
  1. 1
    1
      .travis.yml
  2. 76
    66
      Marlin/planner.cpp

+ 1
- 1
.travis.yml Visa fil

215
   - opt_set_adv FAN_MIN_PWM 50
215
   - opt_set_adv FAN_MIN_PWM 50
216
   - opt_set_adv FAN_KICKSTART_TIME 100
216
   - opt_set_adv FAN_KICKSTART_TIME 100
217
   - opt_set_adv XY_FREQUENCY_LIMIT  15
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
   - opt_enable_adv ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED ADVANCED_OK
219
   - opt_enable_adv ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED ADVANCED_OK
220
   - opt_enable_adv VOLUMETRIC_DEFAULT_ON NO_WORKSPACE_OFFSETS ACTION_ON_KILL
220
   - opt_enable_adv VOLUMETRIC_DEFAULT_ON NO_WORKSPACE_OFFSETS ACTION_ON_KILL
221
   - opt_enable_adv EXTRA_FAN_SPEED FWERETRACT Z_DUAL_STEPPER_DRIVERS Z_DUAL_ENDSTOPS
221
   - opt_enable_adv EXTRA_FAN_SPEED FWERETRACT Z_DUAL_STEPPER_DRIVERS Z_DUAL_ENDSTOPS

+ 76
- 66
Marlin/planner.cpp Visa fil

407
   unsigned char axis_active[NUM_AXIS] = { 0 },
407
   unsigned char axis_active[NUM_AXIS] = { 0 },
408
                 tail_fan_speed[FAN_COUNT];
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
   #if ENABLED(BARICUDA)
410
   #if ENABLED(BARICUDA)
415
     #if HAS_HEATER_1
411
     #if HAS_HEATER_1
416
-      uint8_t tail_valve_pressure = baricuda_valve_pressure;
412
+      uint8_t tail_valve_pressure;
417
     #endif
413
     #endif
418
     #if HAS_HEATER_2
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
     #endif
416
     #endif
421
   #endif
417
   #endif
422
 
418
 
423
   if (blocks_queued()) {
419
   if (blocks_queued()) {
424
 
420
 
425
     #if FAN_COUNT > 0
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
     block_t* block;
482
     block_t* block;
430
 
483
 
443
       LOOP_XYZE(i) if (block->steps[i]) axis_active[i]++;
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
   #if ENABLED(DISABLE_X)
514
   #if ENABLED(DISABLE_X)
447
     if (!axis_active[X_AXIS]) disable_X();
515
     if (!axis_active[X_AXIS]) disable_X();
448
   #endif
516
   #endif
456
     if (!axis_active[E_AXIS]) disable_e_steppers();
524
     if (!axis_active[E_AXIS]) disable_e_steppers();
457
   #endif
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
   #if ENABLED(AUTOTEMP)
527
   #if ENABLED(AUTOTEMP)
518
     getHighESpeed();
528
     getHighESpeed();
519
   #endif
529
   #endif

Laddar…
Avbryt
Spara