diff options
Diffstat (limited to 'klippy/chelper/kin_shaper.c')
-rw-r--r-- | klippy/chelper/kin_shaper.c | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/klippy/chelper/kin_shaper.c b/klippy/chelper/kin_shaper.c index acdd1ccc..42d572d0 100644 --- a/klippy/chelper/kin_shaper.c +++ b/klippy/chelper/kin_shaper.c @@ -166,6 +166,38 @@ shaper_commanded_pos_post_fixup(struct stepper_kinematics *sk) sk->commanded_pos = is->orig_sk->commanded_pos; } +static void +shaper_note_generation_time(struct input_shaper *is) +{ + double pre_active = 0., post_active = 0.; + if ((is->sk.active_flags & AF_X) && is->sx.num_pulses) { + pre_active = is->sx.pulses[is->sx.num_pulses-1].t; + post_active = -is->sx.pulses[0].t; + } + if ((is->sk.active_flags & AF_Y) && is->sy.num_pulses) { + pre_active = is->sy.pulses[is->sy.num_pulses-1].t > pre_active + ? is->sy.pulses[is->sy.num_pulses-1].t : pre_active; + post_active = -is->sy.pulses[0].t > post_active + ? -is->sy.pulses[0].t : post_active; + } + is->sk.gen_steps_pre_active = pre_active; + is->sk.gen_steps_post_active = post_active; +} + +void __visible +input_shaper_update_sk(struct stepper_kinematics *sk) +{ + struct input_shaper *is = container_of(sk, struct input_shaper, sk); + if ((is->orig_sk->active_flags & (AF_X | AF_Y)) == (AF_X | AF_Y)) + is->sk.calc_position_cb = shaper_xy_calc_position; + else if (is->orig_sk->active_flags & AF_X) + is->sk.calc_position_cb = shaper_x_calc_position; + else if (is->orig_sk->active_flags & AF_Y) + is->sk.calc_position_cb = shaper_y_calc_position; + is->sk.active_flags = is->orig_sk->active_flags; + shaper_note_generation_time(is); +} + int __visible input_shaper_set_sk(struct stepper_kinematics *sk , struct stepper_kinematics *orig_sk) @@ -190,24 +222,6 @@ input_shaper_set_sk(struct stepper_kinematics *sk return 0; } -static void -shaper_note_generation_time(struct input_shaper *is) -{ - double pre_active = 0., post_active = 0.; - if ((is->sk.active_flags & AF_X) && is->sx.num_pulses) { - pre_active = is->sx.pulses[is->sx.num_pulses-1].t; - post_active = -is->sx.pulses[0].t; - } - if ((is->sk.active_flags & AF_Y) && is->sy.num_pulses) { - pre_active = is->sy.pulses[is->sy.num_pulses-1].t > pre_active - ? is->sy.pulses[is->sy.num_pulses-1].t : pre_active; - post_active = -is->sy.pulses[0].t > post_active - ? -is->sy.pulses[0].t : post_active; - } - is->sk.gen_steps_pre_active = pre_active; - is->sk.gen_steps_post_active = post_active; -} - int __visible input_shaper_set_shaper_params(struct stepper_kinematics *sk, char axis , int n, double a[], double t[]) |