From e3c831850415f931ef97a9ca1709862a7a8ee729 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 5 Nov 2016 23:47:24 -0500 Subject: [PATCH 1/2] Add reversed CORE options --- Marlin/Configuration.h | 4 ++++ Marlin/example_configurations/Cartesio/Configuration.h | 4 ++++ Marlin/example_configurations/Felix/Configuration.h | 4 ++++ Marlin/example_configurations/Felix/DUAL/Configuration.h | 4 ++++ Marlin/example_configurations/Hephestos/Configuration.h | 4 ++++ Marlin/example_configurations/Hephestos_2/Configuration.h | 4 ++++ Marlin/example_configurations/K8200/Configuration.h | 4 ++++ Marlin/example_configurations/K8400/Configuration.h | 4 ++++ Marlin/example_configurations/K8400/Dual-head/Configuration.h | 4 ++++ .../RepRapWorld/Megatronics/Configuration.h | 4 ++++ Marlin/example_configurations/RigidBot/Configuration.h | 4 ++++ Marlin/example_configurations/SCARA/Configuration.h | 4 ++++ Marlin/example_configurations/TAZ4/Configuration.h | 4 ++++ Marlin/example_configurations/WITBOX/Configuration.h | 4 ++++ Marlin/example_configurations/adafruit/ST7565/Configuration.h | 4 ++++ Marlin/example_configurations/delta/biv2.5/Configuration.h | 4 ++++ Marlin/example_configurations/delta/generic/Configuration.h | 4 ++++ .../example_configurations/delta/kossel_mini/Configuration.h | 4 ++++ .../example_configurations/delta/kossel_pro/Configuration.h | 4 ++++ Marlin/example_configurations/delta/kossel_xl/Configuration.h | 4 ++++ Marlin/example_configurations/makibox/Configuration.h | 4 ++++ Marlin/example_configurations/tvrrug/Round2/Configuration.h | 4 ++++ 22 files changed, 88 insertions(+) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 6b63fc383..588285be6 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -399,9 +399,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/Cartesio/Configuration.h b/Marlin/example_configurations/Cartesio/Configuration.h index fcb7ee666..2d64c0c23 100644 --- a/Marlin/example_configurations/Cartesio/Configuration.h +++ b/Marlin/example_configurations/Cartesio/Configuration.h @@ -399,9 +399,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 3683a40f3..35ad97353 100644 --- a/Marlin/example_configurations/Felix/Configuration.h +++ b/Marlin/example_configurations/Felix/Configuration.h @@ -381,9 +381,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 cf5585a68..65b5948da 100644 --- a/Marlin/example_configurations/Felix/DUAL/Configuration.h +++ b/Marlin/example_configurations/Felix/DUAL/Configuration.h @@ -381,9 +381,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 d5ebeffe4..4ea15fe0a 100644 --- a/Marlin/example_configurations/Hephestos/Configuration.h +++ b/Marlin/example_configurations/Hephestos/Configuration.h @@ -391,9 +391,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 d8835d001..63db19c28 100644 --- a/Marlin/example_configurations/Hephestos_2/Configuration.h +++ b/Marlin/example_configurations/Hephestos_2/Configuration.h @@ -393,9 +393,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 0c9aab131..b7617f540 100644 --- a/Marlin/example_configurations/K8200/Configuration.h +++ b/Marlin/example_configurations/K8200/Configuration.h @@ -416,9 +416,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 585162296..5f70d3f5b 100644 --- a/Marlin/example_configurations/K8400/Configuration.h +++ b/Marlin/example_configurations/K8400/Configuration.h @@ -399,9 +399,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 4fd1a9f8a..8946eb39a 100644 --- a/Marlin/example_configurations/K8400/Dual-head/Configuration.h +++ b/Marlin/example_configurations/K8400/Dual-head/Configuration.h @@ -399,9 +399,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 16517f877..a6aa68a67 100644 --- a/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h +++ b/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h @@ -399,9 +399,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 7310bf6e2..9dff68f89 100644 --- a/Marlin/example_configurations/RigidBot/Configuration.h +++ b/Marlin/example_configurations/RigidBot/Configuration.h @@ -396,9 +396,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 38686f7ca..bd4249619 100644 --- a/Marlin/example_configurations/SCARA/Configuration.h +++ b/Marlin/example_configurations/SCARA/Configuration.h @@ -414,9 +414,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 11cccd8d0..50fa67989 100644 --- a/Marlin/example_configurations/TAZ4/Configuration.h +++ b/Marlin/example_configurations/TAZ4/Configuration.h @@ -420,9 +420,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 6010d6d25..ffce084f3 100644 --- a/Marlin/example_configurations/WITBOX/Configuration.h +++ b/Marlin/example_configurations/WITBOX/Configuration.h @@ -391,9 +391,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 aa764bb09..dcbc783af 100644 --- a/Marlin/example_configurations/adafruit/ST7565/Configuration.h +++ b/Marlin/example_configurations/adafruit/ST7565/Configuration.h @@ -399,9 +399,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 934ac34d9..21737b21e 100644 --- a/Marlin/example_configurations/delta/biv2.5/Configuration.h +++ b/Marlin/example_configurations/delta/biv2.5/Configuration.h @@ -399,9 +399,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 5a647e673..aba24da95 100644 --- a/Marlin/example_configurations/delta/generic/Configuration.h +++ b/Marlin/example_configurations/delta/generic/Configuration.h @@ -399,9 +399,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 2b0a38593..b60bfe57d 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration.h @@ -399,9 +399,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 c5df13508..ac31326b1 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration.h @@ -388,9 +388,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 81f6aa865..bd7a62fff 100644 --- a/Marlin/example_configurations/delta/kossel_xl/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_xl/Configuration.h @@ -397,9 +397,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 891ac9cd2..053e41412 100644 --- a/Marlin/example_configurations/makibox/Configuration.h +++ b/Marlin/example_configurations/makibox/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/tvrrug/Round2/Configuration.h b/Marlin/example_configurations/tvrrug/Round2/Configuration.h index 883f7df19..6cbf2ff0e 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration.h @@ -389,9 +389,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 From 1864b282c53489810be57c58ce35d11be1e6660a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 5 Nov 2016 23:47:38 -0500 Subject: [PATCH 2/2] Implement reversed CORE options --- Marlin/Conditionals_post.h | 37 +++++++++++++-------- Marlin/Marlin_main.cpp | 2 +- Marlin/SanityCheck.h | 27 +++++++++++---- Marlin/endstops.cpp | 12 +++---- Marlin/planner.cpp | 67 ++++++++++++++++++-------------------- Marlin/stepper.cpp | 41 ++++++++++++----------- Marlin/temperature.h | 12 +++---- 7 files changed, 110 insertions(+), 88 deletions(-) diff --git a/Marlin/Conditionals_post.h b/Marlin/Conditionals_post.h index 5dc5abc48..6af0b0353 100644 --- a/Marlin/Conditionals_post.h +++ b/Marlin/Conditionals_post.h @@ -45,20 +45,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/Marlin_main.cpp b/Marlin/Marlin_main.cpp index eba4f83be..1cf776162 100755 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -3044,7 +3044,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 3cd9adeb6..ebb100800 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 53e8b209e..653e0753a 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/planner.cpp b/Marlin/planner.cpp index 426b7d522..84291e10c 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -674,24 +674,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); @@ -718,19 +718,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); @@ -765,7 +762,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(); @@ -773,13 +770,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(); @@ -876,26 +873,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]; @@ -910,11 +907,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 77834bd36..25d0ee659 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -968,22 +968,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; @@ -1023,16 +1023,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); @@ -1057,14 +1058,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 @@ -1082,21 +1081,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 37d47fe5b..a6b9874c6 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