Skip to content

Commit

Permalink
Remove unneeded variables and update descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Harrypulvirenti committed Jan 18, 2023
1 parent 7120651 commit a0b2184
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 156 deletions.
142 changes: 16 additions & 126 deletions klack-macros.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,8 @@ gcode:
{% set probe_lock = printer["gcode_macro _Probe_Variables"].probe_lock %}
{% set verbose = printer["gcode_macro _User_Variables"].verbose %}
# Get Docking location
{% set dockmove_x = printer["gcode_macro _User_Variables"].dockmove_x|default(0) %}
{% set dockmove_y = printer["gcode_macro _User_Variables"].dockmove_y|default(0) %}
{% set dockmove_z = printer["gcode_macro _User_Variables"].dockmove_z|default(0) %}
{% set docklocation_x = printer["gcode_macro _User_Variables"].docklocation_x %}
{% set docklocation_y = printer["gcode_macro _User_Variables"].docklocation_y %}
{% set docklocation_z = printer["gcode_macro _User_Variables"].docklocation_z %}
{% set attachmove_x = printer["gcode_macro _User_Variables"].attachmove_x|default(0) %}
{% set attachmove_y = printer["gcode_macro _User_Variables"].attachmove_y|default(0) %}
{% set attachmove_z = printer["gcode_macro _User_Variables"].attachmove_z|default(0) %}
{% set attachmove2_x = printer["gcode_macro _User_Variables"].attachmove2_x|default(0) %}
{% set attachmove2_y = printer["gcode_macro _User_Variables"].attachmove2_y|default(0) %}
{% set attachmove2_z = printer["gcode_macro _User_Variables"].attachmove2_z|default(0) %}
# Safe Z for travel
{% set safe_z = printer["gcode_macro _User_Variables"].safe_z %}
{% set enable_z_hop = printer["gcode_macro _User_Variables"].enable_z_hop %}
Expand Down Expand Up @@ -146,56 +136,13 @@ gcode:
G0 Z{safe_z} F{z_drop_feedrate}
{% endif %}

# Probe entry location
{% if docklocation_y != -128 %}
_KlackDebug msg="Attach_Probe moving near the dock with G0 X{docklocation_x|int - attachmove_x|int - attachmove2_x|int} Y{docklocation_y|int - attachmove_y|int - attachmove2_y} F{travel_feedrate}"
G0 X{docklocation_x|int - attachmove_x|int - attachmove2_x|int} Y{docklocation_y|int - attachmove_y|int - attachmove2_y} F{travel_feedrate}
{% else %}
_KlackDebug msg="Attach_Probe moving near the dock with G0 X{docklocation_x|int + attachmove_x|int + attachmove2_x|int} F{travel_feedrate}"
G0 X{docklocation_x|int - attachmove_x|int - attachmove2_x|int} F{travel_feedrate}
{% endif %}

{% if docklocation_z != -128 %}
_KlackDebug msg="Attach_Probe moving near the dock with G0 Z{docklocation_z|int - attachmove_z|int - attachmove2_z|int} F{dock_feedrate}"
G0 Z{docklocation_z|int - attachmove_z|int - attachmove2_z|int} F{dock_feedrate}
_KlackDebug msg="Attach_Probe moving near the dock with G0 Z{docklocation_z|int - attachmove_z|int} F{dock_feedrate}"
G0 Z{docklocation_z|int - attachmove_z|int} F{dock_feedrate}
{% endif %}

# Drop Probe to Probe location
{% if docklocation_z != -128 %}
_KlackDebug msg="Attach_Probe moving to the dock with G0 Z{docklocation_z} F{dock_feedrate}"
G0 Z{docklocation_z} F{dock_feedrate}
{% endif %}

{% if docklocation_y != -128 %}
_KlackDebug msg="Attach_Probe moving to the dock with G0 X{docklocation_x|int - attachmove2_x|int} Y{docklocation_y|int - attachmove2_y} F{dock_feedrate}"
G0 X{docklocation_x|int - attachmove2_x|int} Y{docklocation_y|int - attachmove2_y} F{dock_feedrate}
_KlackDebug msg="Attach_Probe moving to the dock with G0 X{docklocation_x} Y{docklocation_y} F{dock_feedrate}"
G0 X{docklocation_x} Y{docklocation_y} F{dock_feedrate}
{% else %}
_KlackDebug msg="Attach_Probe moving to the dock with G0 X{docklocation_x|int - attachmove2_x|int} F{dock_feedrate}"
G0 X{docklocation_x|int - attachmove2_x|int} F{dock_feedrate}
_KlackDebug msg="Attach_Probe moving to the dock with G0 X{docklocation_x} F{dock_feedrate}"
G0 X{docklocation_x} F{dock_feedrate}
{% endif %}

# Probe Attached
{% if docklocation_z != -128 %}
_KlackDebug msg="Attach_Probe moving from the dock to G0 Z{docklocation_z|int - attachmove_z|int} F{z_drop_feedrate}"
G0 Z{docklocation_z|int - attachmove_z|int} F{z_drop_feedrate}
{% endif %}

{% if docklocation_y != -128 %}
_KlackDebug msg="Attach_Probe moving from the dock to G0 X{docklocation_x|int - attachmove_x|int} Y{docklocation_y|int - attachmove_y|int} F{release_feedrate}"
G0 X{docklocation_x|int - attachmove_x|int} Y{docklocation_y|int - attachmove_y|int} F{release_feedrate}
{% else %}
_KlackDebug msg="Attach_Probe moving from the dock to G0 X{docklocation_x|int - attachmove_x|int} F{release_feedrate}"
G0 X{docklocation_x|int - attachmove_x|int} F{release_feedrate}
{% endif %}
G0 X{docklocation_x|int - attachmove_x|int} F{travel_feedrate}
G0 X{docklocation_x} F{dock_feedrate}
G4 P300
G0 X{docklocation_x|int - attachmove_x|int} F{release_feedrate}

## Go to Z safe distance
{% if ((printer.toolhead.position.z < safe_z) or (docklocation_z != -128 and docklocation_z < safe_z ))%}
{% if (printer.toolhead.position.z < safe_z)%}
_KlackDebug msg="Attach_Probe moving to a safe Z position: G0 Z{safe_z} F{z_drop_feedrate} from {printer.toolhead.position.z}"
G0 Z{safe_z} F{z_drop_feedrate}
{% endif %}
Expand Down Expand Up @@ -237,14 +184,9 @@ gcode:
{% set verbose = printer["gcode_macro _User_Variables"].verbose %}
# Get Docking location
{% set dockmove_x = printer["gcode_macro _User_Variables"].dockmove_x|default(0) %}
{% set dockmove_y = printer["gcode_macro _User_Variables"].dockmove_y|default(0) %}
{% set dockmove_z = printer["gcode_macro _User_Variables"].dockmove_z|default(0) %}
{% set docklocation_x = printer["gcode_macro _User_Variables"].docklocation_x %}
{% set docklocation_y = printer["gcode_macro _User_Variables"].docklocation_y %}
{% set docklocation_z = printer["gcode_macro _User_Variables"].docklocation_z %}
{% set attachmove_x = printer["gcode_macro _User_Variables"].attachmove_x|default(0) %}
{% set attachmove_y = printer["gcode_macro _User_Variables"].attachmove_y|default(0) %}
{% set attachmove_z = printer["gcode_macro _User_Variables"].attachmove_z|default(0) %}
# Safe Z for travel
{% set safe_z = printer["gcode_macro _User_Variables"].safe_z|float %}
# Set feedrates
Expand All @@ -271,60 +213,15 @@ gcode:
G0 Z{safe_z} F{z_drop_feedrate}
{% endif %}

# Probe entry location
{% if docklocation_y != -128 %}
_KlackDebug msg="Dock_Probe moving near the dock with G0 X{docklocation_x|int - attachmove_x|int} Y{docklocation_y|int - attachmove_y|int} F{travel_feedrate}"
G0 X{docklocation_x|int - attachmove_x|int} Y{docklocation_y|int - attachmove_y|int} F{travel_feedrate}
{% else %}
_KlackDebug msg="Dock_Probe moving near the dock with G0 X{docklocation_x|int - attachmove_x|int} F{travel_feedrate}"
G0 X{docklocation_x|int - attachmove_x|int} F{travel_feedrate}
{% endif %}

{% if docklocation_z != -128 %}
_KlackDebug msg="Dock_Probe moving near the dock with G0 Z{docklocation_z|int - attachmove_z|int} F{dock_feedrate}"
G0 Z{docklocation_z|int - attachmove_z|int} F{dock_feedrate}
{% endif %}

# Drop Probe to Probe location
{% if docklocation_y != -128 %}
_KlackDebug msg="Dock_Probe moving to the dock with G0 X{docklocation_x} Y{docklocation_y} F{dock_feedrate}"
G0 X{docklocation_x} Y{docklocation_y} F{dock_feedrate}
{% else %}
_KlackDebug msg="Dock_Probe moving to the dock with G0 X{docklocation_x} F{dock_feedrate}"
G0 X{docklocation_x} F{dock_feedrate}
{% endif %}

{% if dockmove_z != -128 %}
_KlackDebug msg="Attach_Probe moving to the dock with G0 Z{dockmove_z} F{dock_feedrate}"
G0 Z{dockmove_z} F{dock_feedrate}
{% endif %}

# Probe decoupling
{% if docklocation_z != -128 %}
_KlackDebug msg="Dock_Probe moving from the dock to G0 Z{docklocation_z|int + dockmove_z|int} F{release_feedrate}"
G0 Z{docklocation_z|int + dockmove_z|int} F{release_feedrate}
{% endif %}

{% if docklocation_y != -128 %}
_KlackDebug msg="Dock_Probe moving from the dock to G0 X{docklocation_x|int + dockmove_x|int} Y{docklocation_y|int + dockmove_y|int} F{release_feedrate}"
G0 X{docklocation_x|int + dockmove_x|int} Y{docklocation_y|int + dockmove_y|int} F{release_feedrate}
{% else %}
_KlackDebug msg="Dock_Probe moving from the dock to G0 X{docklocation_x|int + dockmove_x|int} F{release_feedrate}"
G0 X{docklocation_x|int + dockmove_x|int} F{release_feedrate}
{% endif %}

#Do an extra move away
{% if docklocation_y != -128 %}
_KlackDebug msg="Dock_Probe moving away from the dock to G0 X{docklocation_x|int + dockmove_x|int - attachmove_x|int} Y{docklocation_y|int + dockmove_y|int - attachmove_y|int} F{release_feedrate}"
G0 X{docklocation_x|int + dockmove_x|int - attachmove_x|int} Y{docklocation_y|int + dockmove_y|int - attachmove_y|int} F{release_feedrate}
{% else %}
_KlackDebug msg="Dock_Probe moving away from the dock to G0 X{docklocation_x|int + dockmove_x|int - attachmove_x|int} F{release_feedrate}"
G0 X{docklocation_x|int + dockmove_x|int - attachmove_x|int} F{release_feedrate}
{% endif %}

G0 X{docklocation_x|int - attachmove_x|int} F{travel_feedrate}
G0 X{docklocation_x} F{dock_feedrate}
G0 Z{dockmove_z} F{dock_feedrate}
G0 X{docklocation_x|int + dockmove_x|int} F{release_feedrate}

## Go to Z safe distance
{% if ((printer.toolhead.position.z < safe_z) or (docklocation_z != -128 and docklocation_z < safe_z ))%}
{% if (printer.toolhead.position.z < safe_z)%}
_KlackDebug msg="Dock_Probe moving to a safe Z position: G0 Z{safe_z} F{z_drop_feedrate} from {printer.toolhead.position.z}"
G0 Z{safe_z} F{z_drop_feedrate}
{% endif %}
Expand Down Expand Up @@ -362,16 +259,13 @@ description:Calibrate the probes z_offset with Klack automount
gcode:
{% set safe_z = printer["gcode_macro _User_Variables"].safe_z|float %}
{% set z_drop_feedrate = printer["gcode_macro _User_Variables"].z_drop_speed * 60 %}
{% set max_x = printer["gcode_macro _User_Variables"].max_bed_x|float %}
{% set max_y = printer["gcode_macro _User_Variables"].max_bed_y|float %}
{% set probe_offset_x = printer['configfile'].config["probe"]["x_offset"]|float %}
{% set probe_offset_y = printer['configfile'].config["probe"]["y_offset"]|float %}

{% if not 'xyz' in printer.toolhead.homed_axes %}
{ action_raise_error("Must Home X, Y and Z Axis First!") }
{% endif %}
_KlackDebug msg="probe_calibrate Axis homed"
_KlackDebug msg="probe_calibrate Variables max_x={max_x},max_y={max_y},probe_offset_x={probe_offset_x},probe_offset_y={probe_offset_y}"

_CheckProbe action=query
G90
Expand All @@ -397,16 +291,13 @@ description:Probe Z-height accuracy at current XY position with Klack automount
gcode:
{% set safe_z = printer["gcode_macro _User_Variables"].safe_z|float %}
{% set z_drop_feedrate = printer["gcode_macro _User_Variables"].z_drop_speed * 60 %}
{% set max_x = printer["gcode_macro _User_Variables"].max_bed_x|float %}
{% set max_y = printer["gcode_macro _User_Variables"].max_bed_y|float %}
{% set probe_offset_x = printer['configfile'].config["probe"]["x_offset"]|float %}
{% set probe_offset_y = printer['configfile'].config["probe"]["y_offset"]|float %}

{% if not 'xyz' in printer.toolhead.homed_axes %}
{ action_raise_error("Must Home X, Y and Z Axis First!") }
{% endif %}
_KlackDebug msg="probe_accuracy Axis homed"
_KlackDebug msg="probe_accuracy Variables max_x={max_x},max_y={max_y},probe_offset_x={probe_offset_x},probe_offset_y={probe_offset_y}"

_CheckProbe action=query
Attach_Probe back=1
Expand Down Expand Up @@ -439,7 +330,6 @@ gcode:
{% set dock_on_zhome = printer["gcode_macro _User_Variables"].dock_on_zhome|default(True) %}
{% set attachmove_x = printer["gcode_macro _User_Variables"].attachmove_x|default(0) %}
{% set attachmove_y = printer["gcode_macro _User_Variables"].attachmove_y|default(0) %}
{% set attachmove_z = printer["gcode_macro _User_Variables"].attachmove_z|default(0) %}
{% set z_drop_feedrate = printer["gcode_macro _User_Variables"].z_drop_speed * 60 %}
{% set travel_feedrate = printer["gcode_macro _User_Variables"].travel_speed * 60 %}
{% set home_backoff_x = printer["gcode_macro _User_Variables"].home_backoff_x|default(0) %}
Expand Down Expand Up @@ -534,13 +424,13 @@ gcode:
{% endif %}

# if the dock is oriented on the Y, first do Y endstop
{% if ((attachmove_y == 0 and override_homing == '' ) or (override_homing == 'Y'))%}
{% if (override_homing == '' or (override_homing == 'Y'))%}
# Home y
{% if home_y %}
{% if override_homing == 'Y' %}
_KlackDebug msg="homing_override Y homing first override, due to override_homing = Y"
{% else %}
_KlackDebug msg="homing_override Y homing first override, due to attachmove_y = 0"
_KlackDebug msg="homing_override Y homing first override"
{% endif %}
{% if verbose %}
{ action_respond_info("Homing Y") }
Expand Down Expand Up @@ -765,8 +655,8 @@ gcode:
[gcode_macro _Center_Probe]
gcode:
{% set travel_feedrate = printer["gcode_macro _User_Variables"].travel_speed * 60 %}
{% set max_x = printer["gcode_macro _User_Variables"].max_bed_x|float %}
{% set max_y = printer["gcode_macro _User_Variables"].max_bed_y|float %}
{% set max_x = printer["gcode_macro _User_Variables"].bed_size_x|float %}
{% set max_y = printer["gcode_macro _User_Variables"].bed_size_y|float %}
{% set probe_offset_x = printer['configfile'].config["probe"]["x_offset"]|float %}
{% set probe_offset_y = printer['configfile'].config["probe"]["y_offset"]|float %}
{% set probe_x = max_x / 2 - probe_offset_x %}
Expand All @@ -778,8 +668,8 @@ gcode:
[gcode_macro _Center_Nozzle]
gcode:
{% set travel_feedrate = printer["gcode_macro _User_Variables"].travel_speed * 60 %}
{% set max_x = printer["gcode_macro _User_Variables"].max_bed_x|float %}
{% set max_y = printer["gcode_macro _User_Variables"].max_bed_y|float %}
{% set max_x = printer["gcode_macro _User_Variables"].bed_size_x|float %}
{% set max_y = printer["gcode_macro _User_Variables"].bed_size_|float %}
_Move_to_Safe_z
G0 X{max_x/2} Y{max_y/2} F{travel_feedrate}

Expand Down
48 changes: 18 additions & 30 deletions klack-variables.cfg
Original file line number Diff line number Diff line change
@@ -1,37 +1,31 @@
[gcode_macro _User_Variables]
variable_safe_z: 15 # Minimum Z for attach/dock and homing functions

variable_bed_size_y: 230 # Y bed size used for centering the toolhead
variable_bed_size_x: 230 # X bed size used for centering the toolhead

variable_docklocation_x: 236 # Dock X location where moving the toolhead during attach and dock

#Attach move
Variable_attachmove_x: 40 # Final movement done to remove the probe from the dock

#Dock move
Variable_dockmove_x: -100 # Final movement done to remove the probe from the toolhead
Variable_dockmove_z: 2 # Retainer location on Z, this is the ABSOLUTE Z height where toolhead will be moved to release the probe

variable_verbose: True # Enable verbose output
variable_debug: False # Enable Debug output

variable_safe_z: 15 # Minimum Z for attach/dock and homing functions
# if true it will move the bed away from the nozzle when Z is not homed
variable_enable_z_hop: True # set this to false for beds that fall significantly under gravity (almost to Z max)

variable_max_bed_y: 230 # maximum Bed size avoids doing a probe_accuracy outside the bed
variable_max_bed_x: 230 # maximum Bed size avoids doing a probe_accuracy outside the bed
# Not reviewed variables below

# if a separate Z endstop switch is in
# use, specify the coordinates of the switch here (Voron).
# use, specify the coordinates of the switch here.
# Set to 0 to have the probe move to center of bed
variable_z_endstop_x: 0
variable_z_endstop_y: 0

#Check the printer specific documentation on klipper Dock/Undock configuration, these are dummy values
#dock location
variable_docklocation_x: 236 # X Dock position
variable_docklocation_y: -128 # Y Dock position (-128 for a gantry/frame mount)
variable_docklocation_z: -128 # Z dock position (-128 for a gantry/frame mount)

#Dock move, final toolhead movement to release the probe on the dock
#it's a relative move
Variable_dockmove_x: -100
Variable_dockmove_y: 0
Variable_dockmove_z: 2 # ABSOLUTE POSITION, ACTS AS DOCK_LOCATION_Z

#Attach move. final toolhead movement to attach the probe on the mount
#it's a relative move
Variable_attachmove_x: 40
Variable_attachmove_y: 0
Variable_attachmove_z: 0
# if true it will move the bed away from the nozzle when Z is not homed
variable_enable_z_hop: True # set this to false for beds that fall significantly under gravity (almost to Z max)

# location to park the toolhead
variable_park_toolhead: False # Enable toolhead parking
Expand All @@ -41,12 +35,6 @@ variable_parkposition_z: 30 # -128 excludes Z - Park only on X-Y

variable_version: 1 # Helps users to update the necessary variables, do not update if the variables above are not updated

#Below this remark, you normally do not need to configure
#Attach move2
Variable_attachmove2_x: 0 # intermediate toolhead movement to attach
Variable_attachmove2_y: 0 # the probe on the dock
Variable_attachmove2_z: 0 # (can be negative)

variable_home_backoff_x: 0 # how many mm to move away from the X endstop after homing X
# this is useful for the voron v0 to enable the toolhead to move out of the way to allow an unstricted Y homing
variable_home_backoff_y: 0 # how many mm to move away from the Y endstop after homing Y
Expand Down

0 comments on commit a0b2184

Please sign in to comment.