From caa50934984692e7b0de8aeb05438be9a19ce660 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 21 Dec 2017 22:41:57 -0600 Subject: [PATCH] General DELTA_IK macro --- Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp | 2 +- Marlin/src/module/delta.cpp | 2 +- Marlin/src/module/delta.h | 18 +++++++++--------- Marlin/src/module/motion.cpp | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp index 4bc106976d..fefff867f8 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp @@ -427,7 +427,7 @@ #if ENABLED(DELTA) // apply delta inverse_kinematics - DELTA_RAW_IK(); + DELTA_IK(raw); planner.buffer_segment(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], in_raw[E_AXIS], fr, active_extruder); #elif IS_SCARA // apply scara inverse_kinematics (should be changed to save raw->logical->raw) diff --git a/Marlin/src/module/delta.cpp b/Marlin/src/module/delta.cpp index eae9c557aa..e25c29ef18 100644 --- a/Marlin/src/module/delta.cpp +++ b/Marlin/src/module/delta.cpp @@ -121,7 +121,7 @@ void recalc_delta_settings() { }while(0) void inverse_kinematics(const float raw[XYZ]) { - DELTA_RAW_IK(); + DELTA_IK(raw); // DELTA_DEBUG(); } diff --git a/Marlin/src/module/delta.h b/Marlin/src/module/delta.h index fc98f9e6ba..59c01981fc 100644 --- a/Marlin/src/module/delta.h +++ b/Marlin/src/module/delta.h @@ -76,17 +76,17 @@ void recalc_delta_settings(); #endif // Macro to obtain the Z position of an individual tower -#define DELTA_Z(T) raw[Z_AXIS] + _SQRT( \ - delta_diagonal_rod_2_tower[T] - HYPOT2( \ - delta_tower[T][X_AXIS] - raw[X_AXIS], \ - delta_tower[T][Y_AXIS] - raw[Y_AXIS] \ - ) \ +#define DELTA_Z(V,T) V[Z_AXIS] + _SQRT( \ + delta_diagonal_rod_2_tower[T] - HYPOT2( \ + delta_tower[T][X_AXIS] - V[X_AXIS], \ + delta_tower[T][Y_AXIS] - V[Y_AXIS] \ + ) \ ) -#define DELTA_RAW_IK() do { \ - delta[A_AXIS] = DELTA_Z(A_AXIS); \ - delta[B_AXIS] = DELTA_Z(B_AXIS); \ - delta[C_AXIS] = DELTA_Z(C_AXIS); \ +#define DELTA_IK(V) do { \ + delta[A_AXIS] = DELTA_Z(V, A_AXIS); \ + delta[B_AXIS] = DELTA_Z(V, B_AXIS); \ + delta[C_AXIS] = DELTA_Z(V, C_AXIS); \ }while(0) void inverse_kinematics(const float raw[XYZ]); diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 11803c184b..b13438dab5 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -613,7 +613,7 @@ float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS }, LOOP_XYZE(i) raw[i] += segment_distance[i]; #if ENABLED(DELTA) - DELTA_RAW_IK(); // Delta can inline its kinematics + DELTA_IK(raw); // Delta can inline its kinematics #else inverse_kinematics(raw); #endif