Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions klipper/extras/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ def get_offset(self):
self.gcode_z_offset if self.gcode_z_offset else 0.0,
]

def set_offset(self, offset):
x, y, z = offset
self.gcode_x_offset = x
self.gcode_y_offset = y
self.gcode_z_offset = z

cmd_ASSIGN_TOOL_help = 'Assign tool to tool number'
def cmd_ASSIGN_TOOL(self, gcmd):
self.assign_tool(gcmd.get_int('N', minval=0), replace = True)
Expand Down
19 changes: 19 additions & 0 deletions klipper/extras/tools_calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def __init__(self, config):
self.gcode.register_command('TOOL_CALIBRATE_TOOL_OFFSET',
self.cmd_TOOL_CALIBRATE_TOOL_OFFSET,
desc=self.cmd_TOOL_CALIBRATE_TOOL_OFFSET_help)
self.gcode.register_command('TOOL_CALIBRATE_TOOL_OFFSET_LIVE_UPDATE',
self.cmd_TOOL_CALIBRATE_TOOL_OFFSET_LIVE_UPDATE,
desc=self.cmd_TOOL_CALIBRATE_TOOL_OFFSET_LIVE_UPDATE_help)
self.gcode.register_command('TOOL_CALIBRATE_SAVE_TOOL_OFFSET',
self.cmd_TOOL_CALIBRATE_SAVE_TOOL_OFFSET,
desc=self.cmd_TOOL_CALIBRATE_SAVE_TOOL_OFFSET_help)
Expand Down Expand Up @@ -132,6 +135,22 @@ def cmd_TOOL_CALIBRATE_TOOL_OFFSET(self, gcmd):
% (self.last_result[0], self.last_result[1],
self.last_result[2]))

cmd_TOOL_CALIBRATE_TOOL_OFFSET_LIVE_UPDATE_help = "Calibrate current tool offset relative to tool 0 (and apply)"

def cmd_TOOL_CALIBRATE_TOOL_OFFSET_LIVE_UPDATE(self, gcmd):
if not self.sensor_location:
raise gcmd.error(
"No recorded sensor location, please run TOOL_LOCATE_SENSOR first")
location = self.locate_sensor(gcmd)
self.last_result = [location[i] - self.sensor_location[i] for i in
range(3)]
# set live tool offset using a_tool.set_offset(self.last_result)
self.printer.lookup_object('toolchanger').get_selected_tool().set_offset(self.last_result)

self.gcode.respond_info("Tool offset is %.6f,%.6f,%.6f"
% (self.last_result[0], self.last_result[1],
self.last_result[2]))

cmd_TOOL_CALIBRATE_SAVE_TOOL_OFFSET_help = "Save tool offset calibration to config"

def cmd_TOOL_CALIBRATE_SAVE_TOOL_OFFSET(self, gcmd):
Expand Down