mirror of https://github.com/Desuuuu/klipper.git
gcode: Automatically call reset_last_position() on a toolhead set_position()
Generate a "toolhead:set_position" event on a call to toolhead.set_position() and use that event to automatically call gcode.reset_last_position(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
560d48dbc9
commit
4115a77342
|
@ -132,8 +132,6 @@ class ForceMove:
|
||||||
z = gcmd.get_float('Z', curpos[2])
|
z = gcmd.get_float('Z', curpos[2])
|
||||||
logging.info("SET_KINEMATIC_POSITION pos=%.3f,%.3f,%.3f", x, y, z)
|
logging.info("SET_KINEMATIC_POSITION pos=%.3f,%.3f,%.3f", x, y, z)
|
||||||
toolhead.set_position([x, y, z, curpos[3]], homing_axes=(0, 1, 2))
|
toolhead.set_position([x, y, z, curpos[3]], homing_axes=(0, 1, 2))
|
||||||
gcode = self.printer.lookup_object('gcode')
|
|
||||||
gcode.reset_last_position()
|
|
||||||
|
|
||||||
def load_config(config):
|
def load_config(config):
|
||||||
return ForceMove(config)
|
return ForceMove(config)
|
||||||
|
|
|
@ -51,7 +51,6 @@ class HomingOverride:
|
||||||
pos[axis] = loc
|
pos[axis] = loc
|
||||||
homing_axes.append(axis)
|
homing_axes.append(axis)
|
||||||
toolhead.set_position(pos, homing_axes=homing_axes)
|
toolhead.set_position(pos, homing_axes=homing_axes)
|
||||||
self.gcode.reset_last_position()
|
|
||||||
# Perform homing
|
# Perform homing
|
||||||
kwparams = { 'printer': self.template.create_status_wrapper() }
|
kwparams = { 'printer': self.template.create_status_wrapper() }
|
||||||
kwparams['params'] = gcmd.get_command_parameters()
|
kwparams['params'] = gcmd.get_command_parameters()
|
||||||
|
|
|
@ -123,7 +123,6 @@ class PrinterProbe:
|
||||||
pos = toolhead.get_position()
|
pos = toolhead.get_position()
|
||||||
self.gcode.respond_info("probe at %.3f,%.3f is z=%.6f"
|
self.gcode.respond_info("probe at %.3f,%.3f is z=%.6f"
|
||||||
% (pos[0], pos[1], pos[2]))
|
% (pos[0], pos[1], pos[2]))
|
||||||
self.gcode.reset_last_position()
|
|
||||||
return pos[:3]
|
return pos[:3]
|
||||||
def _move(self, coord, speed):
|
def _move(self, coord, speed):
|
||||||
toolhead = self.printer.lookup_object('toolhead')
|
toolhead = self.printer.lookup_object('toolhead')
|
||||||
|
|
|
@ -35,7 +35,6 @@ class TuningTower:
|
||||||
self.command_fmt = "%s %s=%%.9f" % (command, parameter)
|
self.command_fmt = "%s %s=%%.9f" % (command, parameter)
|
||||||
self.normal_transform = self.gcode.set_move_transform(self, force=True)
|
self.normal_transform = self.gcode.set_move_transform(self, force=True)
|
||||||
self.last_z = -99999999.9
|
self.last_z = -99999999.9
|
||||||
self.gcode.reset_last_position()
|
|
||||||
self.get_position()
|
self.get_position()
|
||||||
gcmd.respond_info("Starting tuning test (start=%.6f factor=%.6f)"
|
gcmd.respond_info("Starting tuning test (start=%.6f factor=%.6f)"
|
||||||
% (self.start, self.factor))
|
% (self.start, self.factor))
|
||||||
|
|
|
@ -65,7 +65,6 @@ class ZAdjustHelper:
|
||||||
last_stepper.set_trapq(toolhead.get_trapq())
|
last_stepper.set_trapq(toolhead.get_trapq())
|
||||||
curpos[2] += first_stepper_offset
|
curpos[2] += first_stepper_offset
|
||||||
toolhead.set_position(curpos)
|
toolhead.set_position(curpos)
|
||||||
gcode.reset_last_position()
|
|
||||||
|
|
||||||
class RetryHelper:
|
class RetryHelper:
|
||||||
def __init__(self, config, error_msg_extra = ""):
|
def __init__(self, config, error_msg_extra = ""):
|
||||||
|
|
|
@ -76,6 +76,8 @@ class GCodeParser:
|
||||||
printer.register_event_handler("klippy:shutdown", self._handle_shutdown)
|
printer.register_event_handler("klippy:shutdown", self._handle_shutdown)
|
||||||
printer.register_event_handler("klippy:disconnect",
|
printer.register_event_handler("klippy:disconnect",
|
||||||
self._handle_disconnect)
|
self._handle_disconnect)
|
||||||
|
printer.register_event_handler("toolhead:set_position",
|
||||||
|
self.reset_last_position)
|
||||||
printer.register_event_handler("extruder:activate_extruder",
|
printer.register_event_handler("extruder:activate_extruder",
|
||||||
self._handle_activate_extruder)
|
self._handle_activate_extruder)
|
||||||
# Command handling
|
# Command handling
|
||||||
|
@ -421,7 +423,6 @@ class GCodeParser:
|
||||||
homing_state.home_axes(axes)
|
homing_state.home_axes(axes)
|
||||||
for axis in homing_state.get_axes():
|
for axis in homing_state.get_axes():
|
||||||
self.base_position[axis] = self.homing_position[axis]
|
self.base_position[axis] = self.homing_position[axis]
|
||||||
self.reset_last_position()
|
|
||||||
def cmd_M400(self, gcmd):
|
def cmd_M400(self, gcmd):
|
||||||
# Wait for current moves to finish
|
# Wait for current moves to finish
|
||||||
self.toolhead.wait_moves()
|
self.toolhead.wait_moves()
|
||||||
|
|
|
@ -136,10 +136,8 @@ class CartKinematics:
|
||||||
self.limits[dc_axis] = dc_rail.get_range()
|
self.limits[dc_axis] = dc_rail.get_range()
|
||||||
cmd_SET_DUAL_CARRIAGE_help = "Set which carriage is active"
|
cmd_SET_DUAL_CARRIAGE_help = "Set which carriage is active"
|
||||||
def cmd_SET_DUAL_CARRIAGE(self, gcmd):
|
def cmd_SET_DUAL_CARRIAGE(self, gcmd):
|
||||||
gcode = self.printer.lookup_object('gcode')
|
|
||||||
carriage = gcmd.get_int('CARRIAGE', minval=0, maxval=1)
|
carriage = gcmd.get_int('CARRIAGE', minval=0, maxval=1)
|
||||||
self._activate_carriage(carriage)
|
self._activate_carriage(carriage)
|
||||||
gcode.reset_last_position()
|
|
||||||
|
|
||||||
def load_kinematics(toolhead, config):
|
def load_kinematics(toolhead, config):
|
||||||
return CartKinematics(toolhead, config)
|
return CartKinematics(toolhead, config)
|
||||||
|
|
|
@ -400,6 +400,7 @@ class ToolHead:
|
||||||
self.trapq_free_moves(self.trapq, self.reactor.NEVER)
|
self.trapq_free_moves(self.trapq, self.reactor.NEVER)
|
||||||
self.commanded_pos[:] = newpos
|
self.commanded_pos[:] = newpos
|
||||||
self.kin.set_position(newpos, homing_axes)
|
self.kin.set_position(newpos, homing_axes)
|
||||||
|
self.printer.send_event("toolhead:set_position")
|
||||||
def move(self, newpos, speed):
|
def move(self, newpos, speed):
|
||||||
move = Move(self, self.commanded_pos, newpos, speed)
|
move = Move(self, self.commanded_pos, newpos, speed)
|
||||||
if not move.move_d:
|
if not move.move_d:
|
||||||
|
|
Loading…
Reference in New Issue