From 73aa7ffff9d5cc6575696b3f4314368b2f7166aa Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 6 Mar 2018 19:20:15 -0600 Subject: [PATCH] LIN_ADVANCE single stepper optimization --- Marlin/stepper.cpp | 9 +++++++-- Marlin/stepper.h | 21 ++++++++++++--------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 336a7ca20d..21b7920999 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -111,8 +111,13 @@ volatile uint32_t Stepper::step_events_completed = 0; // The number of step even Stepper::final_adv_steps, Stepper::max_adv_steps; - int8_t Stepper::e_steps = 0, - Stepper::LA_active_extruder; // Copy from current executed block. Needed because current_block is set to NULL "too early". + int8_t Stepper::e_steps = 0; + + #if E_STEPPERS > 1 + int8_t Stepper::LA_active_extruder; // Copy from current executed block. Needed because current_block is set to NULL "too early". + #else + constexpr int8_t Stepper::LA_active_extruder; + #endif bool Stepper::use_advance_lead; diff --git a/Marlin/stepper.h b/Marlin/stepper.h index 05610ee16a..7e9e1b0522 100644 --- a/Marlin/stepper.h +++ b/Marlin/stepper.h @@ -128,8 +128,12 @@ class Stepper { final_adv_steps, max_adv_steps; // Copy from current executed block. Needed because current_block is set to NULL "too early". #define _NEXT_ISR(T) nextMainISR = T static int8_t e_steps; - static int8_t LA_active_extruder; // Copy from current executed block. Needed because current_block is set to NULL "too early". static bool use_advance_lead; + #if E_STEPPERS > 1 + static int8_t LA_active_extruder; // Copy from current executed block. Needed because current_block is set to NULL "too early". + #else + constexpr int8_t LA_active_extruder = 0; + #endif #else // !LIN_ADVANCE @@ -349,19 +353,18 @@ class Stepper { static int8_t last_extruder = -1; #if ENABLED(LIN_ADVANCE) - if (current_block->active_extruder != last_extruder) { - current_adv_steps = 0; // If the now active extruder wasn't in use during the last move, its pressure is most likely gone. - LA_active_extruder = current_block->active_extruder; - } + #if E_STEPPERS > 1 + if (current_block->active_extruder != last_extruder) { + current_adv_steps = 0; // If the now active extruder wasn't in use during the last move, its pressure is most likely gone. + LA_active_extruder = current_block->active_extruder; + } + #endif - if (current_block->use_advance_lead) { + if ((use_advance_lead = current_block->use_advance_lead)) { LA_decelerate_after = current_block->decelerate_after; final_adv_steps = current_block->final_adv_steps; max_adv_steps = current_block->max_adv_steps; - use_advance_lead = true; } - else - use_advance_lead = false; #endif if (current_block->direction_bits != last_direction_bits || current_block->active_extruder != last_extruder) {