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.
This commit is contained in:
oldmcg 2017-05-16 00:30:29 -05:00 committed by Scott Lahteine
parent 6f86c46fa6
commit b213a45efb
2 changed files with 26 additions and 16 deletions

View File

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

View File

@ -570,6 +570,10 @@
// Otherwise perform per-segment leveling // Otherwise perform per-segment leveling
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
const float fade_scaling_factor = ubl.fade_scaling_factor_for_z(ltarget[Z_AXIS]);
#endif
float seg_dest[XYZE]; // per-segment destination, initialize to first segment float seg_dest[XYZE]; // per-segment destination, initialize to first segment
LOOP_XYZE(i) seg_dest[i] = current_position[i] + segment_distance[i]; LOOP_XYZE(i) seg_dest[i] = current_position[i] + segment_distance[i];
@ -619,8 +623,9 @@
const float z_cxy1 = z_x0y1 + z_xmy1 * cx, // z height along y1 at cx const float z_cxy1 = z_x0y1 + z_xmy1 * cx, // z height along y1 at cx
z_cxyd = z_cxy1 - z_cxy0; // z height difference along cx from y0 to y1 z_cxyd = z_cxy1 - z_cxy0; // z height difference along cx from y0 to y1
float z_cxym = z_cxyd * (1.0 / (MESH_Y_DIST)), // z slope per y along cx from y0 to y1 float z_cxym = z_cxyd * (1.0 / (MESH_Y_DIST)); // z slope per y along cx from y0 to y1
z_cxcy = z_cxy0 + z_cxym * cy; // z height along cx at cy
// float z_cxcy = z_cxy0 + z_cxym * cy; // interpolated mesh z height along cx at cy (do inside the segment loop)
// As subsequent segments step through this cell, the z_cxy0 intercept will change // As subsequent segments step through this cell, the z_cxy0 intercept will change
// and the z_cxym slope will change, both as a function of cx within the cell, and // and the z_cxym slope will change, both as a function of cx within the cell, and
@ -631,9 +636,15 @@
do { // for all segments within this mesh cell do { // for all segments within this mesh cell
z_cxcy += ubl.state.z_offset; float z_cxcy = z_cxy0 + z_cxym * cy; // interpolated mesh z height along cx at cy
if (--segments == 0) { // this is last segment, use ltarget for exact #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
z_cxcy *= fade_scaling_factor; // apply fade factor to interpolated mesh height
#endif
z_cxcy += ubl.state.z_offset; // add fixed mesh offset from G29 Z
if (--segments == 0) { // if this is last segment, use ltarget for exact
COPY(seg_dest, ltarget); COPY(seg_dest, ltarget);
seg_dest[Z_AXIS] += z_cxcy; seg_dest[Z_AXIS] += z_cxcy;
ubl_buffer_line_segment(seg_dest, feedrate, active_extruder); ubl_buffer_line_segment(seg_dest, feedrate, active_extruder);
@ -657,11 +668,10 @@
} }
// Next segment still within same mesh cell, adjust the per-segment // Next segment still within same mesh cell, adjust the per-segment
// slope and intercept and compute next z height. // slope and intercept to compute next z height.
z_cxy0 += z_sxy0; // adjust z_cxy0 by per-segment z_sxy0 z_cxy0 += z_sxy0; // adjust z_cxy0 by per-segment z_sxy0
z_cxym += z_sxym; // adjust z_cxym by per-segment z_sxym z_cxym += z_sxym; // adjust z_cxym by per-segment z_sxym
z_cxcy = z_cxy0 + z_cxym * cy; // recompute z_cxcy from adjusted slope and intercept
} while (true); // per-segment loop exits by break after last segment within cell, or by return on final segment } while (true); // per-segment loop exits by break after last segment within cell, or by return on final segment
} while (true); // per-cell loop } while (true); // per-cell loop