polar: Implement bed angle wrapping adjustments in chelper code

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-10-27 11:14:40 -04:00
parent 92993c062b
commit 374eb98765
4 changed files with 19 additions and 10 deletions

View file

@ -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;
}