-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from TypQxQ/dev
From Dev
- Loading branch information
Showing
6 changed files
with
152 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
TODO: | ||
- Important | ||
- Add variable for wait after movement, add as pause in server before doing calibration | ||
- Rewrite Readme wit Copilot and spellcheck. | ||
- Logo | ||
- Move inmemory log to file on srv. maybe | ||
- Less important | ||
- Trivial | ||
- Put timers on operations like calibrate camera and get possition. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
[gcode_macro tool_align_macro] | ||
description = Aligns all tools | ||
|
||
# This macro will align all tools using the KTAMV plugin | ||
gcode: | ||
# Constants to be customized: | ||
{% set VAR_CAMERA_CENTER_COORDINATES = [ 10.0, 10.0] %}# Where you have your camera, X,Y | ||
{% set VAR_TOOL_TO_USE_FOR_CALIBRATION = 0 %}# Tool to use for calibrating the camera | ||
{% set VAR_TOOL_TO_USE_AS_REFERENCE = 0 %}# Tool to use as reference for the offsets | ||
{% set VAR_TOOLS_TO_ALIGN = [ 1, 2, 3] %}# Tools to align and get offset to the reference tool | ||
|
||
|
||
# Check if printer is homed, mm/px is calculated and we have set a origin for our tools | ||
{% if 'xy' not in printer.toolhead.homed_axes%} | ||
RESPOND PREFIX="info" MSG="Printer not homed." | ||
# If camera is not calibrated or origin position not set, do both. | ||
{% elif printer.ktamv.camera_center_coordinates[0]|default("none")|lower =="none" or printer.ktamv.mm_per_pixels|default("none")|lower == "none"%} | ||
# Set up the server | ||
KTAMV_SEND_SERVER_CFG | ||
# Chose the tool to calibrate with. | ||
T{VAR_TOOL_TO_USE_FOR_CALIBRATION} | ||
# Move to the camera center | ||
G0 X{VAR_CAMERA_CENTER_COORDINATES[0]} Y{VAR_CAMERA_CENTER_COORDINATES[1]} F{printer.ktamv.travel_speed} | ||
# Wait for tool to finish moving | ||
M400 | ||
# Calibrate the camera | ||
KTAMV_CALIB_CAMERA | ||
# Load the tool to use as reference for our offsets | ||
T{VAR_TOOL_TO_USE_AS_REFERENCE} | ||
# Move to the camera center | ||
G0 X{VAR_CAMERA_CENTER_COORDINATES[0]} Y{VAR_CAMERA_CENTER_COORDINATES[1]} F{printer.ktamv.travel_speed} | ||
# Find the nozzle center | ||
KTAMV_FIND_NOZZLE_CENTER | ||
# Set the origin to calibrate from if the above calibration was successful | ||
_tool_align_macro_set_origin_if_successful | ||
{% endif %} | ||
|
||
# Align all tools, checking everything is ok now inside the next macro because in this the variables have not updated yet. | ||
{% for tool in VAR_TOOLS_TO_ALIGN %} | ||
RESPOND PREFIX="info" MSG="-Aligning tool T{tool}" | ||
_tool_align_macro_align_tool TOOL={tool} | ||
{% endfor %} | ||
|
||
# Set Origin if last nozzle center was successful. | ||
# Needs to be in separate macro to be calculated after the previous command is finished. | ||
[gcode_macro _tool_align_macro_set_origin_if_successful] | ||
gcode: | ||
{% if printer.ktamv.last_nozzle_center_successful|default("false")|lower =="true" %} | ||
KTAMV_SET_ORIGIN | ||
{% endif %} | ||
|
||
# Align tool macro | ||
[gcode_macro _tool_align_macro_align_tool] | ||
gcode: | ||
# Get tool from params | ||
{% set TOOL = params.TOOL %} | ||
|
||
# Check if printer is homed, mm/px is calculated and we have set a origin for our tools | ||
# If everything above is true, we can start the tool alignment | ||
{% if printer.ktamv.camera_center_coordinates[0]|default("none")|lower !="none" and printer.ktamv.mm_per_pixels|default("none")|lower != "none" and 'xy' in printer.toolhead.homed_axes%} | ||
RESPOND PREFIX="info" MSG="Aligning tool T{TOOL}" | ||
# Load tool | ||
T{TOOL} | ||
# Move to camera center | ||
G0 X{printer.ktamv.camera_center_coordinates[0]} Y{printer.ktamv.camera_center_coordinates[1]} F{printer.ktamv.travel_speed} | ||
# Get nozzle center | ||
KTAMV_FIND_NOZZLE_CENTER | ||
# Get offset | ||
KTAMV_GET_OFFSET | ||
# Save offset using the next macro | ||
_tool_align_macro_save_offset TOOL={TOOL} | ||
{% else %} | ||
RESPOND PREFIX="info" MSG="Camera not calibrated or origin not set. Please run the macro again." | ||
{% endif %} | ||
|
||
# Macro to save offset | ||
[gcode_macro _tool_align_macro_save_offset] | ||
gcode: | ||
# Get tool from params | ||
{% set TOOL = params.TOOL %} | ||
# If offset is calculated, we can save it | ||
{% if printer.ktamv.last_nozzle_center_successful|default("false")|lower =="true" %} | ||
# Add your code here to save the offset | ||
{action_respond_info("Macro example saving offset X:"~printer.ktamv.last_calculated_offset[0]~" Y:"~printer.ktamv.last_calculated_offset[1]~" for tool T"~TOOL)} | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters