|
@@ -122,8 +122,13 @@ volatile uint32_t Stepper::step_events_completed = 0; // The number of step even
|
122
|
122
|
Stepper::final_adv_steps,
|
123
|
123
|
Stepper::max_adv_steps;
|
124
|
124
|
|
125
|
|
- int8_t Stepper::e_steps = 0,
|
126
|
|
- Stepper::LA_active_extruder; // Copy from current executed block. Needed because current_block is set to NULL "too early".
|
|
125
|
+ int8_t Stepper::e_steps = 0;
|
|
126
|
+
|
|
127
|
+ #if E_STEPPERS > 1
|
|
128
|
+ int8_t Stepper::LA_active_extruder; // Copy from current executed block. Needed because current_block is set to NULL "too early".
|
|
129
|
+ #else
|
|
130
|
+ constexpr int8_t Stepper::LA_active_extruder;
|
|
131
|
+ #endif
|
127
|
132
|
|
128
|
133
|
bool Stepper::use_advance_lead;
|
129
|
134
|
|
|
@@ -755,23 +760,21 @@ void Stepper::isr() {
|
755
|
760
|
|
756
|
761
|
void Stepper::advance_isr() {
|
757
|
762
|
|
758
|
|
- #if ENABLED(MK2_MULTIPLEXER)
|
759
|
|
- // Even-numbered steppers are reversed
|
760
|
|
- #define SET_E_STEP_DIR(INDEX) \
|
761
|
|
- if (e_steps) E## INDEX ##_DIR_WRITE(e_steps < 0 ? !INVERT_E## INDEX ##_DIR ^ TEST(INDEX, 0) : INVERT_E## INDEX ##_DIR ^ TEST(INDEX, 0))
|
|
763
|
+ #if ENABLED(MK2_MULTIPLEXER) // For SNMM even-numbered steppers are reversed
|
|
764
|
+ #define SET_E_STEP_DIR(INDEX) do{ if (e_steps) E## INDEX ##_DIR_WRITE(e_steps < 0 ? !INVERT_E## INDEX ##_DIR ^ TEST(INDEX, 0) : INVERT_E## INDEX ##_DIR ^ TEST(INDEX, 0)); }while(0)
|
|
765
|
+ #elif ENABLED(DUAL_X_CARRIAGE) || ENABLED(DUAL_NOZZLE_DUPLICATION_MODE)
|
|
766
|
+ #define SET_E_STEP_DIR(INDEX) do{ if (e_steps) { e_steps < 0 ? REV_E_DIR() : NORM_E_DIR(); } }while(0)
|
762
|
767
|
#else
|
763
|
|
- #define SET_E_STEP_DIR(INDEX) \
|
764
|
|
- if (e_steps) E## INDEX ##_DIR_WRITE(e_steps < 0 ? INVERT_E## INDEX ##_DIR : !INVERT_E## INDEX ##_DIR)
|
|
768
|
+ #define SET_E_STEP_DIR(INDEX) do{ if (e_steps) E## INDEX ##_DIR_WRITE(e_steps < 0 ? INVERT_E## INDEX ##_DIR : !INVERT_E## INDEX ##_DIR); }while(0)
|
765
|
769
|
#endif
|
766
|
770
|
|
767
|
|
- #define START_E_PULSE(INDEX) \
|
768
|
|
- if (e_steps) E## INDEX ##_STEP_WRITE(!INVERT_E_STEP_PIN)
|
769
|
|
-
|
770
|
|
- #define STOP_E_PULSE(INDEX) \
|
771
|
|
- if (e_steps) { \
|
772
|
|
- e_steps < 0 ? ++e_steps : --e_steps; \
|
773
|
|
- E## INDEX ##_STEP_WRITE(INVERT_E_STEP_PIN); \
|
774
|
|
- }
|
|
771
|
+ #if ENABLED(DUAL_X_CARRIAGE) || ENABLED(DUAL_NOZZLE_DUPLICATION_MODE)
|
|
772
|
+ #define START_E_PULSE(INDEX) do{ if (e_steps) E_STEP_WRITE(!INVERT_E_STEP_PIN); }while(0)
|
|
773
|
+ #define STOP_E_PULSE(INDEX) do{ if (e_steps) { E_STEP_WRITE(INVERT_E_STEP_PIN); e_steps < 0 ? ++e_steps : --e_steps; } }while(0)
|
|
774
|
+ #else
|
|
775
|
+ #define START_E_PULSE(INDEX) do{ if (e_steps) E## INDEX ##_STEP_WRITE(!INVERT_E_STEP_PIN); }while(0)
|
|
776
|
+ #define STOP_E_PULSE(INDEX) do { if (e_steps) { E## INDEX ##_STEP_WRITE(INVERT_E_STEP_PIN); e_steps < 0 ? ++e_steps : --e_steps; } }while(0)
|
|
777
|
+ #endif
|
775
|
778
|
|
776
|
779
|
if (current_block->use_advance_lead) {
|
777
|
780
|
if (step_events_completed > LA_decelerate_after && current_adv_steps > final_adv_steps) {
|
|
@@ -793,7 +796,7 @@ void Stepper::isr() {
|
793
|
796
|
else
|
794
|
797
|
nextAdvanceISR = ADV_NEVER;
|
795
|
798
|
|
796
|
|
- switch(LA_active_extruder) {
|
|
799
|
+ switch (LA_active_extruder) {
|
797
|
800
|
case 0: SET_E_STEP_DIR(0); break;
|
798
|
801
|
#if EXTRUDERS > 1
|
799
|
802
|
case 1: SET_E_STEP_DIR(1); break;
|
|
@@ -816,7 +819,7 @@ void Stepper::isr() {
|
816
|
819
|
hal_timer_t pulse_start = HAL_timer_get_count(PULSE_TIMER_NUM);
|
817
|
820
|
#endif
|
818
|
821
|
|
819
|
|
- switch(LA_active_extruder) {
|
|
822
|
+ switch (LA_active_extruder) {
|
820
|
823
|
case 0: START_E_PULSE(0); break;
|
821
|
824
|
#if EXTRUDERS > 1
|
822
|
825
|
case 1: START_E_PULSE(1); break;
|
|
@@ -840,7 +843,7 @@ void Stepper::isr() {
|
840
|
843
|
DELAY_NOPS(EXTRA_CYCLES_E);
|
841
|
844
|
#endif
|
842
|
845
|
|
843
|
|
- switch(LA_active_extruder) {
|
|
846
|
+ switch (LA_active_extruder) {
|
844
|
847
|
case 0: STOP_E_PULSE(0); break;
|
845
|
848
|
#if EXTRUDERS > 1
|
846
|
849
|
case 1: STOP_E_PULSE(1); break;
|