2018-06-06 22:49:44 +02:00
|
|
|
// Cartesian kinematics stepper pulse time generation
|
|
|
|
//
|
2018-06-14 20:01:33 +02:00
|
|
|
// Copyright (C) 2018 Kevin O'Connor <kevin@koconnor.net>
|
2018-06-06 22:49:44 +02:00
|
|
|
//
|
|
|
|
// This file may be distributed under the terms of the GNU GPLv3 license.
|
|
|
|
|
2018-06-09 20:30:22 +02:00
|
|
|
#include <stdlib.h> // malloc
|
|
|
|
#include <string.h> // memset
|
2018-06-14 20:01:33 +02:00
|
|
|
#include "compiler.h" // __visible
|
2018-06-09 20:30:22 +02:00
|
|
|
#include "itersolve.h" // move_get_coord
|
2018-06-06 22:49:44 +02:00
|
|
|
#include "pyhelper.h" // errorf
|
2018-06-09 20:30:22 +02:00
|
|
|
|
|
|
|
static double
|
|
|
|
cart_stepper_x_calc_position(struct stepper_kinematics *sk, struct move *m
|
|
|
|
, double move_time)
|
|
|
|
{
|
|
|
|
return move_get_coord(m, move_time).x;
|
|
|
|
}
|
|
|
|
|
|
|
|
static double
|
|
|
|
cart_stepper_y_calc_position(struct stepper_kinematics *sk, struct move *m
|
|
|
|
, double move_time)
|
|
|
|
{
|
|
|
|
return move_get_coord(m, move_time).y;
|
|
|
|
}
|
|
|
|
|
|
|
|
static double
|
|
|
|
cart_stepper_z_calc_position(struct stepper_kinematics *sk, struct move *m
|
|
|
|
, double move_time)
|
|
|
|
{
|
|
|
|
return move_get_coord(m, move_time).z;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct stepper_kinematics * __visible
|
|
|
|
cartesian_stepper_alloc(char axis)
|
|
|
|
{
|
|
|
|
struct stepper_kinematics *sk = malloc(sizeof(*sk));
|
|
|
|
memset(sk, 0, sizeof(*sk));
|
|
|
|
if (axis == 'x')
|
2019-10-27 16:06:46 +01:00
|
|
|
sk->calc_position_cb = cart_stepper_x_calc_position;
|
2018-06-09 20:30:22 +02:00
|
|
|
else if (axis == 'y')
|
2019-10-27 16:06:46 +01:00
|
|
|
sk->calc_position_cb = cart_stepper_y_calc_position;
|
2018-06-09 20:30:22 +02:00
|
|
|
else if (axis == 'z')
|
2019-10-27 16:06:46 +01:00
|
|
|
sk->calc_position_cb = cart_stepper_z_calc_position;
|
2018-06-09 20:30:22 +02:00
|
|
|
return sk;
|
|
|
|
}
|