ソースを参照

Overridable Options - Part 10 (PR#2562)

Apply `ENABLED` / `DISABLED` macros to planner files.
Scott Lahteine 10年前
コミット
bf6eb93c61
2個のファイルの変更39行の追加39行の削除
  1. 34
    34
      Marlin/planner.cpp
  2. 5
    5
      Marlin/planner.h

+ 34
- 34
Marlin/planner.cpp ファイルの表示

55
 #include "ultralcd.h"
55
 #include "ultralcd.h"
56
 #include "language.h"
56
 #include "language.h"
57
 
57
 
58
-#ifdef MESH_BED_LEVELING
58
+#if ENABLED(MESH_BED_LEVELING)
59
   #include "mesh_bed_leveling.h"
59
   #include "mesh_bed_leveling.h"
60
 #endif
60
 #endif
61
 
61
 
77
 float mintravelfeedrate;
77
 float mintravelfeedrate;
78
 unsigned long axis_steps_per_sqr_second[NUM_AXIS];
78
 unsigned long axis_steps_per_sqr_second[NUM_AXIS];
79
 
79
 
80
-#ifdef ENABLE_AUTO_BED_LEVELING
80
+#if ENABLED(ENABLE_AUTO_BED_LEVELING)
81
   // Transform required to compensate for bed level
81
   // Transform required to compensate for bed level
82
   matrix_3x3 plan_bed_level_matrix = {
82
   matrix_3x3 plan_bed_level_matrix = {
83
     1.0, 0.0, 0.0,
83
     1.0, 0.0, 0.0,
86
   };
86
   };
87
 #endif // ENABLE_AUTO_BED_LEVELING
87
 #endif // ENABLE_AUTO_BED_LEVELING
88
 
88
 
89
-#ifdef AUTOTEMP
89
+#if ENABLED(AUTOTEMP)
90
   float autotemp_max = 250;
90
   float autotemp_max = 250;
91
   float autotemp_min = 210;
91
   float autotemp_min = 210;
92
   float autotemp_factor = 0.1;
92
   float autotemp_factor = 0.1;
121
   static long axis_segment_time[2][3] = { {MAX_FREQ_TIME+1,0,0}, {MAX_FREQ_TIME+1,0,0} };
121
   static long axis_segment_time[2][3] = { {MAX_FREQ_TIME+1,0,0}, {MAX_FREQ_TIME+1,0,0} };
122
 #endif
122
 #endif
123
 
123
 
124
-#ifdef FILAMENT_SENSOR
124
+#if ENABLED(FILAMENT_SENSOR)
125
   static char meas_sample; //temporary variable to hold filament measurement sample
125
   static char meas_sample; //temporary variable to hold filament measurement sample
126
 #endif
126
 #endif
127
 
127
 
178
     plateau_steps = 0;
178
     plateau_steps = 0;
179
   }
179
   }
180
 
180
 
181
-#ifdef ADVANCE
181
+#if ENABLED(ADVANCE)
182
   volatile long initial_advance = block->advance * entry_factor * entry_factor; 
182
   volatile long initial_advance = block->advance * entry_factor * entry_factor; 
183
   volatile long final_advance = block->advance * exit_factor * exit_factor;
183
   volatile long final_advance = block->advance * exit_factor * exit_factor;
184
 #endif // ADVANCE
184
 #endif // ADVANCE
191
     block->decelerate_after = accelerate_steps+plateau_steps;
191
     block->decelerate_after = accelerate_steps+plateau_steps;
192
     block->initial_rate = initial_rate;
192
     block->initial_rate = initial_rate;
193
     block->final_rate = final_rate;
193
     block->final_rate = final_rate;
194
-    #ifdef ADVANCE
194
+    #if ENABLED(ADVANCE)
195
       block->initial_advance = initial_advance;
195
       block->initial_advance = initial_advance;
196
       block->final_advance = final_advance;
196
       block->final_advance = final_advance;
197
     #endif
197
     #endif
361
 }
361
 }
362
 
362
 
363
 
363
 
364
-#ifdef AUTOTEMP
364
+#if ENABLED(AUTOTEMP)
365
   void getHighESpeed() {
365
   void getHighESpeed() {
366
     static float oldt = 0;
366
     static float oldt = 0;
367
 
367
 
394
 void check_axes_activity() {
394
 void check_axes_activity() {
395
   unsigned char axis_active[NUM_AXIS] = { 0 },
395
   unsigned char axis_active[NUM_AXIS] = { 0 },
396
                 tail_fan_speed = fanSpeed;
396
                 tail_fan_speed = fanSpeed;
397
-  #ifdef BARICUDA
397
+  #if ENABLED(BARICUDA)
398
     unsigned char tail_valve_pressure = ValvePressure,
398
     unsigned char tail_valve_pressure = ValvePressure,
399
                   tail_e_to_p_pressure = EtoPPressure;
399
                   tail_e_to_p_pressure = EtoPPressure;
400
   #endif
400
   #endif
404
   if (blocks_queued()) {
404
   if (blocks_queued()) {
405
     uint8_t block_index = block_buffer_tail;
405
     uint8_t block_index = block_buffer_tail;
406
     tail_fan_speed = block_buffer[block_index].fan_speed;
406
     tail_fan_speed = block_buffer[block_index].fan_speed;
407
-    #ifdef BARICUDA
407
+    #if ENABLED(BARICUDA)
408
       block = &block_buffer[block_index];
408
       block = &block_buffer[block_index];
409
       tail_valve_pressure = block->valve_pressure;
409
       tail_valve_pressure = block->valve_pressure;
410
       tail_e_to_p_pressure = block->e_to_p_pressure;
410
       tail_e_to_p_pressure = block->e_to_p_pressure;
441
           fan_kick_end = 0;
441
           fan_kick_end = 0;
442
         }
442
         }
443
     #endif //FAN_KICKSTART_TIME
443
     #endif //FAN_KICKSTART_TIME
444
-    #ifdef FAN_MIN_PWM
444
+    #if ENABLED(FAN_MIN_PWM)
445
       #define CALC_FAN_SPEED (tail_fan_speed ? ( FAN_MIN_PWM + (tail_fan_speed * (255 - FAN_MIN_PWM)) / 255 ) : 0)
445
       #define CALC_FAN_SPEED (tail_fan_speed ? ( FAN_MIN_PWM + (tail_fan_speed * (255 - FAN_MIN_PWM)) / 255 ) : 0)
446
     #else
446
     #else
447
       #define CALC_FAN_SPEED tail_fan_speed
447
       #define CALC_FAN_SPEED tail_fan_speed
448
     #endif // FAN_MIN_PWM
448
     #endif // FAN_MIN_PWM
449
-    #ifdef FAN_SOFT_PWM
449
+    #if ENABLED(FAN_SOFT_PWM)
450
       fanSpeedSoftPwm = CALC_FAN_SPEED;
450
       fanSpeedSoftPwm = CALC_FAN_SPEED;
451
     #else
451
     #else
452
       analogWrite(FAN_PIN, CALC_FAN_SPEED);
452
       analogWrite(FAN_PIN, CALC_FAN_SPEED);
453
     #endif // FAN_SOFT_PWM
453
     #endif // FAN_SOFT_PWM
454
   #endif // HAS_FAN
454
   #endif // HAS_FAN
455
 
455
 
456
-  #ifdef AUTOTEMP
456
+  #if ENABLED(AUTOTEMP)
457
     getHighESpeed();
457
     getHighESpeed();
458
   #endif
458
   #endif
459
 
459
 
460
-  #ifdef BARICUDA
460
+  #if ENABLED(BARICUDA)
461
     #if HAS_HEATER_1
461
     #if HAS_HEATER_1
462
       analogWrite(HEATER_1_PIN,tail_valve_pressure);
462
       analogWrite(HEATER_1_PIN,tail_valve_pressure);
463
     #endif
463
     #endif
472
 // Add a new linear movement to the buffer. steps[X_AXIS], _y and _z is the absolute position in 
472
 // Add a new linear movement to the buffer. steps[X_AXIS], _y and _z is the absolute position in 
473
 // mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration
473
 // mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration
474
 // calculation the caller must also provide the physical length of the line in millimeters.
474
 // calculation the caller must also provide the physical length of the line in millimeters.
475
-#if defined(ENABLE_AUTO_BED_LEVELING) || defined(MESH_BED_LEVELING)
475
+#if ENABLED(ENABLE_AUTO_BED_LEVELING) || ENABLED(MESH_BED_LEVELING)
476
   void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, const uint8_t extruder)
476
   void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, const uint8_t extruder)
477
 #else
477
 #else
478
   void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t extruder)
478
   void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t extruder)
485
   // Rest here until there is room in the buffer.
485
   // Rest here until there is room in the buffer.
486
   while (block_buffer_tail == next_buffer_head) idle();
486
   while (block_buffer_tail == next_buffer_head) idle();
487
 
487
 
488
-  #ifdef MESH_BED_LEVELING
488
+  #if ENABLED(MESH_BED_LEVELING)
489
     if (mbl.active) z += mbl.get_z(x, y);
489
     if (mbl.active) z += mbl.get_z(x, y);
490
-  #elif defined(ENABLE_AUTO_BED_LEVELING)
490
+  #elif ENABLED(ENABLE_AUTO_BED_LEVELING)
491
     apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
491
     apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
492
   #endif
492
   #endif
493
 
493
 
510
 
510
 
511
   float de = target[E_AXIS] - position[E_AXIS];
511
   float de = target[E_AXIS] - position[E_AXIS];
512
 
512
 
513
-  #ifdef PREVENT_DANGEROUS_EXTRUDE
513
+  #if ENABLED(PREVENT_DANGEROUS_EXTRUDE)
514
     if (de) {
514
     if (de) {
515
       if (degHotend(extruder) < extrude_min_temp) {
515
       if (degHotend(extruder) < extrude_min_temp) {
516
         position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
516
         position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
518
         SERIAL_ECHO_START;
518
         SERIAL_ECHO_START;
519
         SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
519
         SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
520
       }
520
       }
521
-      #ifdef PREVENT_LENGTHY_EXTRUDE
521
+      #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
522
         if (labs(de) > axis_steps_per_unit[E_AXIS] * EXTRUDE_MAXLENGTH) {
522
         if (labs(de) > axis_steps_per_unit[E_AXIS] * EXTRUDE_MAXLENGTH) {
523
           position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
523
           position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
524
           de = 0; // no difference
524
           de = 0; // no difference
536
   block->busy = false;
536
   block->busy = false;
537
 
537
 
538
   // Number of steps for each axis
538
   // Number of steps for each axis
539
-  #ifdef COREXY
539
+  #if ENABLED(COREXY)
540
     // corexy planning
540
     // corexy planning
541
     // these equations follow the form of the dA and dB equations on http://www.corexy.com/theory.html
541
     // these equations follow the form of the dA and dB equations on http://www.corexy.com/theory.html
542
     block->steps[A_AXIS] = labs(dx + dy);
542
     block->steps[A_AXIS] = labs(dx + dy);
564
   if (block->step_event_count <= dropsegments) return;
564
   if (block->step_event_count <= dropsegments) return;
565
 
565
 
566
   block->fan_speed = fanSpeed;
566
   block->fan_speed = fanSpeed;
567
-  #ifdef BARICUDA
567
+  #if ENABLED(BARICUDA)
568
     block->valve_pressure = ValvePressure;
568
     block->valve_pressure = ValvePressure;
569
     block->e_to_p_pressure = EtoPPressure;
569
     block->e_to_p_pressure = EtoPPressure;
570
   #endif
570
   #endif
571
 
571
 
572
   // Compute direction bits for this block 
572
   // Compute direction bits for this block 
573
   uint8_t db = 0;
573
   uint8_t db = 0;
574
-  #ifdef COREXY
574
+  #if ENABLED(COREXY)
575
     if (dx < 0) db |= BIT(X_HEAD); // Save the real Extruder (head) direction in X Axis
575
     if (dx < 0) db |= BIT(X_HEAD); // Save the real Extruder (head) direction in X Axis
576
     if (dy < 0) db |= BIT(Y_HEAD); // ...and Y
576
     if (dy < 0) db |= BIT(Y_HEAD); // ...and Y
577
     if (dz < 0) db |= BIT(Z_AXIS);
577
     if (dz < 0) db |= BIT(Z_AXIS);
594
   block->active_extruder = extruder;
594
   block->active_extruder = extruder;
595
 
595
 
596
   //enable active axes
596
   //enable active axes
597
-  #ifdef COREXY
597
+  #if ENABLED(COREXY)
598
     if (block->steps[A_AXIS] || block->steps[B_AXIS]) {
598
     if (block->steps[A_AXIS] || block->steps[B_AXIS]) {
599
       enable_x();
599
       enable_x();
600
       enable_y();
600
       enable_y();
693
    * So we need to create other 2 "AXIS", named X_HEAD and Y_HEAD, meaning the real displacement of the Head. 
693
    * So we need to create other 2 "AXIS", named X_HEAD and Y_HEAD, meaning the real displacement of the Head. 
694
    * Having the real displacement of the head, we can calculate the total movement length and apply the desired speed.
694
    * Having the real displacement of the head, we can calculate the total movement length and apply the desired speed.
695
    */ 
695
    */ 
696
-  #ifdef COREXY
696
+  #if ENABLED(COREXY)
697
     float delta_mm[6];
697
     float delta_mm[6];
698
     delta_mm[X_HEAD] = dx / axis_steps_per_unit[A_AXIS];
698
     delta_mm[X_HEAD] = dx / axis_steps_per_unit[A_AXIS];
699
     delta_mm[Y_HEAD] = dy / axis_steps_per_unit[B_AXIS];
699
     delta_mm[Y_HEAD] = dy / axis_steps_per_unit[B_AXIS];
720
   } 
720
   } 
721
   else {
721
   else {
722
     block->millimeters = sqrt(
722
     block->millimeters = sqrt(
723
-      #ifdef COREXY
723
+      #if ENABLED(COREXY)
724
         square(delta_mm[X_HEAD]) + square(delta_mm[Y_HEAD]) + square(delta_mm[Z_AXIS])
724
         square(delta_mm[X_HEAD]) + square(delta_mm[Y_HEAD]) + square(delta_mm[Z_AXIS])
725
-      #elif defined(COREXZ)
725
+      #elif ENABLED(COREXZ)
726
         square(delta_mm[X_HEAD]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_HEAD])
726
         square(delta_mm[X_HEAD]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_HEAD])
727
       #else
727
       #else
728
         square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS])
728
         square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS])
737
   int moves_queued = movesplanned();
737
   int moves_queued = movesplanned();
738
 
738
 
739
   // Slow down when the buffer starts to empty, rather than wait at the corner for a buffer refill
739
   // Slow down when the buffer starts to empty, rather than wait at the corner for a buffer refill
740
-  #if defined(OLD_SLOWDOWN) || defined(SLOWDOWN)
740
+  #if ENABLED(OLD_SLOWDOWN) || ENABLED(SLOWDOWN)
741
     bool mq = moves_queued > 1 && moves_queued < BLOCK_BUFFER_SIZE / 2;
741
     bool mq = moves_queued > 1 && moves_queued < BLOCK_BUFFER_SIZE / 2;
742
-    #ifdef OLD_SLOWDOWN
742
+    #if ENABLED(OLD_SLOWDOWN)
743
       if (mq) feed_rate *= 2.0 * moves_queued / BLOCK_BUFFER_SIZE;
743
       if (mq) feed_rate *= 2.0 * moves_queued / BLOCK_BUFFER_SIZE;
744
     #endif
744
     #endif
745
-    #ifdef SLOWDOWN
745
+    #if ENABLED(SLOWDOWN)
746
       //  segment time im micro seconds
746
       //  segment time im micro seconds
747
       unsigned long segment_time = lround(1000000.0/inverse_second);
747
       unsigned long segment_time = lround(1000000.0/inverse_second);
748
       if (mq) {
748
       if (mq) {
760
   block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0
760
   block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0
761
   block->nominal_rate = ceil(block->step_event_count * inverse_second); // (step/sec) Always > 0
761
   block->nominal_rate = ceil(block->step_event_count * inverse_second); // (step/sec) Always > 0
762
 
762
 
763
-  #ifdef FILAMENT_SENSOR
763
+  #if ENABLED(FILAMENT_SENSOR)
764
     //FMM update ring buffer used for delay with filament measurements
764
     //FMM update ring buffer used for delay with filament measurements
765
   
765
   
766
     if (extruder == FILAMENT_SENSOR_EXTRUDER_NUM && delay_index2 > -1) {  //only for extruder with filament sensor and if ring buffer is initialized
766
     if (extruder == FILAMENT_SENSOR_EXTRUDER_NUM && delay_index2 > -1) {  //only for extruder with filament sensor and if ring buffer is initialized
956
   for (int i = 0; i < NUM_AXIS; i++) previous_speed[i] = current_speed[i];
956
   for (int i = 0; i < NUM_AXIS; i++) previous_speed[i] = current_speed[i];
957
   previous_nominal_speed = block->nominal_speed;
957
   previous_nominal_speed = block->nominal_speed;
958
 
958
 
959
-  #ifdef ADVANCE
959
+  #if ENABLED(ADVANCE)
960
     // Calculate advance rate
960
     // Calculate advance rate
961
     if (!bse || (!bsx && !bsy && !bsz)) {
961
     if (!bse || (!bsx && !bsy && !bsz)) {
962
       block->advance_rate = 0;
962
       block->advance_rate = 0;
991
 
991
 
992
 } // plan_buffer_line()
992
 } // plan_buffer_line()
993
 
993
 
994
-#if defined(ENABLE_AUTO_BED_LEVELING) && !defined(DELTA)
994
+#if ENABLED(ENABLE_AUTO_BED_LEVELING) && DISABLED(DELTA)
995
   vector_3 plan_get_position() {
995
   vector_3 plan_get_position() {
996
     vector_3 position = vector_3(st_get_position_mm(X_AXIS), st_get_position_mm(Y_AXIS), st_get_position_mm(Z_AXIS));
996
     vector_3 position = vector_3(st_get_position_mm(X_AXIS), st_get_position_mm(Y_AXIS), st_get_position_mm(Z_AXIS));
997
 
997
 
1006
   }
1006
   }
1007
 #endif // ENABLE_AUTO_BED_LEVELING && !DELTA
1007
 #endif // ENABLE_AUTO_BED_LEVELING && !DELTA
1008
 
1008
 
1009
-#if defined(ENABLE_AUTO_BED_LEVELING) || defined(MESH_BED_LEVELING)
1009
+#if ENABLED(ENABLE_AUTO_BED_LEVELING) || ENABLED(MESH_BED_LEVELING)
1010
   void plan_set_position(float x, float y, float z, const float &e)
1010
   void plan_set_position(float x, float y, float z, const float &e)
1011
 #else
1011
 #else
1012
   void plan_set_position(const float &x, const float &y, const float &z, const float &e)
1012
   void plan_set_position(const float &x, const float &y, const float &z, const float &e)
1013
 #endif // ENABLE_AUTO_BED_LEVELING || MESH_BED_LEVELING
1013
 #endif // ENABLE_AUTO_BED_LEVELING || MESH_BED_LEVELING
1014
   {
1014
   {
1015
-    #ifdef MESH_BED_LEVELING
1015
+    #if ENABLED(MESH_BED_LEVELING)
1016
       if (mbl.active) z += mbl.get_z(x, y);
1016
       if (mbl.active) z += mbl.get_z(x, y);
1017
-    #elif defined(ENABLE_AUTO_BED_LEVELING)
1017
+    #elif ENABLED(ENABLE_AUTO_BED_LEVELING)
1018
       apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
1018
       apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
1019
     #endif
1019
     #endif
1020
 
1020
 

+ 5
- 5
Marlin/planner.h ファイルの表示

37
   long acceleration_rate;                   // The acceleration rate used for acceleration calculation
37
   long acceleration_rate;                   // The acceleration rate used for acceleration calculation
38
   unsigned char direction_bits;             // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
38
   unsigned char direction_bits;             // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
39
   unsigned char active_extruder;            // Selects the active extruder
39
   unsigned char active_extruder;            // Selects the active extruder
40
-  #ifdef ADVANCE
40
+  #if ENABLED(ADVANCE)
41
     long advance_rate;
41
     long advance_rate;
42
     volatile long initial_advance;
42
     volatile long initial_advance;
43
     volatile long final_advance;
43
     volatile long final_advance;
60
   unsigned long final_rate;                          // The minimal rate at exit
60
   unsigned long final_rate;                          // The minimal rate at exit
61
   unsigned long acceleration_st;                     // acceleration steps/sec^2
61
   unsigned long acceleration_st;                     // acceleration steps/sec^2
62
   unsigned long fan_speed;
62
   unsigned long fan_speed;
63
-  #ifdef BARICUDA
63
+  #if ENABLED(BARICUDA)
64
     unsigned long valve_pressure;
64
     unsigned long valve_pressure;
65
     unsigned long e_to_p_pressure;
65
     unsigned long e_to_p_pressure;
66
   #endif
66
   #endif
79
 extern volatile unsigned char block_buffer_tail;
79
 extern volatile unsigned char block_buffer_tail;
80
 FORCE_INLINE uint8_t movesplanned() { return BLOCK_MOD(block_buffer_head - block_buffer_tail + BLOCK_BUFFER_SIZE); }
80
 FORCE_INLINE uint8_t movesplanned() { return BLOCK_MOD(block_buffer_head - block_buffer_tail + BLOCK_BUFFER_SIZE); }
81
 
81
 
82
-#if defined(ENABLE_AUTO_BED_LEVELING) || defined(MESH_BED_LEVELING)
82
+#if ENABLED(ENABLE_AUTO_BED_LEVELING) || ENABLED(MESH_BED_LEVELING)
83
 
83
 
84
-  #if defined(ENABLE_AUTO_BED_LEVELING)
84
+  #if ENABLED(ENABLE_AUTO_BED_LEVELING)
85
     #include "vector_3.h"
85
     #include "vector_3.h"
86
 
86
 
87
     // Transform required to compensate for bed level
87
     // Transform required to compensate for bed level
133
 extern float mintravelfeedrate;
133
 extern float mintravelfeedrate;
134
 extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];
134
 extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];
135
 
135
 
136
-#ifdef AUTOTEMP
136
+#if ENABLED(AUTOTEMP)
137
   extern bool autotemp_enabled;
137
   extern bool autotemp_enabled;
138
   extern float autotemp_max;
138
   extern float autotemp_max;
139
   extern float autotemp_min;
139
   extern float autotemp_min;

読み込み中…
キャンセル
保存