aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/chelper/kin_shaper.c
diff options
context:
space:
mode:
authorDmitry Butyugin <dmbutyugin@google.com>2025-05-23 01:44:47 +0200
committerKevinOConnor <kevin@koconnor.net>2025-06-04 13:40:58 -0400
commit4d4b9684a53fa7e776914b222cdab21f870dad76 (patch)
tree1293fe6e5bbc52d01d502cdbfff625a5821e0e7d /klippy/chelper/kin_shaper.c
parent14cbb8dd2db14a473fe0a01c626d9bbecc420144 (diff)
downloadkutter-4d4b9684a53fa7e776914b222cdab21f870dad76.tar.gz
kutter-4d4b9684a53fa7e776914b222cdab21f870dad76.tar.xz
kutter-4d4b9684a53fa7e776914b222cdab21f870dad76.zip
input_shaper: Track kinematics updates by dual_carriage
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
Diffstat (limited to 'klippy/chelper/kin_shaper.c')
-rw-r--r--klippy/chelper/kin_shaper.c50
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[])