ソースを参照

Planner class parity with 1.1.x

Scott Lahteine 7年前
コミット
a52fec6ac4
2個のファイルの変更39行の追加35行の削除
  1. 32
    28
      Marlin/src/module/planner.cpp
  2. 7
    7
      Marlin/src/module/planner.h

+ 32
- 28
Marlin/src/module/planner.cpp ファイルの表示

@@ -105,11 +105,10 @@ float Planner::max_feedrate_mm_s[XYZE_N], // Max speeds in mm per second
105 105
 
106 106
 int16_t Planner::flow_percentage[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(100); // Extrusion factor for each extruder
107 107
 
108
-// Initialized by settings.load()
109
-float Planner::e_factor[EXTRUDERS],              // The flow percentage and volumetric multiplier combine to scale E movement
110
-      Planner::filament_size[EXTRUDERS],         // As a baseline for the multiplier, filament diameter
108
+float Planner::e_factor[EXTRUDERS],               // The flow percentage and volumetric multiplier combine to scale E movement
109
+      Planner::filament_size[EXTRUDERS],          // diameter of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder
111 110
       Planner::volumetric_area_nominal = CIRCLE_AREA((DEFAULT_NOMINAL_FILAMENT_DIA) * 0.5), // Nominal cross-sectional area
112
-      Planner::volumetric_multiplier[EXTRUDERS]; // May be auto-adjusted by a filament width sensor
111
+      Planner::volumetric_multiplier[EXTRUDERS];  // Reciprocal of cross-sectional area of filament (in mm^2). Pre-calculated to reduce computation in the planner
113 112
 
114 113
 uint32_t Planner::max_acceleration_steps_per_s2[XYZE_N],
115 114
          Planner::max_acceleration_mm_per_s2[XYZE_N]; // Use M201 to override by software
@@ -129,12 +128,11 @@ float Planner::min_feedrate_mm_s,
129 128
   #if ABL_PLANAR
130 129
     matrix_3x3 Planner::bed_level_matrix; // Transform to compensate for bed level
131 130
   #endif
132
-#endif
133
-
134
-#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
135
-  float Planner::z_fade_height, // Initialized by settings.load()
136
-        Planner::inverse_z_fade_height,
137
-        Planner::last_fade_z;
131
+  #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
132
+    float Planner::z_fade_height,      // Initialized by settings.load()
133
+          Planner::inverse_z_fade_height,
134
+          Planner::last_fade_z;
135
+  #endif
138 136
 #endif
139 137
 
140 138
 #if ENABLED(AUTOTEMP)
@@ -571,7 +569,7 @@ void Planner::calculate_volumetric_multipliers() {
571 569
    */
572 570
   void Planner::apply_leveling(float &rx, float &ry, float &rz) {
573 571
 
574
-    if (!planner.leveling_active) return;
572
+    if (!leveling_active) return;
575 573
 
576 574
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
577 575
       const float fade_scaling_factor = fade_scaling_factor_for_z(rz);
@@ -614,20 +612,22 @@ void Planner::calculate_volumetric_multipliers() {
614 612
 
615 613
   void Planner::unapply_leveling(float raw[XYZ]) {
616 614
 
617
-    if (!planner.leveling_active) return;
615
+    if (!leveling_active) return;
618 616
 
619 617
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
620
-      if (z_fade_height && raw[Z_AXIS] >= z_fade_height) return;
618
+      if (!leveling_active_at_z(raw[Z_AXIS])) return;
621 619
     #endif
622 620
 
623 621
     #if ENABLED(AUTO_BED_LEVELING_UBL)
624 622
 
625
-      const float z_correct = ubl.get_z_correction(raw[X_AXIS], raw[Y_AXIS]);
626
-            float z_raw = raw[Z_AXIS] - z_correct;
623
+      const float z_physical = raw[Z_AXIS],
624
+                  z_correct = ubl.get_z_correction(raw[X_AXIS], raw[Y_AXIS]),
625
+                  z_virtual = z_physical - z_correct;
626
+            float z_raw = z_virtual;
627 627
 
628 628
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
629 629
 
630
-        // for P=physical_z, L=raw_z, M=mesh_z, H=fade_height,
630
+        // for P=physical_z, L=logical_z, M=mesh_z, H=fade_height,
631 631
         // Given P=L+M(1-L/H) (faded mesh correction formula for L<H)
632 632
         //  then L=P-M(1-L/H)
633 633
         //    so L=P-M+ML/H
@@ -637,7 +637,7 @@ void Planner::calculate_volumetric_multipliers() {
637 637
 
638 638
         if (planner.z_fade_height) {
639 639
           if (z_raw >= planner.z_fade_height)
640
-            z_raw = raw[Z_AXIS];
640
+            z_raw = z_physical;
641 641
           else
642 642
             z_raw /= 1.0 - z_correct * planner.inverse_z_fade_height;
643 643
         }
@@ -646,28 +646,32 @@ void Planner::calculate_volumetric_multipliers() {
646 646
 
647 647
       raw[Z_AXIS] = z_raw;
648 648
 
649
-    #elif ENABLED(MESH_BED_LEVELING)
649
+      return; // don't fall thru to other ENABLE_LEVELING_FADE_HEIGHT logic
650 650
 
651
-      #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
652
-        const float c = mbl.get_z(raw[X_AXIS], raw[Y_AXIS], 1.0);
653
-        raw[Z_AXIS] = (z_fade_height * (raw[Z_AXIS] - c)) / (z_fade_height - c);
654
-      #else
655
-        raw[Z_AXIS] -= mbl.get_z(raw[X_AXIS], raw[Y_AXIS]);
656
-      #endif
651
+    #endif
652
+
653
+    #if ENABLED(MESH_BED_LEVELING)
654
+
655
+      if (leveling_active) {
656
+        #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
657
+          const float c = mbl.get_z(raw[X_AXIS], raw[Y_AXIS], 1.0);
658
+          raw[Z_AXIS] = (z_fade_height * (raw[Z_AXIS]) - c) / (z_fade_height - c);
659
+        #else
660
+          raw[Z_AXIS] -= mbl.get_z(raw[X_AXIS], raw[Y_AXIS]);
661
+        #endif
662
+      }
657 663
 
658 664
     #elif ABL_PLANAR
659 665
 
660 666
       matrix_3x3 inverse = matrix_3x3::transpose(bed_level_matrix);
661 667
 
662 668
       float dx = raw[X_AXIS] - (X_TILT_FULCRUM),
663
-            dy = raw[Y_AXIS] - (Y_TILT_FULCRUM),
664
-            dz = raw[Z_AXIS];
669
+            dy = raw[Y_AXIS] - (Y_TILT_FULCRUM);
665 670
 
666
-      apply_rotation_xyz(inverse, dx, dy, dz);
671
+      apply_rotation_xyz(inverse, dx, dy, raw[Z_AXIS]);
667 672
 
668 673
       raw[X_AXIS] = dx + X_TILT_FULCRUM;
669 674
       raw[Y_AXIS] = dy + Y_TILT_FULCRUM;
670
-      raw[Z_AXIS] = dz;
671 675
 
672 676
     #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
673 677
 

+ 7
- 7
Marlin/src/module/planner.h ファイルの表示

@@ -144,7 +144,7 @@ class Planner {
144 144
       static uint8_t last_extruder;             // Respond to extruder change
145 145
     #endif
146 146
 
147
-    static int16_t flow_percentage[EXTRUDERS];  // Extrusion factor for each extruder
147
+    static int16_t flow_percentage[EXTRUDERS]; // Extrusion factor for each extruder
148 148
 
149 149
     static float e_factor[EXTRUDERS],               // The flow percentage and volumetric multiplier combine to scale E movement
150 150
                  filament_size[EXTRUDERS],          // diameter of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder
@@ -167,7 +167,7 @@ class Planner {
167 167
                  min_travel_feedrate_mm_s;
168 168
 
169 169
     #if HAS_LEVELING
170
-      static bool leveling_active;              // Flag that bed leveling is enabled
170
+      static bool leveling_active;          // Flag that bed leveling is enabled
171 171
       #if ABL_PLANAR
172 172
         static matrix_3x3 bed_level_matrix; // Transform to compensate for bed level
173 173
       #endif
@@ -342,12 +342,12 @@ class Planner {
342 342
     /**
343 343
      * Planner::_buffer_line
344 344
      *
345
-     * Add a new direct linear movement to the buffer.
345
+     * Add a new linear movement to the buffer in axis units.
346 346
      *
347
-     * Leveling and kinematics should be applied ahead of this.
347
+     * Leveling and kinematics should be applied ahead of calling this.
348 348
      *
349
-     *  a,b,c,e   - target position in mm or degrees
350
-     *  fr_mm_s   - (target) speed of the move (mm/s)
349
+     *  a,b,c,e   - target positions in mm and/or degrees
350
+     *  fr_mm_s   - (target) speed of the move
351 351
      *  extruder  - target extruder
352 352
      */
353 353
     static void _buffer_line(const float &a, const float &b, const float &c, const float &e, float fr_mm_s, const uint8_t extruder);
@@ -444,7 +444,7 @@ class Planner {
444 444
       if (blocks_queued()) {
445 445
         block_t* block = &block_buffer[block_buffer_tail];
446 446
         #if ENABLED(ULTRA_LCD)
447
-          block_buffer_runtime_us -= block->segment_time_us; //We can't be sure how long an active block will take, so don't count it.
447
+          block_buffer_runtime_us -= block->segment_time_us; // We can't be sure how long an active block will take, so don't count it.
448 448
         #endif
449 449
         SBI(block->flag, BLOCK_BIT_BUSY);
450 450
         return block;

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