CR10S BLTouch 3.1 Klipper macros.cfg
🧩 Syntax:
# Adds print macros such as start print and end print.
# in cura, as start gcode you can define "START_PRINT" and end gcode "END_PRINT"
######################################################################
# Start Print and End Print
######################################################################
# Replace the slicer's custom start and end g-code scripts with
# START_PRINT and END_PRINT.
[gcode_macro START_PRINT]
#default_parameter_T_BED: 60
#default_parameter_T_EXTRUDER: 190
#default_parameter_Z_OFFSET: 0.0
gcode:
{% set T_BED = params.T_BED|default(60)|int %}
{% set T_EXTRUDER = params.T_EXTRUDER|default(200)|int %}
{% set Z_OFFSET = params.Z_OFFSET|default(-3.32)|float %}
# Use absolute coordinates
G90
# Reset the G-Code Z offset (adjust Z offset if needed)
SET_GCODE_OFFSET Z={Z_OFFSET|float}
# Home the printer
G28
# Use the bed mesh
BED_MESH_PROFILE LOAD=timeofprint
# Move the nozzle near the bed
G1 X0 Y20 Z5 F6000
# Heat bed and extruder. Keenovo bed is same speed as extruder so just go.
M140 S{T_BED}
M109 S{T_EXTRUDER}
M190 S{T_BED}
# Prime line
PRIME_LINE
[gcode_macro END_PRINT]
gcode:
M117 Done printing :)
# move z up
G91
G1 E-3 Z+10 F3000
# absolute xy
G90
G1 X10 Y220 F2000
#disable hotend and heated bed
M104 S0
M140 S0
# disable steppers
M84
BED_MESH_CLEAR
# prime the nozzle
[gcode_macro PRIME_LINE]
gcode:
M117 Prime Line
G92 E0 ;Reset Extruder
# move z axis
G1 Z2.0 F3000 ;Move Z Axis up
# move to prime position
G1 X20 Y30 Z0.28 F5000.0 ;Move to start position
G1 X20 Y200.0 Z0.28 F1500.0 E15 ;Draw the first line
G1 X22 Y200.0 Z0.28 F5000.0 ;Move to side a little
G1 X22 Y50 Z0.28 F1500.0 E30 ;Draw the second line
G92 E0 ;Reset Extruder
G1 Z2.0 F3000 ;Move Z Axis up
# G29 that does (1) home all (2) get bed mesh (3) move nozzle to corner so it doesnt ooze on the bed while heating up.
[gcode_macro G29]
gcode:
G28
BED_MESH_CALIBRATE
G0 X0 Y0 Z10 F6000
BED_MESH_PROFILE save=timeofprint
# Park toolhead
[gcode_macro M125]
gcode:
SAVE_GCODE_STATE NAME=parking
M117 Parking toolhead
G91
G1 Z20 F600 # move up 5 mm
G90
G1 X125 Y0 F4000 # move to park position
RESTORE_GCODE_STATE NAME=parking
# LOW_TEMP_CHECK checks if there is a setpoint for the extruder. Untested!
# - If this setpoint is reached, continue.
# - If not, heat to setpoint.
# - If no setpoint, heat to parameter T (default@200)
[gcode_macro LOW_TEMP_CHECK]
#default_parameter_T: 230
gcode:
{% set T = params.T|default(230)|int %}
{% if printer.extruder.target != 0 %} # if there is a setpoint for extruder
{% if printer.extruder.temperature < printer.extruder.target %} # if not reached, heat
M118 Heating from {printer.extruder.temperature} to {printer.extruder.target}.
M109 S{printer.extruder.target|float}
{% endif %}
{% else %} # if no setpoint for extruder
{% if printer.extruder.target < T %} # heat to T.
M118 No setpoint, heating to {T}.
M109 S{T}
{% endif %}
{% endif %}
# load filament
[gcode_macro M701]
gcode:
SAVE_GCODE_STATE NAME=loading_filament
M117 Loading Filament
M83
G92 E0.0
LOW_TEMP_CHECK
G1 E420 F6000 # length of bowden tube till cold-end (~420mm)
G1 E100 F200 # some extra to prime the nozzle --> slower
G92 E0.0
RESTORE_GCODE_STATE NAME=loading_filament
# unload filament
[gcode_macro M702]
gcode:
SAVE_GCODE_STATE NAME=unloading_filament
M125 # park
M117 Unloading Filament
LOW_TEMP_CHECK
G91 # set relative
G1 E10 F100
G92 E0.0
G1 E-530 F6000 # the E is the length of the bowden tube (420mm) + 100 mm.
G92 E0.0
RESTORE_GCODE_STATE NAME=unloading_filament
# filament change
[gcode_macro M600]
gcode:
M117 Filament Change
M118 Filament Change
SAVE_GCODE_STATE NAME=filament_change
PAUSE
LOW_TEMP_CHECK
G91 # relative
G1 E-1 F300 # retract 1
M125 # park
M702 # unload
M117 New filament
M118 New filament
COUNTDOWN TIME=25 MSG="Switch"
M701
COUNTDOWN TIME=10 MSG="Clean"
RESUME
M117 Resuming
M118 Resuming
RESTORE_GCODE_STATE NAME=filament_change
M117 Printing..
M118 Printing..
[gcode_macro COUNTDOWN]
#default_parameter_MSG: "Time: "
#default_parameter_TIME: 10
gcode:
{% set MSG = "Time: " %}
{% set TIME = params.TIME|default(10)|int %}
# countdown
{% for s in range(TIME|int, 0, -1) %}
# dwell 1 second
G4 P1000
# echo
M117 {params.MSG} {s}s
M118 {params.MSG} {s}s
{% endfor %}