# https://klipperscreen.readthedocs.io/en/latest/macros/#recommended [gcode_macro PAUSE] description: Pause the actual running print rename_existing: PAUSE_BASE variable_saved_fan_speed: 0.0 gcode: # SAVE_GCODE_STATE NAME=PAUSE_MACRO_state # Save current fan speed {% set current_fan = printer.fan.speed %} SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=saved_fan_speed VALUE={current_fan} # Current position {% set x = printer.toolhead.position.x|float %} {% set y = printer.toolhead.position.y|float %} # Determine target positions {% set target_x = 340 if (x < 340 or x > 350) else x %} {% set target_y = 340 if (y < 340 or y > 350) else y %} # Only move if needed {% if target_x != x or target_y != y %} G90 G1 X{target_x} Y{target_y} F12000 {% endif %} # Pause print PAUSE_BASE _TOOLHEAD_PARK_PAUSE_CANCEL # Set fan to S28 (28/255 ≈ 0.1098) M106 S28 [gcode_macro RESUME] description: Resume the actual running print rename_existing: RESUME_BASE variable_skip_restore: 0 gcode: {% set extrude = printer['gcode_macro _TOOLHEAD_PARK_PAUSE_CANCEL'].extrude %} {% set skip = printer['gcode_macro RESUME'].skip_restore|int %} #### get VELOCITY parameter if specified #### {% if 'VELOCITY' in params|upper %} {% set get_params = ('VELOCITY=' + params.VELOCITY) %} {%else %} {% set get_params = "" %} {% endif %} ##### end of definitions ##### {% if printer.extruder.can_extrude|lower == 'true' %} M83 G1 E{extrude} F2100 {% if printer.gcode_move.absolute_extrude |lower == 'true' %} M82 {% endif %} {% else %} {action_respond_info("Extruder not hot enough")} {% endif %} #BLOBIFIER_CLEAN #G1 Z10 # Restore saved fan speed {% set old_fan = printer["gcode_macro PAUSE"].saved_fan_speed %} {% if old_fan > 0 %} {% set fan_pwm = (old_fan * 255) | int %} {% if fan_pwm > 255 %} {% set fan_pwm = 255 %} {% endif %} M106 S{fan_pwm} {% else %} M107 {% endif %} {% if skip == 0 %} # RESTORE_GCODE_STATE name=PAUSE_MACRO_state RESUME_BASE {get_params} {% else %} RESPOND PREFIX="AFC" MSG="Skipping RESTORE_GCODE_STATE (drift resume)" {% endif %} _status_printing CLEAR_PAUSE RESET_FAILURE SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=skip_restore VALUE=0 [gcode_macro _TOOLHEAD_PARK_PAUSE_CANCEL] description: Helper: park toolhead used in PAUSE and CANCEL_PRINT variable_extrude: 2.0 gcode: ##### set park positon for x and y ##### # default is your max posion from your printer.cfg # {% set x_park = printer.toolhead.axis_maximum.x|float - 5.0 %} {% set x_park = 20.0 %} {% set y_park = printer.toolhead.axis_maximum.y|float - 5.0 %} {% set z_park_delta = 2.0 %} ##### calculate save lift position ##### {% set max_z = printer.toolhead.axis_maximum.z|float %} {% set act_z = printer.toolhead.position.z|float %} {% if act_z < (max_z - z_park_delta) %} {% set z_safe = z_park_delta %} {% else %} {% set z_safe = max_z - act_z %} {% endif %} ##### end of definitions ##### {% if printer.extruder.can_extrude|lower == 'true' %} M83 G1 E-{extrude} F2100 {% if printer.gcode_move.absolute_extrude |lower == 'true' %} M82 {% endif %} {% else %} {action_respond_info("Extruder not hot enough")} {% endif %} {% if "xyz" in printer.toolhead.homed_axes %} G91 G1 Z{z_safe} F900 G90 G1 X{x_park} Y{y_park} F6000 {% if printer.gcode_move.absolute_coordinates|lower == 'false' %} G91 {% endif %} {% else %} {action_respond_info("Printer not homed")} {% endif %} [gcode_macro CANCEL_PRINT] description: Cancel the actual running print rename_existing: CANCEL_PRINT_BASE_KLIPPERSCREEN variable_park: True gcode: ## Move head and retract only if not already in the pause state and park set to true {% if printer.pause_resume.is_paused|lower == 'false' and park|lower == 'true'%} _TOOLHEAD_PARK_PAUSE_CANCEL {% endif %} STOP_HEAT_SOAK TURN_OFF_HEATERS CANCEL_PRINT_BASE_KLIPPERSCREEN [gcode_macro LOAD_FILAMENT] variable_load_distance: 60 variable_purge_distance: 20 gcode: {% set speed = params.SPEED|default(15) %} {% set max_velocity = printer.configfile.settings['extruder'].max_extrude_only_velocity * 15 %} SAVE_GCODE_STATE NAME=load_state G91 G92 E0 G1 E{load_distance} F{max_velocity} # fast-load G1 E{purge_distance} F{speed} # purge RESTORE_GCODE_STATE NAME=load_state [gcode_macro UNLOAD_FILAMENT] variable_unload_distance: 100 variable_purge_distance: 0 gcode: {% set speed = params.SPEED|default(15) %} {% set max_velocity = printer.configfile.settings['extruder'].max_extrude_only_velocity * 30 %} SAVE_GCODE_STATE NAME=unload_state G91 G92 E0 G1 E{purge_distance} F{speed} # purge G1 E-20 F100# unload G1 E-{unload_distance} F{max_velocity} # fast-unload RESTORE_GCODE_STATE NAME=unload_state [gcode_macro M600] # # M600 # https://github.com/simplisticton/common-macros/tree/main # # Mimic Marlin's Pause for filament change command description: Pause for filament change gcode: PAUSE M117 Paused M118 Print paused for filament change... type "Resume" to continue