aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-06-06 18:14:45 -0400
committerKevinOConnor <kevin@koconnor.net>2019-06-21 22:56:16 -0400
commit80194a7e1823c2d70708767e6cdbec2780aa90b8 (patch)
treeee36d0ab052d91283c3cdec7e456103088de9a4a
parent0b02d7a1f236ae3b2c1cb2c8a4ce16e1788bc100 (diff)
downloadkutter-80194a7e1823c2d70708767e6cdbec2780aa90b8.tar.gz
kutter-80194a7e1823c2d70708767e6cdbec2780aa90b8.tar.xz
kutter-80194a7e1823c2d70708767e6cdbec2780aa90b8.zip
endstop_phase: Fix endstop_phase on trinamic drivers that aren't inverted
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--klippy/extras/endstop_phase.py2
-rw-r--r--klippy/extras/tmc.py2
-rw-r--r--klippy/mcu.py2
-rw-r--r--klippy/stepper.py1
4 files changed, 6 insertions, 1 deletions
diff --git a/klippy/extras/endstop_phase.py b/klippy/extras/endstop_phase.py
index 20ddd340..c0408262 100644
--- a/klippy/extras/endstop_phase.py
+++ b/klippy/extras/endstop_phase.py
@@ -66,6 +66,8 @@ class EndstopPhase:
msg = "Unable to get stepper %s phase: %s" % (self.name, str(e))
logging.exception(msg)
raise homing.EndstopError(msg)
+ if stepper.is_dir_inverted():
+ phase = (self.phases - 1) - phase
else:
phase = stepper.get_mcu_position() % self.phases
self.phase_history[phase] += 1
diff --git a/klippy/extras/tmc.py b/klippy/extras/tmc.py
index f3dcdb92..d0c88f58 100644
--- a/klippy/extras/tmc.py
+++ b/klippy/extras/tmc.py
@@ -227,7 +227,7 @@ class TMCMicrostepHelper:
field_name = "MSTEP"
reg = self.mcu_tmc.get_register(self.fields.lookup_register(field_name))
mscnt = self.fields.get_field(field_name, reg)
- return mscnt >> self.fields.get_field("MRES")
+ return (1023 - mscnt) >> self.fields.get_field("MRES")
# Helper to configure "stealthchop" mode
def TMCStealthchopHelper(config, mcu_tmc, tmc_freq):
diff --git a/klippy/mcu.py b/klippy/mcu.py
index 15148a86..bc5e046b 100644
--- a/klippy/mcu.py
+++ b/klippy/mcu.py
@@ -70,6 +70,8 @@ class MCU_stepper:
return self._oid
def get_step_dist(self):
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])
diff --git a/klippy/stepper.py b/klippy/stepper.py
index 786ea2ee..29b525a9 100644
--- a/klippy/stepper.py
+++ b/klippy/stepper.py
@@ -73,6 +73,7 @@ class PrinterStepper:
self.set_commanded_position = mcu_stepper.set_commanded_position
self.get_mcu_position = mcu_stepper.get_mcu_position
self.get_step_dist = mcu_stepper.get_step_dist
+ self.is_dir_inverted = mcu_stepper.is_dir_inverted
def get_name(self, short=False):
if short and self.name.startswith('stepper_'):
return self.name[8:]