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:
Kevin O'Connor 2020-08-16 22:02:23 -04:00
parent 560d48dbc9
commit 4115a77342
8 changed files with 3 additions and 9 deletions

View file

@ -76,6 +76,8 @@ class GCodeParser:
printer.register_event_handler("klippy:shutdown", self._handle_shutdown)
printer.register_event_handler("klippy:disconnect",
self._handle_disconnect)
printer.register_event_handler("toolhead:set_position",
self.reset_last_position)
printer.register_event_handler("extruder:activate_extruder",
self._handle_activate_extruder)
# Command handling
@ -421,7 +423,6 @@ class GCodeParser:
homing_state.home_axes(axes)
for axis in homing_state.get_axes():
self.base_position[axis] = self.homing_position[axis]
self.reset_last_position()
def cmd_M400(self, gcmd):
# Wait for current moves to finish
self.toolhead.wait_moves()