Skip to content

Commit ede9bae

Browse files
committed
Fixed some errors around IS being disabled for specific axes
1 parent c87be2e commit ede9bae

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

Marlin/Configuration_adv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@
10771077
* X<1> Set the given parameters only for the X axis.
10781078
* Y<1> Set the given parameters only for the Y axis.
10791079
*/
1080-
//#define INPUT_SHAPING
1080+
#define INPUT_SHAPING
10811081
#if ENABLED(INPUT_SHAPING)
10821082
#define SHAPING_FREQ_X 40 // (Hz) The dominant resonant frequency of the X axis.
10831083
#define SHAPING_FREQ_Y 40 // (Hz) The dominant resonant frequency of the Y axis.

Marlin/src/module/stepper.cpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2503,14 +2503,15 @@ uint32_t Stepper::block_phase_isr() {
25032503
advance_divisor = step_event_count << 1;
25042504

25052505
#if HAS_SHAPING_X
2506-
int32_t echo_x;
2506+
int32_t echo_x = 0;
25072507
#endif
25082508
#if HAS_SHAPING_Y
2509-
int32_t echo_y;
2509+
int32_t echo_y = 0;
25102510
#endif
25112511

25122512
if (TERN0(HAS_SHAPING_X, shaping_x.frequency)) {
25132513
const int64_t steps = TEST(current_block->direction_bits, X_AXIS) ? -int64_t(current_block->steps.x) : int64_t(current_block->steps.x);
2514+
UNUSED(steps);
25142515
TERN_(HAS_SHAPING_X, shaping_x.last_block_end_pos += steps);
25152516

25162517
// For input shaped axes, advance_divisor is replaced with 0x20000000
@@ -2547,6 +2548,7 @@ uint32_t Stepper::block_phase_isr() {
25472548
// Y follows the same logic as X (but the comments aren't repeated)
25482549
if (TERN0(HAS_SHAPING_Y, shaping_y.frequency)) {
25492550
const int64_t steps = TEST(current_block->direction_bits, Y_AXIS) ? -int64_t(current_block->steps.y) : int64_t(current_block->steps.y);
2551+
UNUSED(steps);
25502552
TERN_(HAS_SHAPING_Y, shaping_y.last_block_end_pos += steps);
25512553
TERN_(HAS_SHAPING_Y, advance_dividend.y = ((steps << 29) + shaping_y.remainder) / step_event_count);
25522554
TERN_(HAS_SHAPING_Y, LIMIT(advance_dividend.y, -0x20000000, 0x20000000));
@@ -2557,7 +2559,8 @@ uint32_t Stepper::block_phase_isr() {
25572559
}
25582560

25592561
// plan the change of values for advance_dividend for the input shaping echoes
2560-
TERN_(INPUT_SHAPING, shaping_dividend_queue.enqueue(TERN0(HAS_SHAPING_X, echo_x), TERN0(HAS_SHAPING_Y, echo_y)));
2562+
if (TERN0(HAS_SHAPING_X, shaping_x.frequency) || TERN0(HAS_SHAPING_Y, shaping_y.frequency))
2563+
TERN_(INPUT_SHAPING, shaping_dividend_queue.enqueue(TERN0(HAS_SHAPING_X, echo_x), TERN0(HAS_SHAPING_Y, echo_y)));
25612564

25622565
// No step events completed so far
25632566
step_events_completed = 0;
@@ -3048,10 +3051,16 @@ void Stepper::init() {
30483051
if (TERN0(HAS_SHAPING_X, axis == X_AXIS)) {
30493052
DelayTimeManager::set_delay(X_AXIS, delay);
30503053
TERN_(HAS_SHAPING_X, shaping_x.frequency = freq);
3054+
delta_error = 0L;
3055+
shaping_x.last_block_end_pos = count_position.x;
3056+
shaping_x.dividend = shaping_x.remainder = 0UL;
30513057
}
30523058
if (TERN0(HAS_SHAPING_Y, axis == Y_AXIS)) {
30533059
DelayTimeManager::set_delay(Y_AXIS, delay);
30543060
TERN_(HAS_SHAPING_Y, shaping_y.frequency = freq);
3061+
delta_error = 0L;
3062+
shaping_y.last_block_end_pos = count_position.y;
3063+
shaping_y.dividend = shaping_y.remainder = 0UL;
30553064
}
30563065

30573066
if (was_on) hal.isr_on();
@@ -3111,10 +3120,14 @@ void Stepper::_set_position(const abce_long_t &spos) {
31113120
count_position = spos;
31123121
#endif
31133122

3114-
TERN_(HAS_SHAPING_X, count_position.x += x_shaping_delta);
3115-
TERN_(HAS_SHAPING_X, shaping_x.last_block_end_pos = spos.x);
3116-
TERN_(HAS_SHAPING_Y, count_position.y += y_shaping_delta);
3117-
TERN_(HAS_SHAPING_Y, shaping_y.last_block_end_pos = spos.y);
3123+
if (TERN0(HAS_SHAPING_X, shaping_x.frequency)) {
3124+
TERN_(HAS_SHAPING_X, count_position.x += x_shaping_delta);
3125+
TERN_(HAS_SHAPING_X, shaping_x.last_block_end_pos = spos.x);
3126+
}
3127+
if (TERN0(HAS_SHAPING_Y, shaping_y.frequency)) {
3128+
TERN_(HAS_SHAPING_Y, count_position.y += y_shaping_delta);
3129+
TERN_(HAS_SHAPING_Y, shaping_y.last_block_end_pos = spos.y);
3130+
}
31183131
}
31193132

31203133
/**

Marlin/src/module/stepper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ class Stepper {
633633
const bool was_on = hal.isr_state();
634634
hal.isr_off();
635635

636-
const bool result = !shaping_queue.empty_x() || !shaping_queue.empty_y();
636+
const bool result = TERN0(HAS_SHAPING_X, !shaping_queue.empty_x()) || TERN0(HAS_SHAPING_Y, !shaping_queue.empty_y());
637637

638638
if (was_on) hal.isr_on();
639639

0 commit comments

Comments
 (0)