Skip to content

Instantly share code, notes, and snippets.

@rootiest
Last active December 13, 2023 17:07
Show Gist options
  • Save rootiest/b61ae9b6809269daa4fa8f159bdc40a1 to your computer and use it in GitHub Desktop.
Save rootiest/b61ae9b6809269daa4fa8f159bdc40a1 to your computer and use it in GitHub Desktop.
# Need this to send console messages
[respond]
[filament_switch_sensor runout_sensor]
pause_on_runout: False # This needs to be false to use runout_gcode
runout_gcode:
_filament_runout
insert_gcode:
_filament_insert
switch_pin:P1.26
[gcode_macro _filament_runout]
gcode:
SET_IDLE_TIMEOUT TIMEOUT=10800 # Set idle_timeout to 3hrs
#M104 S0 # turn off the hotend
#SAVE_GCODE_STATE is not required as PAUSE does this automatically
# See here: https://www.klipper3d.org/G-Codes.html#pause
BASE_PAUSE
G91 # Relative positioning
G1 E-10 F2100 # Retract 10mm of filament
G1 Z10 # Move Z up 10mm from current position
G90 # Absolute positioning
G1 X350 Y350 F6000 # Park at the coordinates you said you wanted
M106 S0 # Disable the part cooling fan
UPDATE_DELAYED_GCODE ID=runout_wait DURATION=300
[delayed_gcode runout_wait]
gcode:
# Honestly you probably shouldn't keep the hotend heated for 5 minutes as it's
# definitely going to leak a bunch of filament during that time, but anyway
M104 S0 # turn off the hotend
[gcode_macro _filament_insert]
gcode:
# Get the extruder min_extrude_temp (will be 150 if not defined)
{% set TARGET = printer.configfile.config.extruder.min_extrude_temp|float %}
# Get the current extruder temp
{% set TEMP = printer.extruder.temperature|float %}
{% if TEMP < TARGET %}
RESPOND TYPE=error MSG="Please heat the extruder before continuing."
{% else %}
RESPOND TYPE=error MSG="Press RESUME to continue."
{% endif %}
SET_IDLE_TIMEOUT TIMEOUT=900 # Set idle_timeout to 15 minutes
# Use this macro to heat the extruder and then resume like so:
#
# HEAT_AND_RESUME TARGET=220
#
[gcode_macro HEAT_AND_RESUME]
description: Heat the extruder and resume print when target is reached
gcode:
# Get the extruder min_extrude_temp (will be 150 if not defined)
{% set min_target = printer.configfile.config.extruder.min_extrude_temp|float %}
# Get the target from params or set it to min_target if none is given
{% set TARGET = params.TARGET|default(min_target)|float %}
# Heat the extruder and wait for the target to be reached
M109 S{TARGET}
# Notify that print is resuming
RESPOND TYPE=error MSG="Temperature reached. Resuming print."
# Resume print when target is reached
# This will automatically restore to the pre-PAUSE position
# See here: https://www.klipper3d.org/G-Codes.html#resume
RESUME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment