Avoid scheduling useless eISR ticks

When switching to a new trapezoid step with the right pressure, cancel
any pending eISR right away.

Similarly do not schedule another eISR if the pressure will be reached
by the end of the eISR.

This was done in the past to preserve the current LA_phase. This is not
needed anymore, since it will be reset at each trapezoid step when LA
is re-initialized.
This commit is contained in:
Yuri D'Elia 2020-06-23 15:20:46 +02:00
parent 1206fc3164
commit 50a09824fd

View File

@ -864,9 +864,11 @@ FORCE_INLINE void isr() {
// avoid multiple instances or function calls to advance_spread // avoid multiple instances or function calls to advance_spread
if (la_state & ADV_INIT) { if (la_state & ADV_INIT) {
LA_phase = -1; LA_phase = -1;
if (current_adv_steps == target_adv_steps) { if (current_adv_steps == target_adv_steps) {
// nothing to be done in this phase // nothing to be done in this phase, cancel any pending eisr
la_state = 0; la_state = 0;
nextAdvanceISR = ADV_NEVER;
} }
else { else {
eISR_Err = current_block->advance_rate / 4; eISR_Err = current_block->advance_rate / 4;
@ -933,20 +935,21 @@ FORCE_INLINE void advance_isr() {
current_adv_steps -= e_step_loops; current_adv_steps -= e_step_loops;
else else
current_adv_steps = 0; current_adv_steps = 0;
nextAdvanceISR = eISR_Rate;
} }
else if (current_adv_steps < target_adv_steps) { else if (current_adv_steps < target_adv_steps) {
// compression // compression
e_steps += e_step_loops; e_steps += e_step_loops;
if (e_steps) WRITE_NC(E0_DIR_PIN, e_steps < 0? INVERT_E0_DIR: !INVERT_E0_DIR); if (e_steps) WRITE_NC(E0_DIR_PIN, e_steps < 0? INVERT_E0_DIR: !INVERT_E0_DIR);
current_adv_steps += e_step_loops; current_adv_steps += e_step_loops;
nextAdvanceISR = eISR_Rate;
} }
else {
if (current_adv_steps == target_adv_steps) {
// advance steps completed // advance steps completed
nextAdvanceISR = ADV_NEVER; nextAdvanceISR = ADV_NEVER;
LA_phase = -1; }
e_step_loops = 1; else {
// schedule another tick
nextAdvanceISR = eISR_Rate;
} }
} }