From 5a9e52a3e08738ccb45cecb40991225526a424be Mon Sep 17 00:00:00 2001 From: oldmcg Date: Tue, 16 May 2017 11:47:51 -0500 Subject: [PATCH] Use COPY_XYZE macro to copy exactly 4 elements (#6758) Fix undefined DELTA_PROBEABLE_RADIUS for UBL_DELTA --- Marlin/Conditionals_post.h | 7 +++++-- Marlin/ubl_motion.cpp | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Marlin/Conditionals_post.h b/Marlin/Conditionals_post.h index 258736eab..1a99ee2fb 100644 --- a/Marlin/Conditionals_post.h +++ b/Marlin/Conditionals_post.h @@ -818,7 +818,7 @@ #endif /** - * DELTA_SEGMENT_MIN_LENGTH for UBL_DELTA + * DELTA_SEGMENT_MIN_LENGTH and DELTA_PROBEABLE_RADIUS for UBL_DELTA */ #if UBL_DELTA #ifndef DELTA_SEGMENT_MIN_LENGTH @@ -830,8 +830,11 @@ #define DELTA_SEGMENT_MIN_LENGTH 1.00 // mm (similar to G2/G3 arc segmentation) #endif #endif + #ifndef DELTA_PROBEABLE_RADIUS + #define DELTA_PROBEABLE_RADIUS DELTA_PRINTABLE_RADIUS + #endif #endif - + // Shorthand #define GRID_MAX_POINTS ((GRID_MAX_POINTS_X) * (GRID_MAX_POINTS_Y)) diff --git a/Marlin/ubl_motion.cpp b/Marlin/ubl_motion.cpp index 32a17b37b..b31516086 100644 --- a/Marlin/ubl_motion.cpp +++ b/Marlin/ubl_motion.cpp @@ -457,6 +457,14 @@ #if UBL_DELTA + // macro to inline copy exactly 4 floats, don't rely on sizeof operator + #define COPY_XYZE( target, source ) { \ + target[X_AXIS] = source[X_AXIS]; \ + target[Y_AXIS] = source[Y_AXIS]; \ + target[Z_AXIS] = source[Z_AXIS]; \ + target[E_AXIS] = source[E_AXIS]; \ + } + #if IS_SCARA // scale the feed rate from mm/s to degrees/s static float scara_feed_factor, scara_oldA, scara_oldB; #endif @@ -550,8 +558,8 @@ const float z_offset = ubl.state.active ? ubl.state.z_offset : 0.0; - float seg_dest[XYZE]; // per-segment destination, - COPY(seg_dest, current_position); // starting from current position + float seg_dest[XYZE]; // per-segment destination, + COPY_XYZE(seg_dest, current_position); // starting from current position while (--segments) { LOOP_XYZE(i) seg_dest[i] += segment_distance[i]; @@ -562,7 +570,7 @@ } // Since repeated adding segment_distance accumulates small errors, final move to exact destination. - COPY(seg_dest, ltarget); + COPY_XYZE(seg_dest, ltarget); seg_dest[Z_AXIS] += z_offset; ubl_buffer_line_segment(seg_dest, feedrate, active_extruder); return false; // moved but did not set_current_to_destination(); @@ -645,7 +653,7 @@ 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_XYZE(seg_dest, ltarget); seg_dest[Z_AXIS] += z_cxcy; ubl_buffer_line_segment(seg_dest, feedrate, active_extruder); return false; // did not set_current_to_destination()