stepper: Remove set_commanded_position() call

Now that the only caller to set_commanded_position() is
set_position(), remove the set_commanded_position() method and pass
the set_position() call directly to the itersolve.c code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-11-13 18:58:51 -05:00
parent 18b0749163
commit d39142139e
4 changed files with 13 additions and 20 deletions

View File

@ -51,9 +51,8 @@ defs_itersolve = """
void itersolve_set_trapq(struct stepper_kinematics *sk, struct trapq *tq);
void itersolve_set_stepcompress(struct stepper_kinematics *sk
, struct stepcompress *sc, double step_dist);
double itersolve_calc_position_from_coord(struct stepper_kinematics *sk
void itersolve_set_position(struct stepper_kinematics *sk
, double x, double y, double z);
void itersolve_set_commanded_pos(struct stepper_kinematics *sk, double pos);
double itersolve_get_commanded_pos(struct stepper_kinematics *sk);
"""

View File

@ -208,7 +208,7 @@ itersolve_set_stepcompress(struct stepper_kinematics *sk
sk->step_dist = step_dist;
}
double __visible
static double
itersolve_calc_position_from_coord(struct stepper_kinematics *sk
, double x, double y, double z)
{
@ -221,9 +221,10 @@ itersolve_calc_position_from_coord(struct stepper_kinematics *sk
}
void __visible
itersolve_set_commanded_pos(struct stepper_kinematics *sk, double pos)
itersolve_set_position(struct stepper_kinematics *sk
, double x, double y, double z)
{
sk->commanded_pos = pos;
sk->commanded_pos = itersolve_calc_position_from_coord(sk, x, y, z);
}
double __visible

View File

@ -30,9 +30,8 @@ double itersolve_check_active(struct stepper_kinematics *sk, double flush_time);
void itersolve_set_trapq(struct stepper_kinematics *sk, struct trapq *tq);
void itersolve_set_stepcompress(struct stepper_kinematics *sk
, struct stepcompress *sc, double step_dist);
double itersolve_calc_position_from_coord(struct stepper_kinematics *sk
void itersolve_set_position(struct stepper_kinematics *sk
, double x, double y, double z);
void itersolve_set_commanded_pos(struct stepper_kinematics *sk, double pos);
double itersolve_get_commanded_pos(struct stepper_kinematics *sk);
#endif // itersolve.h

View File

@ -90,17 +90,14 @@ class MCU_stepper:
return self._step_dist
def is_dir_inverted(self):
return self._invert_dir
def calc_position_from_coord(self, coord):
return self._ffi_lib.itersolve_calc_position_from_coord(
self._stepper_kinematics, coord[0], coord[1], coord[2])
def set_position(self, coord):
self.set_commanded_position(self.calc_position_from_coord(coord))
opos = self.get_commanded_position()
sk = self._stepper_kinematics
self._ffi_lib.itersolve_set_position(sk, coord[0], coord[1], coord[2])
self._mcu_position_offset += opos - self.get_commanded_position()
def get_commanded_position(self):
return self._ffi_lib.itersolve_get_commanded_pos(
self._stepper_kinematics)
def set_commanded_position(self, pos):
self._mcu_position_offset += self.get_commanded_position() - pos
self._ffi_lib.itersolve_set_commanded_pos(self._stepper_kinematics, pos)
sk = self._stepper_kinematics
return self._ffi_lib.itersolve_get_commanded_pos(sk)
def get_mcu_position(self):
mcu_pos_dist = self.get_commanded_position() + self._mcu_position_offset
mcu_pos = mcu_pos_dist / self._step_dist
@ -279,9 +276,6 @@ class PrinterRail:
def set_max_jerk(self, max_halt_velocity, max_accel):
for stepper in self.steppers:
stepper.set_max_jerk(max_halt_velocity, max_accel)
def set_commanded_position(self, pos):
for stepper in self.steppers:
stepper.set_commanded_position(pos)
def set_position(self, coord):
for stepper in self.steppers:
stepper.set_position(coord)