Skip to content

Instantly share code, notes, and snippets.

@catid
Created March 24, 2022 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save catid/2133a5f789c30df609a5aa3909d85bd7 to your computer and use it in GitHub Desktop.
Save catid/2133a5f789c30df609a5aa3909d85bd7 to your computer and use it in GitHub Desktop.
print_start
[gcode_macro PRINT_START]
gcode:
M117 Print Starting...
; Make sure we are not applying stale bed mesh or Z offset
SET_GCODE_OFFSET Z=0
BED_MESH_CLEAR
; Start heating bed
M140 S{params.BED}
; Initial home XYZ
G28
; Start heating nozzle
M104 S{params.EXTRUDER}
; Finish heating bed
M190 S{params.BED}
; Finish heating nozzle
M109 S{params.EXTRUDER}
; Redo Z homing after cleaning nozzle
G1 Z30 F900
G1 X125 Y125 Z30 F3600
G1 X1 F3600
clean_nozzle RETRACT=true
G1 X1 Y125 Z30 F3600
G1 X125 F3600
G28 Z
ATTACH_PROBE
; Auto-calibration of nozzle to bed offset
; Doing this as soon as possible to nozzle clean
CALIBRATE_Z
; Use original version to avoid attaching probe again
; TBD: QGL reportedly messes up the Z offset, but this seems to work fine
_QUAD_GANTRY_LEVEL
_BED_MESH_CALIBRATE
DOCK_PROBE
M117 Prime Line
G92 E0 ;Reset Extruder
G1 X65.0 Y243.3 Z0.25 F2500.0 ; Move to start position
G1 X5.0 F800.0 E10 ; Draw the first line
G1 X5.0 Y243.0 F2500.0 ; Move to side a little
G1 X65.0 F800.0 E20 ; Draw the second line
G92 E0 ; Reset Extruder
G1 X125 Z0.5 F8000.0 ; Move over to prevent blob squish
G1 Z0.2 F3600 ; Move Z Axis down to drop the string
G1 X200 F5000.0
G1 Z0.5 F3600
M117 Print Begin
[gcode_macro EXIT_BED]
gcode:
# safe anti-stringing move coords
{% set th = printer.toolhead %}
{% set x_safe = th.position.x + 20 * (1 if th.axis_maximum.x - th.position.x > 25 else -1) %}
{% set y_safe = th.position.y + 20 * (1 if th.axis_maximum.y - th.position.y > 25 else -1) %}
{% set z_safe = [th.position.z + 2, th.axis_maximum.z]|min %}
M400 ; wait for buffer to clear
; Retract to avoid oozing during initial calibration of next print
{% if printer.extruder.temperature >= 230 %}
G92 E0 ; zero the extruder
G1 E-5.0 F2400 ; retract filament
G92 E0 ; zero the extruder
{% endif %}
G90 ; absolute positioning
G1 X{x_safe} Y{y_safe} Z{z_safe} F5000 ; move nozzle off part at a diagonal to limit stringing
G1 X176 Y256 F3000 ; park nozzle in far right corner so it is closer to X homing
M107 ; turn off fan
; Remove calibrated Z offset
SET_GCODE_OFFSET Z=0
TURN_OFF_HEATERS
[gcode_macro PRINT_END]
gcode:
SAVE_GCODE_STATE NAME=STATE_PRINT_END
EXIT_BED
RESTORE_GCODE_STATE NAME=STATE_PRINT_END
[gcode_macro CANCEL_PRINT]
rename_existing: CANCEL_PRINT_BASE
gcode:
TURN_OFF_HEATERS
CANCEL_PRINT_BASE
EXIT_BED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment