Skip to content

Instantly share code, notes, and snippets.

@NameOfTheDragon
Created April 22, 2021 02:23
Show Gist options
  • Save NameOfTheDragon/03eaf1b20ca07e5feacb86a6126679d1 to your computer and use it in GitHub Desktop.
Save NameOfTheDragon/03eaf1b20ca07e5feacb86a6126679d1 to your computer and use it in GitHub Desktop.
Klipper gcode macros that I use with my Creality Ender 3
# These macros are required for Fluidd to correctly function.
# You can copy these entries into your printer.cfg.
#
# Alternatively, import this file by adding
# this line into your printer.cfg;
#
# [include client_macros.cfg]
[gcode_macro CANCEL_PRINT]
rename_existing: BASE_CANCEL_PRINT
gcode:
TURN_OFF_HEATERS
CLEAR_PAUSE
SDCARD_RESET_FILE
SET_FAN_SPEED SPEED=0.25
LED_FAIL
BASE_CANCEL_PRINT
[gcode_macro PAUSE]
rename_existing: BASE_PAUSE
default_parameter_E: 1.7
gcode:
LED_PAUSED
{% set x_park = printer.toolhead.axis_minimum.x|float + 5.0 %}
{% set y_park = printer.toolhead.axis_maximum.y|float - 15.0 %}
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% if act_z < (max_z - 40) %}
{% set z_safe = 40 %}
{% else %}
{% set z_safe = max_z - act_z %}
{% endif %}
SAVE_GCODE_STATE NAME=PAUSE_state
BASE_PAUSE
G91
G1 E-{E} F2100
G1 Z{z_safe} F900
G90
G0 X{x_park} Y{y_park} F6000
G91
[gcode_macro RESUME]
rename_existing: BASE_RESUME
default_parameter_E: 1.7
gcode:
LED_PRINTING
G91
G1 E{E} F2100
RESTORE_GCODE_STATE NAME=PAUSE_state
BASE_RESUME
[gcode_macro START_PRINT]
default_parameter_BED_TEMPERATURE: 60
default_parameter_EXTRUDER_STANDBY_TEMPERATURE: 170
default_parameter_EXTRUDER_TEMPERATURE: 210
gcode:
LED_STARTING
G90 ; use absolute coordinates
M83 ; extruder relative mode
M106 S50 ; Fan on approx. 20% to protect cooling ducts
M140 S{BED_TEMPERATURE} ; set bed temp
M104 S{EXTRUDER_STANDBY_TEMPERATURE} ; set standby extruder temp
M190 S{BED_TEMPERATURE} ; wait for bed temp
; M109 S170 ; wait for extruder temp
G28 ; home all
G29 ; calibrate bed mesh levelling
M104 S{EXTRUDER_TEMPERATURE} ; set first layer extruder temp
M109 S{EXTRUDER_TEMPERATURE} ; wait for extruder temp
G1 Z2 F240
G1 X2 Y10 F3000
G1 Z0.28 F240
G92 E0.0
G1 Y210 E16.0 F1500.0 ; intro line
G1 X2.3 F5000
G1 Y10 E20 F1200.0 ; intro line
G92 E0.0
LED_PRINTING
[gcode_macro END_PRINT]
gcode:
LED_SUCCESS
{% set max_y = printer.toolhead.axis_maximum.y|float %}
# Move nozzle away from print while retracting
M83 ; Relative E
G91 ; Relative XYZ
G1 X-2 Y-2 Z+5 E-3 F300
G90 ; Absolute XYZ
M82 ; Absolute E
M104 S0 ; turn off temperature
M140 S0 ; turn off heatbed
M106 S50 ; Leave fan running to protect cooling ducts.
# Present print
G1 X0 Y210 F3000 ; present print
# Disable steppers
M84
[gcode_macro PRESENT_PLATE]
gcode:
{% set posy = printer.toolhead.axis_maximum.y|float %}
{% set posx = 5.0 %}
G0 X{posx} Y{posy} F3000
[gcode_macro LOAD_FILAMENT]
default_parameter_SPEED: 400
default_parameter_PRIME_SPEED: 300
gcode:
SAVE_GCODE_STATE NAME=__filament__load
M83
G1 E5 F75
G1 E50 F{SPEED}
G1 E35 F{SPEED}
G1 E20 F{PRIME_SPEED}
G1 E-1 F{SPEED}
RESTORE_GCODE_STATE NAME=__filament__load
[gcode_macro UNLOAD_FILAMENT]
default_parameter_SPEED: 400
gcode:
SAVE_GCODE_STATE NAME=__filament__load
M83
G1 E-13 F250
G1 E17 F250
G1 E-13 F250
G1 E17 F250
G1 E-50 F{SPEED}
G1 E-42 F{SPEED}
RESTORE_GCODE_STATE NAME=__filament__load
[gcode_macro Level]
gcode:
SCREWS_TILT_CALCULATE
[gcode_macro G29]
gcode:
BED_MESH_CALIBRATE
# F360 uses M420 to enable bed levelling, we'll treat it like G29.
[gcode_macro M420]
gcode:
BED_MESH_CALIBRATE
[gcode_macro M600]
gcode:
CHANGE_FILAMENT
[gcode_macro M601]
gcode:
CHANGE_FILAMENT
[gcode_macro CHANGE_FILAMENT]
default_parameter_RESUME_SPEED: 80
gcode:
M117 Change Filament
PAUSE
M117
@froggomad
Copy link

Thanks for this! Would you mind providing the definition for LED_STARTING, LED_PRINTING, and LED_SUCCESS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment