Skip to content

Commit

Permalink
start_end: Add Z_TILT_ADJUST and QUAD_GANTRY_LEVEL
Browse files Browse the repository at this point in the history
Adds automatic support for Z_TILT_ADJUST and QUAD_GANTRY_LEVEL in
START_PRINT. Default behavior is inferred from config, but can be
configured via _km_options.
  • Loading branch information
jschuh committed Feb 13, 2023
1 parent 547cd91 commit c6cedac
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 9 deletions.
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -820,9 +820,10 @@ These are the customization options you can add to your
smaller or thinner beds you may want to reduce this value or disable it
entirely by setting it to `0.0`.

* `variable_start_level_bed_at_temp` *(default: True if bed_mesh configured)* -
If true the `PRINT_START` macro will run [`BED_MESH_CALIBRATE_FAST`](
#bed-mesh-improvements) once the bed has stabilized at its target temperature.
* `variable_start_level_bed_at_temp` *(default: True if `bed_mesh` configured
)* - If true the `PRINT_START` macro will run [`BED_MESH_CALIBRATE_FAST`](
#bed-mesh-improvements) after the bed has stabilized at its target
temperature.

* `variable_start_home_z_at_temp` *(default: True)* - Rehomes the Z axis once
the bed reaches its target temperature, to account for movement during
Expand All @@ -840,6 +841,14 @@ These are the customization options you can add to your
between the purge lines and the print area (if a `start_purge_length` is
provided).

* `variable_start_quad_gantry_level_at_temp` *(default: True if
`quad_gantry_level` configured)* - If true the `PRINT_START` macro will run
`QUAD_GANTRY_LEVEL` after the bed has stabilized at its target temperature.

* `variable_start_z_tilt_adjust_at_temp` *(default: True if `z_tilt`
configured)* - If true the `PRINT_START` macro will run `Z_TILT_ADJUST` after
the bed has stabilized at its target temperature.

You can further customize the `PRINT_START` macro by declaring your own override
wrapper. This can be useful for things like loading mesh/skew profiles, or any
other setup that may need to be performed prior to printing.
Expand Down
16 changes: 14 additions & 2 deletions globals.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,20 @@ variable_start_extruder_preheat_scale: 0.5
variable_start_bed_heat_delay: 2000
# Amount (in degrees C) to overshoot bed target temp before stabilizing.
variable_start_bed_heat_overshoot: 2.0
# Set to level bed in PRINT_START after stabilizing at temp; set 0 to disable.
# Set to level bed in PRINT_START after bed temp stabilizes; False to disable.
variable_start_level_bed_at_temp: True
# Set to rehome the Z in PRINT_START after the bed temperature stabilizes.
# Set to rehome Z in PRINT_START after bed temp stabilizes; False to disable.
variable_start_home_z_at_temp: True
# Set to clear adjustments (e.g. feedrate, extrusion, heater) at end of print.
variable_start_clear_adjustments_at_end: True
# Length of filament (in millimeters) to purge at print start.
variable_start_purge_length: 0.0 # 30 is a good starting point.
# Distance (in millimeters) between the purge lines and the print area.
variable_start_purge_clearance: 5.0
# Level gantry in PRINT_START after bed temp stabilizes; False to disable.
variable_start_quad_gantry_level_at_temp: True
# Adjust Z tilt in PRINT_START after bed temp stabilizes; False to disable.
variable_start_z_tilt_adjust_at_temp: True
# X and Y travel speed (in mm/m) for movement macros.
variable_travel_speed_xy: 3000
# Z travel speed in (mm/m) for movement macros.
Expand Down Expand Up @@ -119,6 +123,14 @@ gcode:
SET_GCODE_VARIABLE MACRO=_km_globals VARIABLE=start_level_bed_at_temp VALUE="{
1 if printer.bed_mesh is defined else 0}"
BED_MESH_CHECK
# Quad gantry behavior is based on config options.
SET_GCODE_VARIABLE MACRO=_km_globals VARIABLE=start_quad_gantry_level_at_temp VALUE="{
1 if printer.quad_gantry_level is defined else 0}"
BED_MESH_CHECK
# Z tilt behavior is based on config options.
SET_GCODE_VARIABLE MACRO=_km_globals VARIABLE=start_z_tilt_adjust_at_temp VALUE="{
1 if printer.z_tilt is defined else 0}"
BED_MESH_CHECK

# Use config to set default printable area.
{% set settings = printer.configfile.settings %}
Expand Down
19 changes: 15 additions & 4 deletions start_end.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ gcode:
{% set NOZZLE_SIZE = params.NOZZLE_SIZE|default(settings.NOZZLE_SIZE)|
default(printer.configfile.settings.extruder.nozzle_diameter)|float %}
{% set km = printer["gcode_macro _km_globals"] %}
{% set actions_at_temp = km.start_level_bed_at_temp or
km.start_quad_gantry_level_at_temp or
start_z_tilt_adjust_at_temp %}
{% set bed_at_target = (BED - printer.heater_bed.temperature)|abs < 0.3 %}
{% set bed_overshoot = (BED + (km.start_bed_heat_overshoot if
(BED and not bed_at_target) else 0.0),
Expand All @@ -33,7 +36,7 @@ gcode:
{% endif %}
# Start bed heating
M140 S{bed_overshoot}
{% if km.start_level_bed_at_temp %}
{% if actions_at_temp %}
# If we're going to run a bed level we heat the extruder only part way to
# avoid oozing all over the bed while probing.
M104 S{(km.start_extruder_preheat_scale * EXTRUDER)|round(0,'ceil')|int}
Expand All @@ -56,13 +59,21 @@ gcode:
_KM_PARK_IF_NEEDED HEATER="chamber" RANGE=ABOVE
M191 S{CHAMBER}
{% endif %}
{% if km.start_level_bed_at_temp %}
{% if actions_at_temp %}
M104 S{EXTRUDER} # set the final extruder target temperature
{% if km.start_home_z_at_temp and not bed_at_target %}
G28 Z # Re-home only the Z axis now that the bed has stabilized.
{% endif %}
BED_MESH_CALIBRATE_FAST{% if MESH_MIN %} MESH_MIN={MESH_MIN}{% endif
%}{% if MESH_MAX %} MESH_MAX={MESH_MAX}{% endif %}
{% if km.start_z_tilt_adjust_at_temp %}
Z_TILT_ADJUST
{% endif %}
{% if km.start_quad_gantry_level_at_temp %}
QUAD_GANTRY_LEVEL
{% endif %}
{% if km.start_level_bed_at_temp %}
BED_MESH_CALIBRATE_FAST{% if MESH_MIN %} MESH_MIN={MESH_MIN}{% endif
%}{% if MESH_MAX %} MESH_MAX={MESH_MAX}{% endif %}
{% endif %}
G4
{% endif %}
# Wait for extruder to reach temperature
Expand Down

0 comments on commit c6cedac

Please sign in to comment.