From eaefc1e41069ab9dc51a52e87e7418c6669dce42 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 19 Mar 2018 02:51:40 -0500 Subject: [PATCH] Add CorePQ support for BABYSTEPPING (#10155) --- Marlin/src/module/stepper.cpp | 51 +++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index c4c604b015..60305919b8 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -1304,16 +1304,16 @@ void Stepper::report_positions() { #endif #endif - #define BABYSTEP_AXIS(AXIS, INVERT) { \ - const uint8_t old_dir = _READ_DIR(AXIS); \ - _ENABLE(AXIS); \ - _SAVE_START; \ - _APPLY_DIR(AXIS, _INVERT_DIR(AXIS)^direction^INVERT); \ - _PULSE_WAIT; \ - _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS), true); \ - _PULSE_WAIT; \ - _APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS), true); \ - _APPLY_DIR(AXIS, old_dir); \ + #define BABYSTEP_AXIS(AXIS, INVERT, DIR) { \ + const uint8_t old_dir = _READ_DIR(AXIS); \ + _ENABLE(AXIS); \ + _SAVE_START; \ + _APPLY_DIR(AXIS, _INVERT_DIR(AXIS)^DIR^INVERT); \ + _PULSE_WAIT; \ + _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS), true); \ + _PULSE_WAIT; \ + _APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS), true); \ + _APPLY_DIR(AXIS, old_dir); \ } // MUST ONLY BE CALLED BY AN ISR, @@ -1326,20 +1326,43 @@ void Stepper::report_positions() { #if ENABLED(BABYSTEP_XY) case X_AXIS: - BABYSTEP_AXIS(X, false); + #if CORE_IS_XY + BABYSTEP_AXIS(X, false, direction); + BABYSTEP_AXIS(Y, false, direction); + #elif CORE_IS_XZ + BABYSTEP_AXIS(X, false, direction); + BABYSTEP_AXIS(Z, false, direction); + #else + BABYSTEP_AXIS(X, false, direction); + #endif break; case Y_AXIS: - BABYSTEP_AXIS(Y, false); + #if CORE_IS_XY + BABYSTEP_AXIS(X, false, direction); + BABYSTEP_AXIS(Y, false, direction^(CORESIGN(1)<0)); + #elif CORE_IS_YZ + BABYSTEP_AXIS(Y, false, direction); + BABYSTEP_AXIS(Z, false, direction^(CORESIGN(1)<0)); + #else + BABYSTEP_AXIS(Y, false, direction); + #endif break; #endif case Z_AXIS: { - #if DISABLED(DELTA) + #if CORE_IS_XZ + BABYSTEP_AXIS(X, BABYSTEP_INVERT_Z, direction); + BABYSTEP_AXIS(Z, BABYSTEP_INVERT_Z, direction^(CORESIGN(1)<0)); - BABYSTEP_AXIS(Z, BABYSTEP_INVERT_Z); + #elif CORE_IS_YZ + BABYSTEP_AXIS(Y, BABYSTEP_INVERT_Z, direction); + BABYSTEP_AXIS(Z, BABYSTEP_INVERT_Z, direction^(CORESIGN(1)<0)); + + #elif DISABLED(DELTA) + BABYSTEP_AXIS(Z, BABYSTEP_INVERT_Z, direction); #else // DELTA