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.
This commit is contained in:
Yuri D'Elia 2020-06-22 00:19:47 +02:00
parent 7c140bc497
commit 51a539608c

View File

@ -848,13 +848,11 @@ 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;
}
}
#endif
}
_NEXT_ISR(OCR1A_nominal);
@ -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;