diff options
Diffstat (limited to 'klippy/chelper/kin_polar.c')
-rw-r--r-- | klippy/chelper/kin_polar.c | 16 |
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; } |