From 22ece0081e0ab4497adf1089d165ebc3b9b3cacc Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 23 Sep 2016 03:01:27 -0500 Subject: [PATCH] Pass array pointer to unapply_leveling --- Marlin/Marlin_main.cpp | 6 +++--- Marlin/planner.cpp | 19 +++++++++---------- Marlin/planner.h | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 7cd480115..c4d22431a 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -3150,7 +3150,7 @@ inline void gcode_G28() { if (DEBUGGING(LEVELING)) DEBUG_POS("MBL Rest Origin", current_position); #endif #else - planner.unapply_leveling(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS]); + planner.unapply_leveling(current_position); #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("MBL adjusted MESH_HOME_SEARCH_Z", current_position); #endif @@ -3160,7 +3160,7 @@ inline void gcode_G28() { current_position[Z_AXIS] = pre_home_z; SYNC_PLAN_POSITION_KINEMATIC(); mbl.set_active(true); - planner.unapply_leveling(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS]); + planner.unapply_leveling(current_position); #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("MBL Home X or Y", current_position); #endif @@ -8053,7 +8053,7 @@ void get_cartesian_from_steppers() { void set_current_from_steppers_for_axis(const AxisEnum axis) { get_cartesian_from_steppers(); #if PLANNER_LEVELING - planner.unapply_leveling(cartes[X_AXIS], cartes[Y_AXIS], cartes[Z_AXIS]); + planner.unapply_leveling(cartes); #endif if (axis == ALL_AXES) memcpy(current_position, cartes, sizeof(cartes)); diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index 3964a7f51..45cd467f0 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -570,7 +570,7 @@ void Planner::check_axes_activity() { #endif } - void Planner::unapply_leveling(float &lx, float &ly, float &lz) { + void Planner::unapply_leveling(float logical[XYZ]) { #if ENABLED(AUTO_BED_LEVELING_FEATURE) if (!abl_enabled) return; @@ -579,26 +579,25 @@ void Planner::check_axes_activity() { #if ENABLED(MESH_BED_LEVELING) if (mbl.active()) - lz -= mbl.get_z(RAW_X_POSITION(lx), RAW_Y_POSITION(ly)); + logical[Z_AXIS] -= mbl.get_z(RAW_X_POSITION(logical[X_AXIS]), RAW_Y_POSITION(logical[Y_AXIS])); #elif ENABLED(AUTO_BED_LEVELING_LINEAR) matrix_3x3 inverse = matrix_3x3::transpose(bed_level_matrix); - float dx = RAW_X_POSITION(lx) - (X_TILT_FULCRUM), - dy = RAW_Y_POSITION(ly) - (Y_TILT_FULCRUM), - dz = RAW_Z_POSITION(lz); + float dx = RAW_X_POSITION(logical[X_AXIS]) - (X_TILT_FULCRUM), + dy = RAW_Y_POSITION(logical[Y_AXIS]) - (Y_TILT_FULCRUM), + dz = RAW_Z_POSITION(logical[Z_AXIS]); apply_rotation_xyz(inverse, dx, dy, dz); - lx = LOGICAL_X_POSITION(dx + X_TILT_FULCRUM); - ly = LOGICAL_Y_POSITION(dy + Y_TILT_FULCRUM); - lz = LOGICAL_Z_POSITION(dz); + logical[X_AXIS] = LOGICAL_X_POSITION(dx + X_TILT_FULCRUM); + logical[Y_AXIS] = LOGICAL_Y_POSITION(dy + Y_TILT_FULCRUM); + logical[Z_AXIS] = LOGICAL_Z_POSITION(dz); #elif ENABLED(AUTO_BED_LEVELING_NONLINEAR) - float tmp[XYZ] = { lx, ly, 0 }; - lz -= nonlinear_z_offset(tmp); + logical[Z_AXIS] -= nonlinear_z_offset(logical); #endif } diff --git a/Marlin/planner.h b/Marlin/planner.h index 1d82ee57d..27505e938 100644 --- a/Marlin/planner.h +++ b/Marlin/planner.h @@ -219,7 +219,7 @@ class Planner { * as it will be given to the planner and steppers. */ static void apply_leveling(float &lx, float &ly, float &lz); - static void unapply_leveling(float &lx, float &ly, float &lz); + static void unapply_leveling(float logical[XYZ]); #endif