endstop_phase: Fix endstop_phase on trinamic drivers that aren't inverted
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
0b02d7a1f2
commit
80194a7e18
|
@ -66,6 +66,8 @@ class EndstopPhase:
|
||||||
msg = "Unable to get stepper %s phase: %s" % (self.name, str(e))
|
msg = "Unable to get stepper %s phase: %s" % (self.name, str(e))
|
||||||
logging.exception(msg)
|
logging.exception(msg)
|
||||||
raise homing.EndstopError(msg)
|
raise homing.EndstopError(msg)
|
||||||
|
if stepper.is_dir_inverted():
|
||||||
|
phase = (self.phases - 1) - phase
|
||||||
else:
|
else:
|
||||||
phase = stepper.get_mcu_position() % self.phases
|
phase = stepper.get_mcu_position() % self.phases
|
||||||
self.phase_history[phase] += 1
|
self.phase_history[phase] += 1
|
||||||
|
|
|
@ -227,7 +227,7 @@ class TMCMicrostepHelper:
|
||||||
field_name = "MSTEP"
|
field_name = "MSTEP"
|
||||||
reg = self.mcu_tmc.get_register(self.fields.lookup_register(field_name))
|
reg = self.mcu_tmc.get_register(self.fields.lookup_register(field_name))
|
||||||
mscnt = self.fields.get_field(field_name, reg)
|
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
|
# Helper to configure "stealthchop" mode
|
||||||
def TMCStealthchopHelper(config, mcu_tmc, tmc_freq):
|
def TMCStealthchopHelper(config, mcu_tmc, tmc_freq):
|
||||||
|
|
|
@ -70,6 +70,8 @@ class MCU_stepper:
|
||||||
return self._oid
|
return self._oid
|
||||||
def get_step_dist(self):
|
def get_step_dist(self):
|
||||||
return self._step_dist
|
return self._step_dist
|
||||||
|
def is_dir_inverted(self):
|
||||||
|
return self._invert_dir
|
||||||
def calc_position_from_coord(self, coord):
|
def calc_position_from_coord(self, coord):
|
||||||
return self._ffi_lib.itersolve_calc_position_from_coord(
|
return self._ffi_lib.itersolve_calc_position_from_coord(
|
||||||
self._stepper_kinematics, coord[0], coord[1], coord[2])
|
self._stepper_kinematics, coord[0], coord[1], coord[2])
|
||||||
|
|
|
@ -73,6 +73,7 @@ class PrinterStepper:
|
||||||
self.set_commanded_position = mcu_stepper.set_commanded_position
|
self.set_commanded_position = mcu_stepper.set_commanded_position
|
||||||
self.get_mcu_position = mcu_stepper.get_mcu_position
|
self.get_mcu_position = mcu_stepper.get_mcu_position
|
||||||
self.get_step_dist = mcu_stepper.get_step_dist
|
self.get_step_dist = mcu_stepper.get_step_dist
|
||||||
|
self.is_dir_inverted = mcu_stepper.is_dir_inverted
|
||||||
def get_name(self, short=False):
|
def get_name(self, short=False):
|
||||||
if short and self.name.startswith('stepper_'):
|
if short and self.name.startswith('stepper_'):
|
||||||
return self.name[8:]
|
return self.name[8:]
|
||||||
|
|
Loading…
Reference in New Issue