klipper-config/macros.cfg

118 lines
4.9 KiB
INI

# This file provides Klipper G-Code macros.
# See docs/Config_Reference.md for a description of parameters.
######################################################################
# Start Print and End Print
######################################################################
# Replace the slicer's custom start and end g-code scripts with
# START_PRINT and END_PRINT. See docs/Slicers.md for more information on using these macros.
[gcode_macro START_PRINT]
gcode:
# This part fetches data from your slicer. Such as bed temp, extruder temp and size of your printer.
{% set target_bed = params.BED|int %}
{% set target_extruder = params.EXTRUDER|int %}
{% set x_wait = printer.toolhead.axis_maximum.x|float / 2 %}
{% set y_wait = printer.toolhead.axis_maximum.y|float / 2 %}
# Homes the printer, sets absolute positioning, update the Stealthburner leds and clear old bed mesh.
STATUS_HOMING # Sets SB-leds to homing-mode
G28 # Full home (XYZ)
G90 # Absolute position
BED_MESH_CLEAR # Clears old saved bed mesh (if any)
# Heat up the bed with 5 minute soak.
RESPOND TYPE=echo_no_space MSG="Bed: {target_bed}c" # Displays info
STATUS_HEATING # Sets SB-leds to heating-mode
G1 X{x_wait} Y{y_wait} Z15 F9000 # Goes to center of the bed
M190 S{target_bed} # Sets the target temp for the bed
RESPOND TYPE=echo_no_space MSG="Soak for 5min" # Displays info
G4 P300000 # Waits 5 min for the bedtemp to stabilize
# Heating nozzle to 150 degrees. This helps with getting a correct Z-home
RESPOND TYPE=echo_no_space MSG="Hotend: 150c" # Displays info
M109 S150 # Heats the nozzle to 150c
# Adjust for gantry tilt.
RESPOND TYPE=echo_no_space MSG="Z-tilt adjust" # Displays info
STATUS_LEVELING # Sets SB-leds to leveling-mode
Z_TILT_ADJUST # Levels the x gantry via z_tilt_adjust
G28 Z # Homes Z again after z_tilt_adjust
# Take a mesh of the bed.
RESPOND TYPE=echo_no_space MSG="Bed mesh" # Displays info
STATUS_MESHING # Sets SB-leds to bed mesh-mode
BED_MESH_CALIBRATE # Starts bed mesh
# Parks the printhead, update the SB-leds and heat the nozzle.
RESPOND TYPE=echo_no_space MSG="Hotend: {target_extruder}c" # Displays info
STATUS_HEATING # Sets SB-leds to heating-mode
SMART_PARK # Move the printhead near the print area
M109 S{target_extruder} # Heats the nozzle to printing temp
# Gets ready to print by doing a purge line and updating the SB-leds
RESPOND TYPE=echo_no_space MSG="Printer goes brr" # Displays info
STATUS_PRINTING # Sets SB-leds to printing-mode
LINE_PURGE # Purge line
G90 # Absolute position
[gcode_macro END_PRINT]
gcode:
# Fetch maximum position for axis
{% set x_max = printer.toolhead.axis_maximum.x %}
{% set y_max = printer.toolhead.axis_maximum.y %}
# Turn off bed, extruder, and fan
M140 S0
M104 S0
M106 S0
# Move nozzle away from print while retracting
G91
G1 X-2 Y-2 E-3 F300
# Raise nozzle by 10mm
G1 Z10 F3000
G90
# Present print
G1 X{x_max} Y{y_max}
# Disable steppers
M84
######################################################################
# Filament Change
######################################################################
# M600: Filament Change. This macro will pause the printer, move the
# tool to the change position, and retract the filament 50mm. Adjust
# the retraction settings for your own extruder. After filament has
# been changed, the print can be resumed from its previous position
# with the "RESUME" gcode.
[pause_resume]
[gcode_macro M600]
gcode:
{% set X = params.X|default(50)|float %}
{% set Y = params.Y|default(0)|float %}
{% set Z = params.Z|default(10)|float %}
SAVE_GCODE_STATE NAME=M600_state
PAUSE
G91
G1 E-.8 F2700
G1 Z{Z}
G90
G1 X{X} Y{Y} F3000
FILAMENT_UNLOAD # Use orbiter sensor unload macro
RESTORE_GCODE_STATE NAME=M600_state
# Enable the "M118" and "RESPOND" extended commands.
[respond]
# Enable object exclusion
[exclude_object]