######################################## # M600 Support ######################################## [respond] [idle_timeout] gcode: RESPOND TYPE=command MSG="Stopping hotend heating..." M104 S0 timeout: 99999999 [filament_switch_sensor filament_sensor] pause_on_runout: true switch_pin: !PC15 runout_gcode: M600 [gcode_macro M600] description: Filament Change variable_m600_state: 0 gcode: {% set E = printer["gcode_macro PAUSE"].extrude|float %} {% set y_park = printer.toolhead.axis_minimum.y|float + 5.0 %} {% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %} {% set max_z = printer["gcode_macro PRINTER_PARAM"].max_z_position|float %} {% set act_z = printer.toolhead.position.z|float %} {% set z_safe = 0.0 %} {% if act_z < 48.0 %} {% set z_safe = 50.0 - act_z %} {% elif act_z < (max_z - 2.0) %} {% set z_safe = 2.0 %} {% elif act_z < max_z %} {% set z_safe = max_z - act_z %} {% endif %} {action_respond_info("z_safe = %s"% (z_safe))} SET_GCODE_VARIABLE MACRO=M600 VARIABLE=m600_state VALUE=1 SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=hotend_temp VALUE={printer.extruder.target} RESPOND TYPE=command MSG="Print paused for filament change!" PAUSE_BASE G91 {% if "xyz" in printer.toolhead.homed_axes %} {% if printer.extruder.can_extrude|lower == 'true' %} G1 E-1.0 F180 G1 E-{E} F4000 {% else %} RESPOND TYPE=command MSG="Extruder not hot enough!" {% endif %} G1 Z{z_safe} F600 M400 G90 G1 X{x_park} Y{y_park} F30000 {% endif %} G91 {% if printer.extruder.can_extrude|lower == 'true' %} RESPOND TYPE=command MSG="Extracting filament..." G1 E20 F180 G1 E-30 F180 G1 E-50 F2000 {% else %} RESPOND TYPE=command MSG="Extruder not hot enough!" {% endif %} SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=fan2_speed VALUE={printer['output_pin fan2'].value} SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=fan0_speed VALUE={printer['output_pin fan0'].value} M106 P0 S0 M106 P2 S0 SET_IDLE_TIMEOUT TIMEOUT=900 SET_E_MIN_CURRENT RESPOND TYPE=command MSG="Replace filament at the extruder inlet and click on Resume button!" [gcode_macro RESUME] description: Resume the current print rename_existing: RESUME_BASE gcode: RESTORE_E_CURRENT {% if printer['gcode_macro PRINTER_PARAM'].hotend_temp|int != 0 %} {% if printer['gcode_macro PRINTER_PARAM'].hotend_temp|int > printer.extruder.temperature %} RESPOND TYPE=command MSG="Starting hotend heating..." M109 S{printer['gcode_macro PRINTER_PARAM'].hotend_temp|int} {% else %} RESPOND TYPE=command MSG="Starting hotend heating..." M104 S{printer['gcode_macro PRINTER_PARAM'].hotend_temp|int} {% endif %} SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=hotend_temp VALUE=0 {% endif %} {% if printer['gcode_macro PRINTER_PARAM'].fan2_speed > 0 %} {% set s_value = (printer['gcode_macro PRINTER_PARAM'].fan2_speed * 255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) * 255 / (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min)|float %} M106 P2 S{s_value} {% endif %} {% set z_resume_move = printer['gcode_macro PRINTER_PARAM'].z_safe_pause|int %} {% if z_resume_move > 2 %} {% set z_resume_move = z_resume_move - 2 %} G91 G1 Z-{z_resume_move} F600 M400 {% endif %} {% set E = printer["gcode_macro PAUSE"].extrude|float + 1.0 %} {% if 'VELOCITY' in params|upper %} {% set get_params = ('VELOCITY=' + params.VELOCITY) %} {%else %} {% set get_params = "" %} {% endif %} {% if printer["gcode_macro M600"].m600_state == 1 %} {% if printer.extruder.can_extrude|lower == 'true' %} RESPOND TYPE=command MSG="Loading and purging filament..." G91 G1 E180 F180 G90 M400 {% else %} RESPOND TYPE=command MSG="Extruder not hot enough!" {% endif %} {% if printer['gcode_macro PRINTER_PARAM'].fan0_speed > 0 %} {% set s_value = (printer['gcode_macro PRINTER_PARAM'].fan0_speed * 255 - printer['gcode_macro PRINTER_PARAM'].fan0_min) * 255 / (255 - printer['gcode_macro PRINTER_PARAM'].fan0_min)|float %} M106 P0 S{s_value} {% endif %} SET_GCODE_VARIABLE MACRO=M600 VARIABLE=m600_state VALUE=0 SET_IDLE_TIMEOUT TIMEOUT=99999999 {% else %} {% if printer.extruder.can_extrude|lower == 'true' %} G91 G1 E{E} F2100 G90 M400 {% else %} RESPOND TYPE=command MSG="Extruder not hot enough!" {% endif %} {% endif %} RESPOND TYPE=command MSG="Restarting print..." RESUME_BASE {get_params}