From 977aabe038a4fbfa46c2b8873999e9e198f7487f Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 13 Oct 2016 10:04:30 -0400 Subject: [PATCH] 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 --- klippy/cartesian.py | 3 ++- klippy/stepper.py | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/klippy/cartesian.py b/klippy/cartesian.py index de9d4fa4..860ce9fd 100644 --- a/klippy/cartesian.py +++ b/klippy/cartesian.py @@ -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) diff --git a/klippy/stepper.py b/klippy/stepper.py index 310a0711..8881c99f 100644 --- a/klippy/stepper.py +++ b/klippy/stepper.py @@ -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