mirror of https://github.com/Desuuuu/klipper.git
stepper: Return homing offset in steps instead of an absolute position
Rename get_homed_position() to get_homed_offset() and return the endstop position delta in steps instead of an absolute position relative to position_endstop. The conversion to absolute positions can be dependent on the type of kinematics in use, so is inappropriate to do in the low level stepper.py code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
da7d8dbcac
commit
977aabe038
|
@ -28,7 +28,8 @@ class CartKinematics:
|
|||
max_xy_accel = min(s.max_accel for s in self.steppers[:2])
|
||||
return max_xy_speed, max_xy_accel
|
||||
def get_homed_position(self):
|
||||
return [s.get_homed_position() for s in self.steppers]
|
||||
return [s.position_endstop + s.get_homed_offset()*s.step_dist
|
||||
for s in self.steppers]
|
||||
def home(self, toolhead, axes):
|
||||
# Each axis is homed independently and in order
|
||||
homing_state = homing.Homing(toolhead, axes)
|
||||
|
|
|
@ -85,21 +85,21 @@ class PrinterStepper:
|
|||
return None
|
||||
self.mcu_endstop.query_endstop()
|
||||
return self.mcu_endstop
|
||||
def get_homed_position(self):
|
||||
def get_homed_offset(self):
|
||||
if not self.homing_stepper_phases:
|
||||
return self.position_endstop
|
||||
return 0
|
||||
pos = self.mcu_endstop.get_last_position()
|
||||
pos %= self.homing_stepper_phases
|
||||
if self.homing_endstop_phase is None:
|
||||
logging.info("Setting %s endstop phase to %d" % (
|
||||
self.config.section, pos))
|
||||
self.homing_endstop_phase = pos
|
||||
return self.position_endstop
|
||||
return 0
|
||||
delta = (pos - self.homing_endstop_phase) % self.homing_stepper_phases
|
||||
if delta >= self.homing_stepper_phases - self.homing_endstop_accuracy:
|
||||
delta -= self.homing_stepper_phases
|
||||
elif delta > self.homing_endstop_accuracy:
|
||||
logging.error("Endstop %s incorrect phase (got %d vs %d)" % (
|
||||
self.config.section, pos, self.homing_endstop_phase))
|
||||
return self.position_endstop
|
||||
return self.position_endstop + delta * self.step_dist
|
||||
return 0
|
||||
return delta
|
||||
|
|
Loading…
Reference in New Issue