️ Use cached la_active state

Co-Authored-By: tombrazier <68918209+tombrazier@users.noreply.github.com>
This commit is contained in:
Scott Lahteine 2023-03-11 19:19:36 -06:00
parent 194f58740a
commit d554844a51
2 changed files with 9 additions and 6 deletions

View file

@ -230,6 +230,7 @@ uint32_t Stepper::advance_divisor = 0,
int32_t Stepper::la_delta_error = 0,
Stepper::la_dividend = 0,
Stepper::la_advance_steps = 0;
bool Stepper::la_active = false;
#endif
#if HAS_SHAPING
@ -1868,7 +1869,7 @@ void Stepper::pulse_phase_isr() {
PULSE_PREP(E);
#if ENABLED(LIN_ADVANCE)
if (step_needed.e && current_block->la_advance_rate) {
if (la_active && step_needed.e) {
// don't actually step here, but do subtract movements steps
// from the linear advance step count
step_needed.e = false;
@ -2170,7 +2171,7 @@ hal_timer_t Stepper::block_phase_isr() {
acceleration_time += interval;
#if ENABLED(LIN_ADVANCE)
if (current_block->la_advance_rate) {
if (la_active) {
const uint32_t la_step_rate = la_advance_steps < current_block->max_adv_steps ? current_block->la_advance_rate : 0;
la_interval = calc_timer_interval(acc_step_rate + la_step_rate) << current_block->la_scaling;
}
@ -2240,7 +2241,7 @@ hal_timer_t Stepper::block_phase_isr() {
deceleration_time += interval;
#if ENABLED(LIN_ADVANCE)
if (current_block->la_advance_rate) {
if (la_active) {
const uint32_t la_step_rate = la_advance_steps > current_block->final_adv_steps ? current_block->la_advance_rate : 0;
if (la_step_rate != step_rate) {
bool reverse_e = la_step_rate > step_rate;
@ -2301,7 +2302,7 @@ hal_timer_t Stepper::block_phase_isr() {
ticks_nominal = calc_timer_interval(current_block->nominal_rate << oversampling_factor, steps_per_isr);
#if ENABLED(LIN_ADVANCE)
if (current_block->la_advance_rate)
if (la_active)
la_interval = calc_timer_interval(current_block->nominal_rate) << current_block->la_scaling;
#endif
}
@ -2556,11 +2557,12 @@ hal_timer_t Stepper::block_phase_isr() {
// Initialize the trapezoid generator from the current block.
#if ENABLED(LIN_ADVANCE)
la_active = (current_block->la_advance_rate != 0);
#if DISABLED(MIXING_EXTRUDER) && E_STEPPERS > 1
// If the now active extruder wasn't in use during the last move, its pressure is most likely gone.
if (stepper_extruder != last_moved_extruder) la_advance_steps = 0;
#endif
if (current_block->la_advance_rate) {
if (la_active) {
// Apply LA scaling and discount the effect of frequency scaling
la_dividend = (advance_dividend.e << current_block->la_scaling) << oversampling_factor;
}
@ -2621,7 +2623,7 @@ hal_timer_t Stepper::block_phase_isr() {
acceleration_time += interval;
#if ENABLED(LIN_ADVANCE)
if (current_block->la_advance_rate) {
if (la_active) {
const uint32_t la_step_rate = la_advance_steps < current_block->max_adv_steps ? current_block->la_advance_rate : 0;
la_interval = calc_timer_interval(current_block->initial_rate + la_step_rate) << current_block->la_scaling;
}

View file

@ -574,6 +574,7 @@ class Stepper {
static int32_t la_delta_error, // Analogue of delta_error.e for E steps in LA ISR
la_dividend, // Analogue of advance_dividend.e for E steps in LA ISR
la_advance_steps; // Count of steps added to increase nozzle pressure
static bool la_active; // Whether linear advance is used on the present segment.
#endif
#if ENABLED(INTEGRATED_BABYSTEPPING)