2018-06-09 20:30:22 +02:00
|
|
|
// CoreXY kinematics stepper pulse time generation
|
|
|
|
//
|
2019-10-29 03:59:07 +01:00
|
|
|
// Copyright (C) 2018-2019 Kevin O'Connor <kevin@koconnor.net>
|
2018-06-09 20:30:22 +02:00
|
|
|
//
|
|
|
|
// This file may be distributed under the terms of the GNU GPLv3 license.
|
|
|
|
|
|
|
|
#include <stdlib.h> // malloc
|
|
|
|
#include <string.h> // memset
|
|
|
|
#include "compiler.h" // __visible
|
|
|
|
#include "itersolve.h" // struct stepper_kinematics
|
2019-10-27 18:23:03 +01:00
|
|
|
#include "trapq.h" // move_get_coord
|
2018-06-09 20:30:22 +02:00
|
|
|
|
|
|
|
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 == '+')
|
2019-10-27 16:06:46 +01:00
|
|
|
sk->calc_position_cb = corexy_stepper_plus_calc_position;
|
2018-06-09 20:30:22 +02:00
|
|
|
else if (type == '-')
|
2019-10-27 16:06:46 +01:00
|
|
|
sk->calc_position_cb = corexy_stepper_minus_calc_position;
|
2019-10-29 03:59:07 +01:00
|
|
|
sk->active_flags = AF_X | AF_Y;
|
2018-06-09 20:30:22 +02:00
|
|
|
return sk;
|
|
|
|
}
|