Quellcode durchsuchen

UBL_DELTA post merge cleanup (#6705)

* UBL_DELTA post merge cleanup:
   fix fade_height, lost during some previous merge
   fix float cx,cy which are not const
   move repeated z_cxcy calc line inside loop
   style fixes and comment fixes/alignment

* Update ubl_motion.cpp

remove unnecessary parentheses

* Update Conditionals_post.h

Change name of define to more accurate meaning:
UBL_GRANULAR_SEGMENTATION_FOR_CARTESIAN
which is not and should not be the default for cartesians with UBL.
oldmcg vor 7 Jahren
Ursprung
Commit
b213a45efb
2 geänderte Dateien mit 26 neuen und 16 gelöschten Zeilen
  1. 1
    1
      Marlin/Conditionals_post.h
  2. 25
    15
      Marlin/ubl_motion.cpp

+ 1
- 1
Marlin/Conditionals_post.h Datei anzeigen

@@ -731,7 +731,7 @@
731 731
    * Set granular options based on the specific type of leveling
732 732
    */
733 733
 
734
-  #define UBL_DELTA  (ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(DELTA))
734
+  #define UBL_DELTA  (ENABLED(AUTO_BED_LEVELING_UBL) && (ENABLED(DELTA) || ENABLED(UBL_GRANULAR_SEGMENTATION_FOR_CARTESIAN)))
735 735
   #define ABL_PLANAR (ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_3POINT))
736 736
   #define ABL_GRID   (ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR))
737 737
   #define HAS_ABL    (ABL_PLANAR || ABL_GRID || ENABLED(AUTO_BED_LEVELING_UBL))

+ 25
- 15
Marlin/ubl_motion.cpp Datei anzeigen

@@ -506,13 +506,13 @@
506 506
                     ltarget[E_AXIS] - current_position[E_AXIS]
507 507
                   };
508 508
 
509
-      const float cartesian_xy_mm = HYPOT(difference[X_AXIS], difference[Y_AXIS]);        // total horizontal xy distance
509
+      const float cartesian_xy_mm = HYPOT(difference[X_AXIS], difference[Y_AXIS]);         // total horizontal xy distance
510 510
 
511 511
       #if IS_KINEMATIC
512
-        const float seconds = cartesian_xy_mm / feedrate;                                 // seconds to move xy distance at requested rate
513
-        uint16_t segments = lroundf(delta_segments_per_second * seconds),                // preferred number of segments for distance @ feedrate
512
+        const float seconds = cartesian_xy_mm / feedrate;                                  // seconds to move xy distance at requested rate
513
+        uint16_t segments = lroundf(delta_segments_per_second * seconds),                  // preferred number of segments for distance @ feedrate
514 514
                  seglimit = lroundf(cartesian_xy_mm * (1.0 / (DELTA_SEGMENT_MIN_LENGTH))); // number of segments at minimum segment length
515
-        NOMORE(segments, seglimit);                                                     // limit to minimum segment length (fewer segments)
515
+        NOMORE(segments, seglimit);                                                        // limit to minimum segment length (fewer segments)
516 516
       #else
517 517
         uint16_t segments = lroundf(cartesian_xy_mm * (1.0 / (DELTA_SEGMENT_MIN_LENGTH))); // cartesian fixed segment length
518 518
       #endif
@@ -570,6 +570,10 @@
570 570
 
571 571
       // Otherwise perform per-segment leveling
572 572
 
573
+      #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
574
+        const float fade_scaling_factor = ubl.fade_scaling_factor_for_z(ltarget[Z_AXIS]);
575
+      #endif
576
+
573 577
       float seg_dest[XYZE];  // per-segment destination, initialize to first segment
574 578
       LOOP_XYZE(i) seg_dest[i] = current_position[i] + segment_distance[i];
575 579
 
@@ -614,13 +618,14 @@
614 618
         const float z_xmy0 = (z_x1y0 - z_x0y0) * (1.0 / (MESH_X_DIST)),   // z slope per x along y0 (lower left to lower right)
615 619
                     z_xmy1 = (z_x1y1 - z_x0y1) * (1.0 / (MESH_X_DIST));   // z slope per x along y1 (upper left to upper right)
616 620
 
617
-              float z_cxy0 = z_x0y0 + z_xmy0 * cx;          // z height along y0 at cx
621
+              float z_cxy0 = z_x0y0 + z_xmy0 * cx;            // z height along y0 at cx
618 622
 
619
-        const float z_cxy1 = z_x0y1 + z_xmy1 * cx,          // z height along y1 at cx
620
-                    z_cxyd = z_cxy1 - z_cxy0;               // z height difference along cx from y0 to y1
623
+        const float z_cxy1 = z_x0y1 + z_xmy1 * cx,            // z height along y1 at cx
624
+                    z_cxyd = z_cxy1 - z_cxy0;                 // z height difference along cx from y0 to y1
621 625
 
622
-              float z_cxym = z_cxyd * (1.0 / (MESH_Y_DIST)),  // z slope per y along cx from y0 to y1
623
-                    z_cxcy = z_cxy0 + z_cxym * cy;          // z height along cx at cy
626
+              float z_cxym = z_cxyd * (1.0 / (MESH_Y_DIST));  // z slope per y along cx from y0 to y1
627
+        
628
+        //    float z_cxcy = z_cxy0 + z_cxym * cy;            // interpolated mesh z height along cx at cy (do inside the segment loop)
624 629
 
625 630
         // As subsequent segments step through this cell, the z_cxy0 intercept will change
626 631
         // and the z_cxym slope will change, both as a function of cx within the cell, and
@@ -631,9 +636,15 @@
631 636
 
632 637
         do {  // for all segments within this mesh cell
633 638
 
634
-          z_cxcy += ubl.state.z_offset;
639
+          float z_cxcy = z_cxy0 + z_cxym * cy;      // interpolated mesh z height along cx at cy
640
+
641
+          #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
642
+            z_cxcy *= fade_scaling_factor;          // apply fade factor to interpolated mesh height
643
+          #endif
644
+        
645
+          z_cxcy += ubl.state.z_offset;             // add fixed mesh offset from G29 Z
635 646
 
636
-          if (--segments == 0) {          // this is last segment, use ltarget for exact
647
+          if (--segments == 0) {                    // if this is last segment, use ltarget for exact
637 648
             COPY(seg_dest, ltarget);
638 649
             seg_dest[Z_AXIS] += z_cxcy;
639 650
             ubl_buffer_line_segment(seg_dest, feedrate, active_extruder);
@@ -657,11 +668,10 @@
657 668
           }
658 669
 
659 670
           // Next segment still within same mesh cell, adjust the per-segment
660
-          // slope and intercept and compute next z height.
671
+          // slope and intercept to compute next z height.
661 672
 
662
-          z_cxy0 += z_sxy0;                 // adjust z_cxy0 by per-segment z_sxy0
663
-          z_cxym += z_sxym;                 // adjust z_cxym by per-segment z_sxym
664
-          z_cxcy  = z_cxy0 + z_cxym * cy;   // recompute z_cxcy from adjusted slope and intercept
673
+          z_cxy0 += z_sxy0;   // adjust z_cxy0 by per-segment z_sxy0
674
+          z_cxym += z_sxym;   // adjust z_cxym by per-segment z_sxym
665 675
 
666 676
         } while (true);   // per-segment loop exits by break after last segment within cell, or by return on final segment
667 677
       } while (true);   // per-cell loop

Laden…
Abbrechen
Speichern