From fc4a9e7564a51ab5275826f2a2398335ff9acc9a Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sat, 9 Jun 2018 14:30:22 -0400 Subject: corexy: Convert corexy to use the iterative solver Signed-off-by: Kevin O'Connor --- klippy/chelper/kin_corexy.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 klippy/chelper/kin_corexy.c (limited to 'klippy/chelper/kin_corexy.c') diff --git a/klippy/chelper/kin_corexy.c b/klippy/chelper/kin_corexy.c new file mode 100644 index 00000000..2a097d91 --- /dev/null +++ b/klippy/chelper/kin_corexy.c @@ -0,0 +1,38 @@ +// CoreXY kinematics stepper pulse time generation +// +// Copyright (C) 2018 Kevin O'Connor +// +// This file may be distributed under the terms of the GNU GPLv3 license. + +#include // malloc +#include // memset +#include "compiler.h" // __visible +#include "itersolve.h" // struct stepper_kinematics + +static double +corexy_stepper_plus_calc_position(struct stepper_kinematics *sk, struct move *m + , double move_time) +{ + struct coord c = move_get_coord(m, move_time); + return c.x + c.y; +} + +static double +corexy_stepper_minus_calc_position(struct stepper_kinematics *sk, struct move *m + , double move_time) +{ + struct coord c = move_get_coord(m, move_time); + return c.x - c.y; +} + +struct stepper_kinematics * __visible +corexy_stepper_alloc(char type) +{ + struct stepper_kinematics *sk = malloc(sizeof(*sk)); + memset(sk, 0, sizeof(*sk)); + if (type == '+') + sk->calc_position = corexy_stepper_plus_calc_position; + else if (type == '-') + sk->calc_position = corexy_stepper_minus_calc_position; + return sk; +} -- cgit v1.2.3-70-g09d2