diff --git a/Marlin/Conditionals_post.h b/Marlin/Conditionals_post.h index ff997ce109..709e87e645 100644 --- a/Marlin/Conditionals_post.h +++ b/Marlin/Conditionals_post.h @@ -39,20 +39,31 @@ #define Z_CENTER float((Z_MIN_POS + Z_MAX_POS) * 0.5) /** - * CoreXY and CoreXZ + * CoreXY, CoreXZ, and CoreYZ - and their reverse */ - #if ENABLED(COREXY) - #define CORE_AXIS_1 A_AXIS // XY from A + B - #define CORE_AXIS_2 B_AXIS - #define NORMAL_AXIS Z_AXIS - #elif ENABLED(COREXZ) - #define CORE_AXIS_1 A_AXIS // XZ from A + C - #define CORE_AXIS_2 C_AXIS - #define NORMAL_AXIS Y_AXIS - #elif ENABLED(COREYZ) - #define CORE_AXIS_1 B_AXIS // YZ from B + C - #define CORE_AXIS_2 C_AXIS - #define NORMAL_AXIS X_AXIS + #define CORE_IS_XY (ENABLED(COREXY) || ENABLED(COREYX)) + #define CORE_IS_XZ (ENABLED(COREXZ) || ENABLED(COREZX)) + #define CORE_IS_YZ (ENABLED(COREYZ) || ENABLED(COREZY)) + #define IS_CORE (CORE_IS_XY || CORE_IS_XZ || CORE_IS_YZ) + #if IS_CORE + #if CORE_IS_XY + #define CORE_AXIS_1 A_AXIS + #define CORE_AXIS_2 B_AXIS + #define NORMAL_AXIS Z_AXIS + #elif CORE_IS_XZ + #define CORE_AXIS_1 A_AXIS + #define NORMAL_AXIS Y_AXIS + #define CORE_AXIS_2 C_AXIS + #elif CORE_IS_YZ + #define NORMAL_AXIS X_AXIS + #define CORE_AXIS_1 B_AXIS + #define CORE_AXIS_2 C_AXIS + #endif + #if (ENABLED(COREYX) || ENABLED(COREZX) || ENABLED(COREZY)) + #define CORESIGN(n) (-(n)) + #else + #define CORESIGN(n) (n) + #endif #endif #define IS_SCARA (ENABLED(MORGAN_SCARA) || ENABLED(MAKERARM_SCARA)) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index b70b57dbbb..4610c4f945 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -408,9 +408,13 @@ // @section machine // Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics +// either in the usual order or reversed //#define COREXY //#define COREXZ //#define COREYZ +//#define COREYX +//#define COREZX +//#define COREZY // Enable this option for Toshiba steppers //#define CONFIG_STEPPERS_TOSHIBA diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index b1a5b6c74a..6e6c1d3813 100755 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -3078,7 +3078,7 @@ inline void gcode_G4() { SERIAL_ECHOLNPGM("Delta"); #elif IS_SCARA SERIAL_ECHOLNPGM("SCARA"); - #elif ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(COREYZ) + #elif IS_CORE SERIAL_ECHOLNPGM("Core"); #else SERIAL_ECHOLNPGM("Cartesian"); diff --git a/Marlin/SanityCheck.h b/Marlin/SanityCheck.h index 3cd9adeb6b..ebb1008002 100644 --- a/Marlin/SanityCheck.h +++ b/Marlin/SanityCheck.h @@ -57,8 +57,8 @@ #error "Thermal Runaway Protection for hotends is now enabled with THERMAL_PROTECTION_HOTENDS." #elif DISABLED(THERMAL_PROTECTION_BED) && defined(THERMAL_PROTECTION_BED_PERIOD) #error "Thermal Runaway Protection for the bed is now enabled with THERMAL_PROTECTION_BED." -#elif ENABLED(COREXZ) && ENABLED(Z_LATE_ENABLE) - #error "Z_LATE_ENABLE can't be used with COREXZ." +#elif (CORE_IS_XZ || CORE_IS_YZ) && ENABLED(Z_LATE_ENABLE) + #error "Z_LATE_ENABLE can't be used with COREXZ, COREZX, COREYZ, or COREZY." #elif defined(X_HOME_RETRACT_MM) #error "[XYZ]_HOME_RETRACT_MM settings have been renamed [XYZ]_HOME_BUMP_MM." #elif defined(SDCARDDETECTINVERTED) @@ -644,8 +644,23 @@ #else #define COUNT_KIN_7 COUNT_KIN_6 #endif -#if COUNT_KIN_7 > 1 - #error "Please enable only one of DELTA, MORGAN_SCARA, MAKERARM_SCARA, COREXY, COREXZ, or COREYZ." +#if ENABLED(COREYX) + #define COUNT_KIN_8 INCREMENT(COUNT_KIN_7) +#else + #define COUNT_KIN_8 COUNT_KIN_7 +#endif +#if ENABLED(COREZX) + #define COUNT_KIN_9 INCREMENT(COUNT_KIN_8) +#else + #define COUNT_KIN_9 COUNT_KIN_8 +#endif +#if ENABLED(COREZY) + #define COUNT_KIN_10 INCREMENT(COUNT_KIN_9) +#else + #define COUNT_KIN_10 COUNT_KIN_9 +#endif +#if COUNT_KIN_10 > 1 + #error "Please enable only one of DELTA, MORGAN_SCARA, MAKERARM_SCARA, COREXY, COREYX, COREXZ, COREZX, COREYZ, or COREZY." #endif /** @@ -662,8 +677,8 @@ #if ENABLED(DUAL_X_CARRIAGE) #if EXTRUDERS == 1 #error "DUAL_X_CARRIAGE requires 2 (or more) extruders." - #elif ENABLED(COREXY) || ENABLED(COREXZ) - #error "DUAL_X_CARRIAGE cannot be used with COREXY or COREXZ." + #elif CORE_IS_XY || CORE_IS_XZ + #error "DUAL_X_CARRIAGE cannot be used with COREXY, COREYX, COREXZ, or COREZX." #elif !HAS_X2_ENABLE || !HAS_X2_STEP || !HAS_X2_DIR #error "DUAL_X_CARRIAGE requires X2 stepper pins to be defined." #elif !HAS_X_MAX diff --git a/Marlin/endstops.cpp b/Marlin/endstops.cpp index 53e8b209e5..653e0753a9 100644 --- a/Marlin/endstops.cpp +++ b/Marlin/endstops.cpp @@ -268,7 +268,7 @@ void Endstops::update() { #endif - #if ENABLED(COREXY) || ENABLED(COREXZ) + #if CORE_IS_XY || CORE_IS_XZ // Head direction in -X axis for CoreXY and CoreXZ bots. // If DeltaA == -DeltaB, the movement is only in Y or Z axis if ((stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2]) || (stepper.motor_direction(CORE_AXIS_1) == stepper.motor_direction(CORE_AXIS_2))) { @@ -298,11 +298,11 @@ void Endstops::update() { #endif } } - #if ENABLED(COREXY) || ENABLED(COREXZ) + #if CORE_IS_XY || CORE_IS_XZ } #endif - #if ENABLED(COREXY) || ENABLED(COREYZ) + #if CORE_IS_XY || CORE_IS_YZ // Head direction in -Y axis for CoreXY / CoreYZ bots. // If DeltaA == DeltaB, the movement is only in X or Y axis if ((stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2]) || (stepper.motor_direction(CORE_AXIS_1) != stepper.motor_direction(CORE_AXIS_2))) { @@ -320,11 +320,11 @@ void Endstops::update() { UPDATE_ENDSTOP(Y, MAX); #endif } - #if ENABLED(COREXY) || ENABLED(COREYZ) + #if CORE_IS_XY || CORE_IS_YZ } #endif - #if ENABLED(COREXZ) || ENABLED(COREYZ) + #if CORE_IS_XZ || CORE_IS_YZ // Head direction in -Z axis for CoreXZ or CoreYZ bots. // If DeltaA == DeltaB, the movement is only in X or Y axis if ((stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2]) || (stepper.motor_direction(CORE_AXIS_1) != stepper.motor_direction(CORE_AXIS_2))) { @@ -390,7 +390,7 @@ void Endstops::update() { #endif // !Z_MIN_PROBE_PIN... #endif // Z_MAX_PIN } - #if ENABLED(COREXZ) + #if CORE_IS_XZ || CORE_IS_YZ } #endif diff --git a/Marlin/example_configurations/Cartesio/Configuration.h b/Marlin/example_configurations/Cartesio/Configuration.h index e34be9f4a2..6ba809172c 100644 --- a/Marlin/example_configurations/Cartesio/Configuration.h +++ b/Marlin/example_configurations/Cartesio/Configuration.h @@ -408,9 +408,13 @@ // @section machine // Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics +// either in the usual order or reversed //#define COREXY //#define COREXZ //#define COREYZ +//#define COREYX +//#define COREZX +//#define COREZY // Enable this option for Toshiba steppers //#define CONFIG_STEPPERS_TOSHIBA diff --git a/Marlin/example_configurations/Felix/Configuration.h b/Marlin/example_configurations/Felix/Configuration.h index 923cd3a41f..bde82b2931 100644 --- a/Marlin/example_configurations/Felix/Configuration.h +++ b/Marlin/example_configurations/Felix/Configuration.h @@ -390,9 +390,13 @@ // @section machine // Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics +// either in the usual order or reversed //#define COREXY //#define COREXZ //#define COREYZ +//#define COREYX +//#define COREZX +//#define COREZY // Enable this option for Toshiba steppers //#define CONFIG_STEPPERS_TOSHIBA diff --git a/Marlin/example_configurations/Felix/DUAL/Configuration.h b/Marlin/example_configurations/Felix/DUAL/Configuration.h index 0a202134f1..e4f92618bd 100644 --- a/Marlin/example_configurations/Felix/DUAL/Configuration.h +++ b/Marlin/example_configurations/Felix/DUAL/Configuration.h @@ -390,9 +390,13 @@ // @section machine // Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics +// either in the usual order or reversed //#define COREXY //#define COREXZ //#define COREYZ +//#define COREYX +//#define COREZX +//#define COREZY // Enable this option for Toshiba steppers //#define CONFIG_STEPPERS_TOSHIBA diff --git a/Marlin/example_configurations/Hephestos/Configuration.h b/Marlin/example_configurations/Hephestos/Configuration.h index cae5d1e015..3d033f95c0 100644 --- a/Marlin/example_configurations/Hephestos/Configuration.h +++ b/Marlin/example_configurations/Hephestos/Configuration.h @@ -400,9 +400,13 @@ // @section machine // Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics +// either in the usual order or reversed //#define COREXY //#define COREXZ //#define COREYZ +//#define COREYX +//#define COREZX +//#define COREZY // Enable this option for Toshiba steppers //#define CONFIG_STEPPERS_TOSHIBA diff --git a/Marlin/example_configurations/Hephestos_2/Configuration.h b/Marlin/example_configurations/Hephestos_2/Configuration.h index 64f39a2f0d..79a797df58 100644 --- a/Marlin/example_configurations/Hephestos_2/Configuration.h +++ b/Marlin/example_configurations/Hephestos_2/Configuration.h @@ -402,9 +402,13 @@ // @section machine // Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics +// either in the usual order or reversed //#define COREXY //#define COREXZ //#define COREYZ +//#define COREYX +//#define COREZX +//#define COREZY // Enable this option for Toshiba steppers //#define CONFIG_STEPPERS_TOSHIBA diff --git a/Marlin/example_configurations/K8200/Configuration.h b/Marlin/example_configurations/K8200/Configuration.h index a76ad5ea92..ec46a33fa2 100644 --- a/Marlin/example_configurations/K8200/Configuration.h +++ b/Marlin/example_configurations/K8200/Configuration.h @@ -438,9 +438,13 @@ // @section machine // Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics +// either in the usual order or reversed //#define COREXY //#define COREXZ //#define COREYZ +//#define COREYX +//#define COREZX +//#define COREZY // Enable this option for Toshiba steppers //#define CONFIG_STEPPERS_TOSHIBA diff --git a/Marlin/example_configurations/K8400/Configuration.h b/Marlin/example_configurations/K8400/Configuration.h index ab24c1b039..35ae51196c 100644 --- a/Marlin/example_configurations/K8400/Configuration.h +++ b/Marlin/example_configurations/K8400/Configuration.h @@ -408,9 +408,13 @@ // @section machine // Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics +// either in the usual order or reversed //#define COREXY //#define COREXZ //#define COREYZ +//#define COREYX +//#define COREZX +//#define COREZY // Enable this option for Toshiba steppers //#define CONFIG_STEPPERS_TOSHIBA diff --git a/Marlin/example_configurations/K8400/Dual-head/Configuration.h b/Marlin/example_configurations/K8400/Dual-head/Configuration.h index ca4cff7cbe..5d1c84c45c 100644 --- a/Marlin/example_configurations/K8400/Dual-head/Configuration.h +++ b/Marlin/example_configurations/K8400/Dual-head/Configuration.h @@ -408,9 +408,13 @@ // @section machine // Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics +// either in the usual order or reversed //#define COREXY //#define COREXZ //#define COREYZ +//#define COREYX +//#define COREZX +//#define COREZY // Enable this option for Toshiba steppers //#define CONFIG_STEPPERS_TOSHIBA diff --git a/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h b/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h index 726aff69cc..bc96cb8820 100644 --- a/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h +++ b/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h @@ -408,9 +408,13 @@ // @section machine // Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics +// either in the usual order or reversed //#define COREXY //#define COREXZ //#define COREYZ +//#define COREYX +//#define COREZX +//#define COREZY // Enable this option for Toshiba steppers //#define CONFIG_STEPPERS_TOSHIBA diff --git a/Marlin/example_configurations/RigidBot/Configuration.h b/Marlin/example_configurations/RigidBot/Configuration.h index 54e9d86db5..d1c2334e70 100644 --- a/Marlin/example_configurations/RigidBot/Configuration.h +++ b/Marlin/example_configurations/RigidBot/Configuration.h @@ -405,9 +405,13 @@ // @section machine // Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics +// either in the usual order or reversed //#define COREXY //#define COREXZ //#define COREYZ +//#define COREYX +//#define COREZX +//#define COREZY // Enable this option for Toshiba steppers //#define CONFIG_STEPPERS_TOSHIBA diff --git a/Marlin/example_configurations/SCARA/Configuration.h b/Marlin/example_configurations/SCARA/Configuration.h index 2ef2772447..6f72476cbf 100644 --- a/Marlin/example_configurations/SCARA/Configuration.h +++ b/Marlin/example_configurations/SCARA/Configuration.h @@ -423,9 +423,13 @@ // @section machine // Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics +// either in the usual order or reversed //#define COREXY //#define COREXZ //#define COREYZ +//#define COREYX +//#define COREZX +//#define COREZY // Enable this option for Toshiba steppers //#define CONFIG_STEPPERS_TOSHIBA diff --git a/Marlin/example_configurations/TAZ4/Configuration.h b/Marlin/example_configurations/TAZ4/Configuration.h index be7d9d25f9..6f4afcf377 100644 --- a/Marlin/example_configurations/TAZ4/Configuration.h +++ b/Marlin/example_configurations/TAZ4/Configuration.h @@ -429,9 +429,13 @@ // @section machine // Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics +// either in the usual order or reversed //#define COREXY //#define COREXZ //#define COREYZ +//#define COREYX +//#define COREZX +//#define COREZY // Enable this option for Toshiba steppers //#define CONFIG_STEPPERS_TOSHIBA diff --git a/Marlin/example_configurations/WITBOX/Configuration.h b/Marlin/example_configurations/WITBOX/Configuration.h index b1cba78d82..fc5f81503a 100644 --- a/Marlin/example_configurations/WITBOX/Configuration.h +++ b/Marlin/example_configurations/WITBOX/Configuration.h @@ -400,9 +400,13 @@ // @section machine // Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics +// either in the usual order or reversed //#define COREXY //#define COREXZ //#define COREYZ +//#define COREYX +//#define COREZX +//#define COREZY // Enable this option for Toshiba steppers //#define CONFIG_STEPPERS_TOSHIBA diff --git a/Marlin/example_configurations/adafruit/ST7565/Configuration.h b/Marlin/example_configurations/adafruit/ST7565/Configuration.h index 837b6c2684..aa2079865c 100644 --- a/Marlin/example_configurations/adafruit/ST7565/Configuration.h +++ b/Marlin/example_configurations/adafruit/ST7565/Configuration.h @@ -408,9 +408,13 @@ // @section machine // Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics +// either in the usual order or reversed //#define COREXY //#define COREXZ //#define COREYZ +//#define COREYX +//#define COREZX +//#define COREZY // Enable this option for Toshiba steppers //#define CONFIG_STEPPERS_TOSHIBA diff --git a/Marlin/example_configurations/delta/biv2.5/Configuration.h b/Marlin/example_configurations/delta/biv2.5/Configuration.h index cd16f383c3..93b8c99499 100644 --- a/Marlin/example_configurations/delta/biv2.5/Configuration.h +++ b/Marlin/example_configurations/delta/biv2.5/Configuration.h @@ -408,9 +408,13 @@ // @section machine // Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics +// either in the usual order or reversed //#define COREXY //#define COREXZ //#define COREYZ +//#define COREYX +//#define COREZX +//#define COREZY //=========================================================================== //============================== Delta Settings ============================= diff --git a/Marlin/example_configurations/delta/generic/Configuration.h b/Marlin/example_configurations/delta/generic/Configuration.h index 3ace6e84ca..38ac08962c 100644 --- a/Marlin/example_configurations/delta/generic/Configuration.h +++ b/Marlin/example_configurations/delta/generic/Configuration.h @@ -408,9 +408,13 @@ // @section machine // Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics +// either in the usual order or reversed //#define COREXY //#define COREXZ //#define COREYZ +//#define COREYX +//#define COREZX +//#define COREZY //=========================================================================== //============================== Delta Settings ============================= diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration.h b/Marlin/example_configurations/delta/kossel_mini/Configuration.h index a39855417c..a6d187cdf1 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration.h @@ -408,9 +408,13 @@ // @section machine // Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics +// either in the usual order or reversed //#define COREXY //#define COREXZ //#define COREYZ +//#define COREYX +//#define COREZX +//#define COREZY //=========================================================================== //============================== Delta Settings ============================= diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration.h b/Marlin/example_configurations/delta/kossel_pro/Configuration.h index e66863fba0..ee5cbd1e21 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration.h @@ -395,9 +395,13 @@ // @section machine // Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics +// either in the usual order or reversed //#define COREXY //#define COREXZ //#define COREYZ +//#define COREYX +//#define COREZX +//#define COREZY //=========================================================================== //============================== Delta Settings ============================= diff --git a/Marlin/example_configurations/delta/kossel_xl/Configuration.h b/Marlin/example_configurations/delta/kossel_xl/Configuration.h index 076a085156..619cab9311 100644 --- a/Marlin/example_configurations/delta/kossel_xl/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_xl/Configuration.h @@ -406,9 +406,13 @@ // @section machine // Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics +// either in the usual order or reversed //#define COREXY //#define COREXZ //#define COREYZ +//#define COREYX +//#define COREZX +//#define COREZY //=========================================================================== //============================== Delta Settings ============================= diff --git a/Marlin/example_configurations/makibox/Configuration.h b/Marlin/example_configurations/makibox/Configuration.h index 4364fdfa49..d2e402cb7a 100644 --- a/Marlin/example_configurations/makibox/Configuration.h +++ b/Marlin/example_configurations/makibox/Configuration.h @@ -411,9 +411,13 @@ // @section machine // Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics +// either in the usual order or reversed //#define COREXY //#define COREXZ //#define COREYZ +//#define COREYX +//#define COREZX +//#define COREZY // Enable this option for Toshiba steppers //#define CONFIG_STEPPERS_TOSHIBA diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration.h b/Marlin/example_configurations/tvrrug/Round2/Configuration.h index ec57e30348..48e777a754 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration.h @@ -398,9 +398,13 @@ // @section machine // Uncomment one of these options to enable CoreXY, CoreXZ, or CoreYZ kinematics +// either in the usual order or reversed //#define COREXY //#define COREXZ //#define COREYZ +//#define COREYX +//#define COREZX +//#define COREZY // Enable this option for Toshiba steppers #define CONFIG_STEPPERS_TOSHIBA diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index bb9379733b..9869373586 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -712,24 +712,24 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const // Compute direction bit-mask for this block uint8_t dm = 0; - #if ENABLED(COREXY) - if (da < 0) SBI(dm, X_HEAD); // Save the real Extruder (head) direction in X Axis - if (db < 0) SBI(dm, Y_HEAD); // ...and Y + #if CORE_IS_XY + if (da < 0) SBI(dm, X_HEAD); // Save the real Extruder (head) direction in X Axis + if (db < 0) SBI(dm, Y_HEAD); // ...and Y if (dc < 0) SBI(dm, Z_AXIS); - if (da + db < 0) SBI(dm, A_AXIS); // Motor A direction - if (da - db < 0) SBI(dm, B_AXIS); // Motor B direction - #elif ENABLED(COREXZ) - if (da < 0) SBI(dm, X_HEAD); // Save the real Extruder (head) direction in X Axis + if (da + db < 0) SBI(dm, A_AXIS); // Motor A direction + if (CORESIGN(da - db) < 0) SBI(dm, B_AXIS); // Motor B direction + #elif CORE_IS_XZ + if (da < 0) SBI(dm, X_HEAD); // Save the real Extruder (head) direction in X Axis if (db < 0) SBI(dm, Y_AXIS); - if (dc < 0) SBI(dm, Z_HEAD); // ...and Z - if (da + dc < 0) SBI(dm, A_AXIS); // Motor A direction - if (da - dc < 0) SBI(dm, C_AXIS); // Motor C direction - #elif ENABLED(COREYZ) + if (dc < 0) SBI(dm, Z_HEAD); // ...and Z + if (da + dc < 0) SBI(dm, A_AXIS); // Motor A direction + if (CORESIGN(da - dc) < 0) SBI(dm, C_AXIS); // Motor C direction + #elif CORE_IS_YZ if (da < 0) SBI(dm, X_AXIS); - if (db < 0) SBI(dm, Y_HEAD); // Save the real Extruder (head) direction in Y Axis - if (dc < 0) SBI(dm, Z_HEAD); // ...and Z - if (db + dc < 0) SBI(dm, B_AXIS); // Motor B direction - if (db - dc < 0) SBI(dm, C_AXIS); // Motor C direction + if (db < 0) SBI(dm, Y_HEAD); // Save the real Extruder (head) direction in Y Axis + if (dc < 0) SBI(dm, Z_HEAD); // ...and Z + if (db + dc < 0) SBI(dm, B_AXIS); // Motor B direction + if (CORESIGN(db - dc) < 0) SBI(dm, C_AXIS); // Motor C direction #else if (da < 0) SBI(dm, X_AXIS); if (db < 0) SBI(dm, Y_AXIS); @@ -757,19 +757,16 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const block->direction_bits = dm; // Number of steps for each axis - #if ENABLED(COREXY) - // corexy planning - // these equations follow the form of the dA and dB equations on http://www.corexy.com/theory.html + // See http://www.corexy.com/theory.html + #if CORE_IS_XY block->steps[A_AXIS] = labs(da + db); block->steps[B_AXIS] = labs(da - db); block->steps[Z_AXIS] = labs(dc); - #elif ENABLED(COREXZ) - // corexz planning + #elif CORE_IS_XZ block->steps[A_AXIS] = labs(da + dc); block->steps[Y_AXIS] = labs(db); block->steps[C_AXIS] = labs(da - dc); - #elif ENABLED(COREYZ) - // coreyz planning + #elif CORE_IS_YZ block->steps[X_AXIS] = labs(da); block->steps[B_AXIS] = labs(db + dc); block->steps[C_AXIS] = labs(db - dc); @@ -804,7 +801,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const block->active_extruder = extruder; //enable active axes - #if ENABLED(COREXY) + #if CORE_IS_XY if (block->steps[A_AXIS] || block->steps[B_AXIS]) { enable_x(); enable_y(); @@ -812,13 +809,13 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const #if DISABLED(Z_LATE_ENABLE) if (block->steps[Z_AXIS]) enable_z(); #endif - #elif ENABLED(COREXZ) + #elif CORE_IS_XZ if (block->steps[A_AXIS] || block->steps[C_AXIS]) { enable_x(); enable_z(); } if (block->steps[Y_AXIS]) enable_y(); - #elif ENABLED(COREYZ) + #elif CORE_IS_YZ if (block->steps[B_AXIS] || block->steps[C_AXIS]) { enable_y(); enable_z(); @@ -915,26 +912,26 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const * So we need to create other 2 "AXIS", named X_HEAD and Y_HEAD, meaning the real displacement of the Head. * Having the real displacement of the head, we can calculate the total movement length and apply the desired speed. */ - #if ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(COREYZ) + #if IS_CORE float delta_mm[7]; - #if ENABLED(COREXY) + #if CORE_IS_XY delta_mm[X_HEAD] = da * steps_to_mm[A_AXIS]; delta_mm[Y_HEAD] = db * steps_to_mm[B_AXIS]; delta_mm[Z_AXIS] = dc * steps_to_mm[Z_AXIS]; delta_mm[A_AXIS] = (da + db) * steps_to_mm[A_AXIS]; - delta_mm[B_AXIS] = (da - db) * steps_to_mm[B_AXIS]; - #elif ENABLED(COREXZ) + delta_mm[B_AXIS] = CORESIGN(da - db) * steps_to_mm[B_AXIS]; + #elif CORE_IS_XZ delta_mm[X_HEAD] = da * steps_to_mm[A_AXIS]; delta_mm[Y_AXIS] = db * steps_to_mm[Y_AXIS]; delta_mm[Z_HEAD] = dc * steps_to_mm[C_AXIS]; delta_mm[A_AXIS] = (da + dc) * steps_to_mm[A_AXIS]; - delta_mm[C_AXIS] = (da - dc) * steps_to_mm[C_AXIS]; - #elif ENABLED(COREYZ) + delta_mm[C_AXIS] = CORESIGN(da - dc) * steps_to_mm[C_AXIS]; + #elif CORE_IS_YZ delta_mm[X_AXIS] = da * steps_to_mm[X_AXIS]; delta_mm[Y_HEAD] = db * steps_to_mm[B_AXIS]; delta_mm[Z_HEAD] = dc * steps_to_mm[C_AXIS]; delta_mm[B_AXIS] = (db + dc) * steps_to_mm[B_AXIS]; - delta_mm[C_AXIS] = (db - dc) * steps_to_mm[C_AXIS]; + delta_mm[C_AXIS] = CORESIGN(db - dc) * steps_to_mm[C_AXIS]; #endif #else float delta_mm[4]; @@ -949,11 +946,11 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const } else { block->millimeters = sqrt( - #if ENABLED(COREXY) + #if CORE_IS_XY sq(delta_mm[X_HEAD]) + sq(delta_mm[Y_HEAD]) + sq(delta_mm[Z_AXIS]) - #elif ENABLED(COREXZ) + #elif CORE_IS_XZ sq(delta_mm[X_HEAD]) + sq(delta_mm[Y_AXIS]) + sq(delta_mm[Z_HEAD]) - #elif ENABLED(COREYZ) + #elif CORE_IS_YZ sq(delta_mm[X_AXIS]) + sq(delta_mm[Y_HEAD]) + sq(delta_mm[Z_HEAD]) #else sq(delta_mm[X_AXIS]) + sq(delta_mm[Y_AXIS]) + sq(delta_mm[Z_AXIS]) diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 2c6ba5255f..0be61e6465 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -991,22 +991,22 @@ void Stepper::set_position(const long &a, const long &b, const long &c, const lo CRITICAL_SECTION_START; - #if ENABLED(COREXY) + #if CORE_IS_XY // corexy positioning // these equations follow the form of the dA and dB equations on http://www.corexy.com/theory.html count_position[A_AXIS] = a + b; - count_position[B_AXIS] = a - b; + count_position[B_AXIS] = CORESIGN(a - b); count_position[Z_AXIS] = c; - #elif ENABLED(COREXZ) + #elif CORE_IS_XZ // corexz planning count_position[A_AXIS] = a + c; count_position[Y_AXIS] = b; - count_position[C_AXIS] = a - c; - #elif ENABLED(COREYZ) + count_position[C_AXIS] = CORESIGN(a - c); + #elif CORE_IS_YZ // coreyz planning count_position[X_AXIS] = a; count_position[B_AXIS] = b + c; - count_position[C_AXIS] = b - c; + count_position[C_AXIS] = CORESIGN(b - c); #else // default non-h-bot planning count_position[X_AXIS] = a; @@ -1046,16 +1046,17 @@ long Stepper::position(AxisEnum axis) { */ float Stepper::get_axis_position_mm(AxisEnum axis) { float axis_steps; - #if ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(COREYZ) + #if IS_CORE // Requesting one of the "core" axes? if (axis == CORE_AXIS_1 || axis == CORE_AXIS_2) { CRITICAL_SECTION_START; - long pos1 = count_position[CORE_AXIS_1], - pos2 = count_position[CORE_AXIS_2]; - CRITICAL_SECTION_END; // ((a1+a2)+(a1-a2))/2 -> (a1+a2+a1-a2)/2 -> (a1+a1)/2 -> a1 // ((a1+a2)-(a1-a2))/2 -> (a1+a2-a1+a2)/2 -> (a2+a2)/2 -> a2 - axis_steps = (pos1 + ((axis == CORE_AXIS_1) ? pos2 : -pos2)) * 0.5f; + axis_steps = 0.5f * ( + axis == CORE_AXIS_2 ? CORESIGN(count_position[CORE_AXIS_1] - count_position[CORE_AXIS_2]) + : count_position[CORE_AXIS_1] + count_position[CORE_AXIS_2] + ); + CRITICAL_SECTION_END; } else axis_steps = position(axis); @@ -1083,14 +1084,12 @@ void Stepper::quick_stop() { void Stepper::endstop_triggered(AxisEnum axis) { - #if ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(COREYZ) + #if IS_CORE - float axis_pos = count_position[axis]; - if (axis == CORE_AXIS_1) - axis_pos = (axis_pos + count_position[CORE_AXIS_2]) * 0.5; - else if (axis == CORE_AXIS_2) - axis_pos = (count_position[CORE_AXIS_1] - axis_pos) * 0.5; - endstops_trigsteps[axis] = axis_pos; + endstops_trigsteps[axis] = 0.5f * ( + axis == CORE_AXIS_2 ? CORESIGN(count_position[CORE_AXIS_1] - count_position[CORE_AXIS_2]) + : count_position[CORE_AXIS_1] + count_position[CORE_AXIS_2] + ); #else // !COREXY && !COREXZ && !COREYZ @@ -1108,21 +1107,21 @@ void Stepper::report_positions() { zpos = count_position[Z_AXIS]; CRITICAL_SECTION_END; - #if ENABLED(COREXY) || ENABLED(COREXZ) || IS_SCARA + #if CORE_IS_XY || CORE_IS_XZ || IS_SCARA SERIAL_PROTOCOLPGM(MSG_COUNT_A); #else SERIAL_PROTOCOLPGM(MSG_COUNT_X); #endif SERIAL_PROTOCOL(xpos); - #if ENABLED(COREXY) || ENABLED(COREYZ) || IS_SCARA + #if CORE_IS_XY || CORE_IS_YZ || IS_SCARA SERIAL_PROTOCOLPGM(" B:"); #else SERIAL_PROTOCOLPGM(" Y:"); #endif SERIAL_PROTOCOL(ypos); - #if ENABLED(COREXZ) || ENABLED(COREYZ) + #if CORE_IS_XZ || CORE_IS_YZ SERIAL_PROTOCOLPGM(" C:"); #else SERIAL_PROTOCOLPGM(" Z:"); diff --git a/Marlin/temperature.h b/Marlin/temperature.h index 37d47fe5b7..a6b9874c6a 100644 --- a/Marlin/temperature.h +++ b/Marlin/temperature.h @@ -385,7 +385,7 @@ class Temperature { #if ENABLED(BABYSTEPPING) static void babystep_axis(const AxisEnum axis, const int distance) { - #if ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(COREYZ) + #if IS_CORE #if ENABLED(BABYSTEP_XY) switch (axis) { case CORE_AXIS_1: // X on CoreXY and CoreXZ, Y on CoreYZ @@ -393,17 +393,17 @@ class Temperature { babystepsTodo[CORE_AXIS_2] += distance * 2; break; case CORE_AXIS_2: // Y on CoreXY, Z on CoreXZ and CoreYZ - babystepsTodo[CORE_AXIS_1] += distance * 2; - babystepsTodo[CORE_AXIS_2] -= distance * 2; + babystepsTodo[CORE_AXIS_1] += CORESIGN(distance * 2); + babystepsTodo[CORE_AXIS_2] -= CORESIGN(distance * 2); break; case NORMAL_AXIS: // Z on CoreXY, Y on CoreXZ, X on CoreYZ babystepsTodo[NORMAL_AXIS] += distance; break; } - #elif ENABLED(COREXZ) || ENABLED(COREYZ) + #elif CORE_IS_XZ || CORE_IS_YZ // Only Z stepping needs to be handled here - babystepsTodo[CORE_AXIS_1] += distance * 2; - babystepsTodo[CORE_AXIS_2] -= distance * 2; + babystepsTodo[CORE_AXIS_1] += CORESIGN(distance * 2); + babystepsTodo[CORE_AXIS_2] -= CORESIGN(distance * 2); #else babystepsTodo[Z_AXIS] += distance; #endif