From 9644d56b42de1d45b292f67cda950387fd76aa06 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 24 May 2018 00:04:47 -0500 Subject: [PATCH] Patches for core motion tests --- Marlin/src/core/enum.h | 7 +++---- Marlin/src/core/macros.h | 2 +- Marlin/src/module/endstops.cpp | 12 ++++++------ Marlin/src/module/stepper.cpp | 20 ++++++++++---------- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/Marlin/src/core/enum.h b/Marlin/src/core/enum.h index 8101b9aeab..b9581bec89 100644 --- a/Marlin/src/core/enum.h +++ b/Marlin/src/core/enum.h @@ -26,10 +26,9 @@ /** * Axis indices as enumerated constants * - * Special axis: - * - A_AXIS and B_AXIS are used by COREXY printers - * - X_HEAD and Y_HEAD is used for systems that don't have a 1:1 relationship - * between X_AXIS and X Head movement, like CoreXY bots + * - X_AXIS, Y_AXIS, and Z_AXIS should be used for axes in Cartesian space + * - A_AXIS, B_AXIS, and C_AXIS should be used for Steppers, corresponding to XYZ on Cartesians + * - X_HEAD, Y_HEAD, and Z_HEAD should be used for Steppers on Core kinematics */ enum AxisEnum : unsigned char { X_AXIS = 0, diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index 4f4b7dd62a..ce464eb4b7 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -71,7 +71,7 @@ #define TEST(n,b) !!((n)&_BV(b)) #define SBI(n,b) (n |= _BV(b)) #define CBI(n,b) (n &= ~_BV(b)) -#define SET_BIT(N,B,TF) do{ if (TF) SBI(N,B); else CBI(N,B); }while(0) +#define SET_BIT_TO(N,B,TF) do{ if (TF) SBI(N,B); else CBI(N,B); }while(0) #define _BV32(b) (1UL << (b)) #define TEST32(n,b) !!((n)&_BV32(b)) diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 8c51662922..319562a6a6 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -405,11 +405,11 @@ void Endstops::M119() { // Check endstops - Could be called from ISR! void Endstops::update() { - #define SET_BIT(N,B,TF) do{ if (TF) SBI(N,B); else CBI(N,B); }while(0) + #define SET_BIT_TO(N,B,TF) do{ if (TF) SBI(N,B); else CBI(N,B); }while(0) // UPDATE_ENDSTOP_BIT: set the current endstop bits for an endstop to its status - #define UPDATE_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT(live_state, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX))) + #define UPDATE_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT_TO(live_state, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX))) // COPY_BIT: copy the value of SRC_BIT to DST_BIT in DST - #define COPY_BIT(DST, SRC_BIT, DST_BIT) SET_BIT(DST, DST_BIT, TEST(DST, SRC_BIT)) + #define COPY_BIT(DST, SRC_BIT, DST_BIT) SET_BIT_TO(DST, DST_BIT, TEST(DST, SRC_BIT)) #if ENABLED(G38_PROBE_TARGET) && PIN_EXISTS(Z_MIN_PROBE) && !(CORE_IS_XY || CORE_IS_XZ) // If G38 command is active check Z_MIN_PROBE for ALL movement @@ -605,9 +605,9 @@ void Endstops::update() { // If G38 command is active check Z_MIN_PROBE for ALL movement if (G38_move) { if (TEST_ENDSTOP(_ENDSTOP(Z, MIN_PROBE))) { - if (stepper.axis_is_moving(_AXIS(X))) { _ENDSTOP_HIT(X, MIN); planner.endstop_triggered(_AXIS(X)); } - else if (stepper.axis_is_moving(_AXIS(Y))) { _ENDSTOP_HIT(Y, MIN); planner.endstop_triggered(_AXIS(Y)); } - else if (stepper.axis_is_moving(_AXIS(Z))) { _ENDSTOP_HIT(Z, MIN); planner.endstop_triggered(_AXIS(Z)); } + if (stepper.axis_is_moving(X_AXIS)) { _ENDSTOP_HIT(X, MIN); planner.endstop_triggered(X_AXIS); } + else if (stepper.axis_is_moving(Y_AXIS)) { _ENDSTOP_HIT(Y, MIN); planner.endstop_triggered(Y_AXIS); } + else if (stepper.axis_is_moving(Z_AXIS)) { _ENDSTOP_HIT(Z, MIN); planner.endstop_triggered(Z_AXIS); } G38_endstop_hit = true; } } diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 64f38bd69a..62f91d5ecf 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -1589,7 +1589,7 @@ uint32_t Stepper::stepper_block_phase_isr() { #endif #define X_MOVE_TEST ( S_(1) != S_(2) || (S_(1) > 0 && D_(1) X_CMP D_(2)) ) #else - #define X_MOVE_TEST !!current_block->steps[X_AXIS] + #define X_MOVE_TEST !!current_block->steps[A_AXIS] #endif #if CORE_IS_XY || CORE_IS_YZ @@ -1607,7 +1607,7 @@ uint32_t Stepper::stepper_block_phase_isr() { #endif #define Y_MOVE_TEST ( S_(1) != S_(2) || (S_(1) > 0 && D_(1) Y_CMP D_(2)) ) #else - #define Y_MOVE_TEST !!current_block->steps[Y_AXIS] + #define Y_MOVE_TEST !!current_block->steps[B_AXIS] #endif #if CORE_IS_XZ || CORE_IS_YZ @@ -1625,16 +1625,16 @@ uint32_t Stepper::stepper_block_phase_isr() { #endif #define Z_MOVE_TEST ( S_(1) != S_(2) || (S_(1) > 0 && D_(1) Z_CMP D_(2)) ) #else - #define Z_MOVE_TEST !!current_block->steps[Z_AXIS] + #define Z_MOVE_TEST !!current_block->steps[C_AXIS] #endif - SET_BIT(axis_did_move, X_AXIS, X_MOVE_TEST); - SET_BIT(axis_did_move, Y_AXIS, Y_MOVE_TEST); - SET_BIT(axis_did_move, Z_AXIS, Z_MOVE_TEST); - SET_BIT(axis_did_move, E_AXIS, !!current_block->steps[E_AXIS]); - SET_BIT(axis_did_move, X_HEAD, !!current_block->steps[X_HEAD]); - SET_BIT(axis_did_move, Y_HEAD, !!current_block->steps[Y_HEAD]); - SET_BIT(axis_did_move, Z_HEAD, !!current_block->steps[Z_HEAD]); + SET_BIT_TO(axis_did_move, X_AXIS, X_MOVE_TEST); + SET_BIT_TO(axis_did_move, Y_AXIS, Y_MOVE_TEST); + SET_BIT_TO(axis_did_move, Z_AXIS, Z_MOVE_TEST); + //SET_BIT_TO(axis_did_move, E_AXIS, !!current_block->steps[E_AXIS]); + //SET_BIT_TO(axis_did_move, X_HEAD, !!current_block->steps[A_AXIS]); + //SET_BIT_TO(axis_did_move, Y_HEAD, !!current_block->steps[B_AXIS]); + //SET_BIT_TO(axis_did_move, Z_HEAD, !!current_block->steps[C_AXIS]); // Initialize the trapezoid generator from the current block. #if ENABLED(LIN_ADVANCE)