diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 1f2111833ab7e..aaafad6f98b05 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -1075,9 +1075,9 @@ #undef SHAPING_BUFFER_Y #endif #if SHAPING_FREQ_X && SHAPING_BUFFER_X - #define INPUT_SHAPING_X 1 + #define HAS_SHAPING_X 1 #endif #if SHAPING_FREQ_Y && SHAPING_BUFFER_Y - #define INPUT_SHAPING_Y 1 + #define HAS_SHAPING_Y 1 #endif #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 5453f78e4c331..6832168dd7bc7 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -4205,13 +4205,13 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); // Check requirements for Input Shaping #if ENABLED(INPUT_SHAPING) && defined(__AVR__) - #if INPUT_SHAPING_X && (SHAPING_FREQ_X) * 2 * 0x10000 < (STEPPER_TIMER_RATE) + #if HAS_SHAPING_X && (SHAPING_FREQ_X) * 2 * 0x10000 < (STEPPER_TIMER_RATE) #if F_CPU > 16000000 #error "SHAPING_FREQ_X is below the minimum (20) for AVR 20MHz." #else #error "SHAPING_FREQ_X is below the minimum (16) for AVR 16MHz." #endif - #elif INPUT_SHAPING_Y && (SHAPING_FREQ_Y) * 2 * 0x10000 < (STEPPER_TIMER_RATE) + #elif HAS_SHAPING_Y && (SHAPING_FREQ_Y) * 2 * 0x10000 < (STEPPER_TIMER_RATE) #if F_CPU > 16000000 #error "SHAPING_FREQ_Y is below the minimum (20) for AVR 20MHz." #else diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 880f2ee02ef37..cc86dd90c566f 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -232,10 +232,10 @@ uint32_t Stepper::advance_divisor = 0, Stepper::la_advance_steps = 0; #endif -#if INPUT_SHAPING_X +#if HAS_SHAPING_X DelayQueue Stepper::shaping_queue_x; #endif -#if INPUT_SHAPING_Y +#if HAS_SHAPING_Y DelayQueue Stepper::shaping_queue_y; #endif @@ -1476,8 +1476,8 @@ void Stepper::isr() { if (!nextMainISR) pulse_phase_isr(); // 0 = Do coordinated axes Stepper pulses - TERN_(INPUT_SHAPING_X, if (!shaping_queue_x.peek()) shaping_isr_x()); - TERN_(INPUT_SHAPING_Y, if (!shaping_queue_y.peek()) shaping_isr_y()); + TERN_(HAS_SHAPING_X, if (!shaping_queue_x.peek()) shaping_isr_x()); + TERN_(HAS_SHAPING_Y, if (!shaping_queue_y.peek()) shaping_isr_y()); #if ENABLED(LIN_ADVANCE) if (!nextAdvanceISR) { // 0 = Do Linear Advance E Stepper pulses @@ -1509,8 +1509,8 @@ void Stepper::isr() { const uint32_t interval = _MIN( uint32_t(HAL_TIMER_TYPE_MAX), // Come back in a very long time nextMainISR // Time until the next Pulse / Block phase - OPTARG(INPUT_SHAPING_X, shaping_queue_x.peek()) // Time until next input shaping echo for X - OPTARG(INPUT_SHAPING_Y, shaping_queue_y.peek()) // Time until next input shaping echo for Y + OPTARG(HAS_SHAPING_X, shaping_queue_x.peek()) // Time until next input shaping echo for X + OPTARG(HAS_SHAPING_Y, shaping_queue_y.peek()) // Time until next input shaping echo for Y OPTARG(LIN_ADVANCE, nextAdvanceISR) // Come back early for Linear Advance? OPTARG(INTEGRATED_BABYSTEPPING, nextBabystepISR) // Come back early for Babystepping? ); @@ -1523,8 +1523,8 @@ void Stepper::isr() { // nextMainISR -= interval; - TERN_(INPUT_SHAPING_X, shaping_queue_x.decrement_delays(interval)); - TERN_(INPUT_SHAPING_Y, shaping_queue_y.decrement_delays(interval)); + TERN_(HAS_SHAPING_X, shaping_queue_x.decrement_delays(interval)); + TERN_(HAS_SHAPING_Y, shaping_queue_y.decrement_delays(interval)); #if ENABLED(LIN_ADVANCE) if (nextAdvanceISR != LA_ADV_NEVER) nextAdvanceISR -= interval; @@ -1788,15 +1788,15 @@ void Stepper::pulse_phase_isr() { #endif // DIRECT_STEPPING if (!is_page) { - TERN_(INPUT_SHAPING_X, shaping_queue_x.enqueue(shaping_delay_x)); - TERN_(INPUT_SHAPING_Y, shaping_queue_y.enqueue(shaping_delay_y)); + TERN_(HAS_SHAPING_X, shaping_queue_x.enqueue(shaping_delay_x)); + TERN_(HAS_SHAPING_Y, shaping_queue_y.enqueue(shaping_delay_y)); // Determine if pulses are needed #if HAS_X_STEP - TERN(INPUT_SHAPING_X, PULSE_PREP_INPUT_SHAPING(X), PULSE_PREP(X)); + TERN(HAS_SHAPING_X, PULSE_PREP_INPUT_SHAPING(X), PULSE_PREP(X)); #endif #if HAS_Y_STEP - TERN(INPUT_SHAPING_Y, PULSE_PREP_INPUT_SHAPING(Y), PULSE_PREP(Y)); + TERN(HAS_SHAPING_Y, PULSE_PREP_INPUT_SHAPING(Y), PULSE_PREP(Y)); #endif #if HAS_Z_STEP PULSE_PREP(Z); @@ -1927,7 +1927,7 @@ void Stepper::pulse_phase_isr() { } while (--events_to_do); } -#if INPUT_SHAPING_X +#if HAS_SHAPING_X void Stepper::shaping_isr_x() { shaping_queue_x.dequeue(); @@ -1948,7 +1948,7 @@ void Stepper::pulse_phase_isr() { } #endif -#if INPUT_SHAPING_Y +#if HAS_SHAPING_Y void Stepper::shaping_isr_y() { shaping_queue_y.dequeue(); @@ -2046,10 +2046,10 @@ uint32_t Stepper::block_phase_isr() { // If current block is finished, reset pointer and finalize state if (step_events_completed >= step_event_count) { // Only end block when input shaping echoes are complete and idle in the meantime - if (TERN0(INPUT_SHAPING_X, !shaping_queue_x.empty()) || TERN0(INPUT_SHAPING_Y, !shaping_queue_y.empty())) { + if (TERN0(HAS_SHAPING_X, !shaping_queue_x.empty()) || TERN0(HAS_SHAPING_Y, !shaping_queue_y.empty())) { interval = 0; - TERN_(INPUT_SHAPING_X, NOLESS(interval, shaping_queue_x.peek_tail() + 1)); - TERN_(INPUT_SHAPING_Y, NOLESS(interval, shaping_queue_y.peek_tail() + 1)); + TERN_(HAS_SHAPING_X, NOLESS(interval, shaping_queue_x.peek_tail() + 1)); + TERN_(HAS_SHAPING_Y, NOLESS(interval, shaping_queue_y.peek_tail() + 1)); } else { #if ENABLED(DIRECT_STEPPING) @@ -2449,13 +2449,13 @@ uint32_t Stepper::block_phase_isr() { // for input shaped axes, advance_divisor is replaced with 0x40000000 // and steps are repeated twice so dividends have to be scaled and halved - TERN_(INPUT_SHAPING_X, delta_error.x = 0); - TERN_(INPUT_SHAPING_Y, delta_error.y = 0); - TERN_(INPUT_SHAPING_X, advance_dividend.x = (uint64_t(current_block->steps.x) << 29) / step_event_count); - TERN_(INPUT_SHAPING_Y, advance_dividend.y = (uint64_t(current_block->steps.y) << 29) / step_event_count); + TERN_(HAS_SHAPING_X, delta_error.x = 0); + TERN_(HAS_SHAPING_Y, delta_error.y = 0); + TERN_(HAS_SHAPING_X, advance_dividend.x = (uint64_t(current_block->steps.x) << 29) / step_event_count); + TERN_(HAS_SHAPING_Y, advance_dividend.y = (uint64_t(current_block->steps.y) << 29) / step_event_count); // finally, the scaling operation above introduces rounding errors which must now be removed - TERN_(INPUT_SHAPING_X, delta_error.x += (0x40000000L - advance_dividend.x * step_event_count) & 0x3FFFFFFFUL); - TERN_(INPUT_SHAPING_Y, delta_error.y += (0x40000000L - advance_dividend.y * step_event_count) & 0x3FFFFFFFUL); + TERN_(HAS_SHAPING_X, delta_error.x += (0x40000000L - advance_dividend.x * step_event_count) & 0x3FFFFFFFUL); + TERN_(HAS_SHAPING_Y, delta_error.y += (0x40000000L - advance_dividend.y * step_event_count) & 0x3FFFFFFFUL); // No step events completed so far step_events_completed = 0; diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index fc6dbca79dca1..4fcdccbf51e3f 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -447,11 +447,11 @@ class Stepper { #endif #if ENABLED(INPUT_SHAPING) - #if INPUT_SHAPING_X + #if HAS_SHAPING_X static DelayQueue shaping_queue_x; static constexpr shaping_time_t shaping_delay_x = uint32_t(STEPPER_TIMER_RATE) / (SHAPING_FREQ_X) / 2; #endif - #if INPUT_SHAPING_Y + #if HAS_SHAPING_Y static DelayQueue shaping_queue_y; static constexpr shaping_time_t shaping_delay_y = uint32_t(STEPPER_TIMER_RATE) / (SHAPING_FREQ_Y) / 2; #endif @@ -516,10 +516,10 @@ class Stepper { // The stepper block processing ISR phase static uint32_t block_phase_isr(); - #if INPUT_SHAPING_X + #if HAS_SHAPING_X static void shaping_isr_x(); #endif - #if INPUT_SHAPING_Y + #if HAS_SHAPING_Y static void shaping_isr_y(); #endif @@ -562,8 +562,8 @@ class Stepper { axis_did_move = 0; planner.release_current_block(); TERN_(LIN_ADVANCE, la_interval = nextAdvanceISR = LA_ADV_NEVER); - TERN_(INPUT_SHAPING_X, shaping_queue_x.purge()); - TERN_(INPUT_SHAPING_Y, shaping_queue_y.purge()); + TERN_(HAS_SHAPING_X, shaping_queue_x.purge()); + TERN_(HAS_SHAPING_Y, shaping_queue_y.purge()); } // Quickly stop all steppers