Browse Source

Reset LA_phase at each trapezoid stage

There used to be a single stage where an extruder reversal could occur,
but since PR #2591 reversals can happen up to two times per trapezoid.

Reset LA_phase when ADV_INIT is set, since it is re-inizialized only
when needed a few lines afterward. This improves performance by avoiding
to check the phase continuosly to the end of the trapezoid.

Likewise, always set ADV_INIT during the first cruising step, also to
force a LA_phase reset.
Yuri D'Elia 4 years ago
parent
commit
51a539608c
1 changed files with 5 additions and 6 deletions
  1. 5 6
      Firmware/stepper.cpp

+ 5 - 6
Firmware/stepper.cpp

@@ -848,12 +848,10 @@ FORCE_INLINE void isr() {
 
 #ifdef LIN_ADVANCE
           if(current_block->use_advance_lead) {
-              if (!nextAdvanceISR) {
-                  // Due to E-jerk, there can be discontinuities in pressure state where an
-                  // acceleration or deceleration can be skipped or joined with the previous block.
-                  // If LA was not previously active, re-check the pressure level
-                  la_state = ADV_INIT;
-              }
+              // Due to E-jerk, there can be discontinuities in pressure state where an
+              // acceleration or deceleration can be skipped or joined with the previous block.
+              // If LA was not previously active, re-check the pressure level
+              la_state = ADV_INIT;
           }
 #endif
         }
@@ -865,6 +863,7 @@ FORCE_INLINE void isr() {
 #ifdef LIN_ADVANCE
     // avoid multiple instances or function calls to advance_spread
     if (la_state & ADV_INIT) {
+        LA_phase = -1;
         if (current_adv_steps == target_adv_steps) {
             // nothing to be done in this phase
             la_state = 0;