itersolve: Rename calc_position to calc_position_cb
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
9945cc0f46
commit
92993c062b
|
@ -1,6 +1,6 @@
|
|||
// Iterative solver for kinematic moves
|
||||
//
|
||||
// Copyright (C) 2018 Kevin O'Connor <kevin@koconnor.net>
|
||||
// Copyright (C) 2018-2019 Kevin O'Connor <kevin@koconnor.net>
|
||||
//
|
||||
// This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
|
||||
|
@ -108,7 +108,7 @@ itersolve_find_step(struct stepper_kinematics *sk, struct move *m
|
|||
, struct timepos low, struct timepos high
|
||||
, double target)
|
||||
{
|
||||
sk_callback calc_position = sk->calc_position;
|
||||
sk_calc_callback calc_position_cb = sk->calc_position_cb;
|
||||
struct timepos best_guess = high;
|
||||
low.position -= target;
|
||||
high.position -= target;
|
||||
|
@ -125,7 +125,7 @@ itersolve_find_step(struct stepper_kinematics *sk, struct move *m
|
|||
if (fabs(guess_time - best_guess.time) <= .000000001)
|
||||
break;
|
||||
best_guess.time = guess_time;
|
||||
best_guess.position = calc_position(sk, m, guess_time);
|
||||
best_guess.position = calc_position_cb(sk, m, guess_time);
|
||||
double guess_position = best_guess.position - target;
|
||||
int guess_sign = signbit(guess_position);
|
||||
if (guess_sign == high_sign) {
|
||||
|
@ -144,7 +144,7 @@ int32_t __visible
|
|||
itersolve_gen_steps(struct stepper_kinematics *sk, struct move *m)
|
||||
{
|
||||
struct stepcompress *sc = sk->sc;
|
||||
sk_callback calc_position = sk->calc_position;
|
||||
sk_calc_callback calc_position_cb = sk->calc_position_cb;
|
||||
double half_step = .5 * sk->step_dist;
|
||||
double mcu_freq = stepcompress_get_mcu_freq(sc);
|
||||
struct timepos last = { 0., sk->commanded_pos }, low = last, high = last;
|
||||
|
@ -165,7 +165,7 @@ itersolve_gen_steps(struct stepper_kinematics *sk, struct move *m)
|
|||
seek_time_delta += seek_time_delta;
|
||||
if (high.time > m->move_t)
|
||||
high.time = m->move_t;
|
||||
high.position = calc_position(sk, m, high.time);
|
||||
high.position = calc_position_cb(sk, m, high.time);
|
||||
continue;
|
||||
}
|
||||
int next_sdir = dist > 0.;
|
||||
|
@ -179,7 +179,7 @@ itersolve_gen_steps(struct stepper_kinematics *sk, struct move *m)
|
|||
if (high.time < last.time + .000000001)
|
||||
goto seek_new_high_range;
|
||||
high.time = (last.time + high.time) * .5;
|
||||
high.position = calc_position(sk, m, high.time);
|
||||
high.position = calc_position_cb(sk, m, high.time);
|
||||
continue;
|
||||
}
|
||||
int ret = queue_append_set_next_step_dir(&qa, next_sdir);
|
||||
|
@ -224,7 +224,7 @@ itersolve_calc_position_from_coord(struct stepper_kinematics *sk
|
|||
struct move m;
|
||||
memset(&m, 0, sizeof(m));
|
||||
move_fill(&m, 0., 0., 1., 0., x, y, z, 0., 1., 0., 0., 1., 0.);
|
||||
return sk->calc_position(sk, &m, 0.);
|
||||
return sk->calc_position_cb(sk, &m, 0.);
|
||||
}
|
||||
|
||||
void __visible
|
||||
|
|
|
@ -30,12 +30,12 @@ double move_get_distance(struct move *m, double move_time);
|
|||
struct coord move_get_coord(struct move *m, double move_time);
|
||||
|
||||
struct stepper_kinematics;
|
||||
typedef double (*sk_callback)(struct stepper_kinematics *sk, struct move *m
|
||||
typedef double (*sk_calc_callback)(struct stepper_kinematics *sk, struct move *m
|
||||
, double move_time);
|
||||
struct stepper_kinematics {
|
||||
double step_dist, commanded_pos;
|
||||
struct stepcompress *sc;
|
||||
sk_callback calc_position;
|
||||
sk_calc_callback calc_position_cb;
|
||||
};
|
||||
|
||||
int32_t itersolve_gen_steps(struct stepper_kinematics *sk, struct move *m);
|
||||
|
|
|
@ -37,10 +37,10 @@ cartesian_stepper_alloc(char axis)
|
|||
struct stepper_kinematics *sk = malloc(sizeof(*sk));
|
||||
memset(sk, 0, sizeof(*sk));
|
||||
if (axis == 'x')
|
||||
sk->calc_position = cart_stepper_x_calc_position;
|
||||
sk->calc_position_cb = cart_stepper_x_calc_position;
|
||||
else if (axis == 'y')
|
||||
sk->calc_position = cart_stepper_y_calc_position;
|
||||
sk->calc_position_cb = cart_stepper_y_calc_position;
|
||||
else if (axis == 'z')
|
||||
sk->calc_position = cart_stepper_z_calc_position;
|
||||
sk->calc_position_cb = cart_stepper_z_calc_position;
|
||||
return sk;
|
||||
}
|
||||
|
|
|
@ -31,8 +31,8 @@ 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;
|
||||
sk->calc_position_cb = corexy_stepper_plus_calc_position;
|
||||
else if (type == '-')
|
||||
sk->calc_position = corexy_stepper_minus_calc_position;
|
||||
sk->calc_position_cb = corexy_stepper_minus_calc_position;
|
||||
return sk;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,6 @@ delta_stepper_alloc(double arm2, double tower_x, double tower_y)
|
|||
ds->arm2 = arm2;
|
||||
ds->tower_x = tower_x;
|
||||
ds->tower_y = tower_y;
|
||||
ds->sk.calc_position = delta_stepper_calc_position;
|
||||
ds->sk.calc_position_cb = delta_stepper_calc_position;
|
||||
return &ds->sk;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ extruder_stepper_alloc(void)
|
|||
{
|
||||
struct stepper_kinematics *sk = malloc(sizeof(*sk));
|
||||
memset(sk, 0, sizeof(*sk));
|
||||
sk->calc_position = extruder_calc_position;
|
||||
sk->calc_position_cb = extruder_calc_position;
|
||||
return sk;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,8 +38,8 @@ polar_stepper_alloc(char type)
|
|||
struct stepper_kinematics *sk = malloc(sizeof(*sk));
|
||||
memset(sk, 0, sizeof(*sk));
|
||||
if (type == 'r')
|
||||
sk->calc_position = polar_stepper_radius_calc_position;
|
||||
sk->calc_position_cb = polar_stepper_radius_calc_position;
|
||||
else if (type == 'a')
|
||||
sk->calc_position = polar_stepper_angle_calc_position;
|
||||
sk->calc_position_cb = polar_stepper_angle_calc_position;
|
||||
return sk;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,6 @@ winch_stepper_alloc(double anchor_x, double anchor_y, double anchor_z)
|
|||
hs->anchor.x = anchor_x;
|
||||
hs->anchor.y = anchor_y;
|
||||
hs->anchor.z = anchor_z;
|
||||
hs->sk.calc_position = winch_stepper_calc_position;
|
||||
hs->sk.calc_position_cb = winch_stepper_calc_position;
|
||||
return &hs->sk;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue