aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/chelper/kin_polar.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-10-27 11:14:40 -0400
committerKevin O'Connor <kevin@koconnor.net>2019-11-06 15:51:51 -0500
commit374eb9876565272c041e1d6950e7547d0604dffa (patch)
tree6ea4be0fac8b22ba013b7e45999b597e30e91794 /klippy/chelper/kin_polar.c
parent92993c062b4c70e4e97cecdfb2b43b8c0bbef96c (diff)
downloadkutter-374eb9876565272c041e1d6950e7547d0604dffa.tar.gz
kutter-374eb9876565272c041e1d6950e7547d0604dffa.tar.xz
kutter-374eb9876565272c041e1d6950e7547d0604dffa.zip
polar: Implement bed angle wrapping adjustments in chelper code
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/chelper/kin_polar.c')
-rw-r--r--klippy/chelper/kin_polar.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/klippy/chelper/kin_polar.c b/klippy/chelper/kin_polar.c
index bba5546a..77755d70 100644
--- a/klippy/chelper/kin_polar.c
+++ b/klippy/chelper/kin_polar.c
@@ -32,14 +32,26 @@ polar_stepper_angle_calc_position(struct stepper_kinematics *sk, struct move *m
return angle;
}
+static void
+polar_stepper_angle_post_fixup(struct stepper_kinematics *sk)
+{
+ // Normalize the stepper_bed angle
+ if (sk->commanded_pos < -M_PI)
+ sk->commanded_pos += 2 * M_PI;
+ else if (sk->commanded_pos > M_PI)
+ sk->commanded_pos -= 2 * M_PI;
+}
+
struct stepper_kinematics * __visible
polar_stepper_alloc(char type)
{
struct stepper_kinematics *sk = malloc(sizeof(*sk));
memset(sk, 0, sizeof(*sk));
- if (type == 'r')
+ if (type == 'r') {
sk->calc_position_cb = polar_stepper_radius_calc_position;
- else if (type == 'a')
+ } else if (type == 'a') {
sk->calc_position_cb = polar_stepper_angle_calc_position;
+ sk->post_cb = polar_stepper_angle_post_fixup;
+ }
return sk;
}