Skip to content

Instantly share code, notes, and snippets.

@catid
Created March 18, 2022 21:26
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/fd80e06b8a39806e82ecf4eaa4b89418 to your computer and use it in GitHub Desktop.
Save catid/fd80e06b8a39806e82ecf4eaa4b89418 to your computer and use it in GitHub Desktop.
printer.cfg
[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
G1 Z30 F900
G1 X125 Y125 Z30 F3600
G92 E0 ;Reset Extruder
# move to prime position
G1 X65.5 Y240.0 Z0.3 F2500.0 ; Move to start position
G1 X5.5 Y240.0 Z0.3 F800.0 E10 ; Draw the first line
G1 X5.5 Y239.5 Z0.3 F2500.0 ; Move to side a little
G1 X65.5 Y239.5 Z0.3 F800.0 E20 ; Draw the second line
G92 E0 ; Reset Extruder
G1 Z2.0 F3600 ; Move Z Axis up little to prevent scratching of Heat Bed
G1 X230 Y230 Z2.0 F5000.0 ; Move over to prevent blob squish
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-35.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 Y258 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