From d44e5b1fdeb4f5d6196ed0f3afe3076eef90a3da Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Thu, 4 Apr 2019 03:44:07 -0400 Subject: [PATCH] Fix stepper direction macros, multi-nozzle scope (#13569) --- Marlin/src/module/motion.cpp | 7 +++---- Marlin/src/module/motion.h | 7 +++---- Marlin/src/module/stepper_indirection.h | 17 +++++++++++------ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 2e1ed63fa9..c226c180aa 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -859,10 +859,9 @@ void clean_up_after_endstop_or_probe_move() { #if HAS_DUPLICATION_MODE bool extruder_duplication_enabled, mirrored_duplication_mode; -#endif - -#if ENABLED(MULTI_NOZZLE_DUPLICATION) && HOTENDS > 2 - uint8_t duplication_e_mask; // = 0 + #if ENABLED(MULTI_NOZZLE_DUPLICATION) + uint8_t duplication_e_mask; // = 0 + #endif #endif #if ENABLED(DUAL_X_CARRIAGE) diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index fcae47beef..2252f4cac9 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -318,10 +318,9 @@ void homeaxis(const AxisEnum axis); #if HAS_DUPLICATION_MODE extern bool extruder_duplication_enabled, // Used in Dual X mode 2 mirrored_duplication_mode; // Used in Dual X mode 3 -#endif - -#if ENABLED(MULTI_NOZZLE_DUPLICATION) && HOTENDS > 2 - uint8_t duplication_e_mask; + #if ENABLED(MULTI_NOZZLE_DUPLICATION) + extern uint8_t duplication_e_mask; + #endif #endif /** diff --git a/Marlin/src/module/stepper_indirection.h b/Marlin/src/module/stepper_indirection.h index 147a060fc9..39d4fceacb 100644 --- a/Marlin/src/module/stepper_indirection.h +++ b/Marlin/src/module/stepper_indirection.h @@ -618,14 +618,20 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define _REV_E_DIR(E) do{ if (E == 0) { E0_DIR_WRITE( INVERT_E0_DIR); } else { E1_DIR_WRITE( INVERT_E1_DIR); } }while(0) #endif - #if EITHER(DUAL_X_CARRIAGE, MULTI_NOZZLE_DUPLICATION) + #if HAS_DUPLICATION_MODE + + #if ENABLED(MULTI_NOZZLE_DUPLICATION) + #define _DUPE(N,T,V) do{ if (TEST(duplication_e_mask, N)) E##N##_##T##_WRITE(V); }while(0) + #else + #define _DUPE(N,T,V) E##N##_##T##_WRITE(V) + #endif + + #define NDIR(N) _DUPE(N,DIR,!INVERT_E##N##_DIR) + #define RDIR(N) _DUPE(N,DIR, INVERT_E##N##_DIR) - #define NDIR(N) _DUPE(DIR,!INVERT_E##N##_DIR) - #define RDIR(N) _DUPE(DIR, INVERT_E##N##_DIR) #define E_STEP_WRITE(E,V) do{ if (extruder_duplication_enabled) { DUPE(STEP,V); } else _E_STEP_WRITE(E,V); }while(0) #if E_STEPPERS > 2 - #define _DUPE(N,T,V) do{ if (duplication_e_mask <= (N)) E##N##_##T##_WRITE(V); }while(0) #if E_STEPPERS > 5 #define DUPE(T,V) do{ _DUPE(0,T,V); _DUPE(1,T,V); _DUPE(2,T,V); _DUPE(3,T,V); _DUPE(4,T,V); _DUPE(5,T,V); }while(0) #define NORM_E_DIR(E) do{ if (extruder_duplication_enabled) { NDIR(0); NDIR(1); NDIR(2); NDIR(3); NDIR(4); NDIR(5); } else _NORM_E_DIR(E); }while(0) @@ -644,8 +650,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define REV_E_DIR(E) do{ if (extruder_duplication_enabled) { RDIR(0); RDIR(1); RDIR(2); } else _REV_E_DIR(E); }while(0) #endif #else - #define _DUPE(T,V) do{ E0_##T##_WRITE(V); E1_##T##_WRITE(V); }while(0) - #define DUPE(T,V) _DUPE(T,V) + #define DUPE(T,V) do{ _DUPE(0,T,V); _DUPE(1,T,V); } while(0) #define NORM_E_DIR(E) do{ if (extruder_duplication_enabled) { NDIR(0); NDIR(1); } else _NORM_E_DIR(E); }while(0) #define REV_E_DIR(E) do{ if (extruder_duplication_enabled) { RDIR(0); RDIR(1); } else _REV_E_DIR(E); }while(0) #endif