Skip to content

Instantly share code, notes, and snippets.

@profesor79
Created June 24, 2025 23:23
Show Gist options
  • Save profesor79/1e926784ad06b1d0f1c39dc243a42306 to your computer and use it in GitHub Desktop.
Save profesor79/1e926784ad06b1d0f1c39dc243a42306 to your computer and use it in GitHub Desktop.
co-print
[pause_resume]
[display_status]
#[virtual_sdcard]
#path: ~/printer_1_data/gcodes
#Change this parameter according to which printer you are using in ChromaPad.
#Example: 3rd printer "path: ~/printer_3_data/gcodes"
#[bed_screws]
#You can change these values ​​​​according to the size of your printer and verify manually.
#screw1: 30, 30
#screw2: 150, 30
#screw3: 30, 150
#screw4: 150, 150
[gcode_macro LOAD_FILAMENT]
gcode:
M83
G1 E100 F300
M118
[gcode_macro PARK_FILAMENT]
gcode:
M83
G1 E-100 F300
[gcode_macro _TOOLHEAD_PARK_PAUSE_CANCEL]
description: Helper: park toolhead used in PAUSE and CANCEL_PRINT
variable_extrude: 1.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 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
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 %}
FILAMENT_CUT
G91
G1 E-78
TURN_OFF_HEATERS
CANCEL_PRINT_BASE
[gcode_macro PAUSE]
description: Pause the actual running print
rename_existing: PAUSE_BASE
gcode:
PAUSE_BASE
_TOOLHEAD_PARK_PAUSE_CANCEL
[gcode_macro RESUME]
description: Resume the actual running print
rename_existing: RESUME_BASE
gcode:
##### read extrude from _TOOLHEAD_PARK_PAUSE_CANCEL macro #####
{% set extrude = printer['gcode_macro _TOOLHEAD_PARK_PAUSE_CANCEL'].extrude %}
#### 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 %}
RESUME_BASE {get_params}
[gcode_macro END_PRINT]
gcode:
{% set x_stop = params.X|default(printer.toolhead.axis_maximum.x-5)|int %}
{% set y_stop = params.Y|default(printer.toolhead.axis_maximum.y-5)|int %}
{% set z_stop = printer.toolhead.axis_maximum.z|int %}
{% set z_pos = printer.toolhead.position.z|int %}
{% if z_pos < (z_stop-6) %}
G91
G1 E-2 F2700
G1 Z5
{% else %}
G91
G1 E-2 F2700
G1 Z1
{% endif %}
FILAMENT_CUT
G1 E-78
G90
G1 X{x_stop} Y{y_stop}
M106 S0
M104 S0
M140 S0
[gcode_macro START_PRINT]
gcode:
{% set BED_TEMP = params.BED_TEMP|default(60)|float %}
{% set EXTRUDER = params.EXTRUDER|default(0)|int %}
{% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(200)|float %}
{% set axismax = printer.toolhead.axis_maximum %}
{% set axismin_x = printer.toolhead.axis_minimum.x %}
{% set axismin_y = printer.toolhead.axis_minimum.y %}
# Home the printer
G28
# Heat bed for probing
M190 S{BED_TEMP}
# Use absolute coordinates
G90
BED_MESH_PROFILE LOAD=default
G1 Z10 F450
M109 S{EXTRUDER_TEMP}
T{EXTRUDER}
{% if axismax.x > 196 %}
G92 E0
G1 X0 Y152 Z0.4 F900
G92 E0
G1 Y77 E20 F900
G92 E0
G1 Y2 E20 F900
G92 E0
G1 X98 E30 F900
G92 E0
G1 X196 E30 F900
G92 E0
G1 Y4 F900
G92 E0
G1 X98 E30 F900
G92 E0
G1 X2 E30 F900
G92 E0
G1 Y77 E20 F900
G92 E0
G1 Y152 E20 F900
G92 E0 ;Reset Extruder
{% else %}
{% if axismax.y > 153 %}
G92 E0 ;Reset Extruder
G1 X{axismin_x + 2} Y152 Z0.4 F900 ;Move to start position
G92 E0
G1 Y77 E20 F900 ;Draw the first line
G92 E0
G1 Y2 E20 F900 ;Draw the first line
G92 E0
G1 X{axismax.x / 2} E30 F900 ;Draw the first line
G92 E0
G1 X{axismax.x - 2} E30 F900 ;Draw the first line
G92 E0
G1 Y{axismin_y + 4} F900 ;Draw the first line
G92 E0
G1 X{axismax.x / 2} E30 F900 ;Draw the first line
G92 E0
G1 X{axismin_x + 4} E30 F900 ;Draw the first line
G92 E0
G1 Y77 E20 F900 ;Draw the first line
G92 E0
G1 Y152 E20 F900
G92 E0
{% else %}
G92 E0 ;Reset Extruder
G1 X{axismin_x + 2} Y{axismax.Y - 2} Z0.4 F900 ;Move to start position
G92 E0
G1 Y{axismax.Y / 2} E20 F900 ;Draw the first line
G92 E0
G1 Y2 E20 F900 ;Draw the first line
G92 E0
G1 X{axismax.x / 2} E30 F900 ;Draw the first line
G92 E0
G1 X{axismax.x - 2} E30 F900 ;Draw the first line
G92 E0
G1 Y{axismin_y + 4} F900 ;Draw the first line
G92 E0
G1 X{axismax.x / 2} E30 F900 ;Draw the first line
G92 E0
G1 X{axismin_x + 4} E30 F900 ;Draw the first line
G92 E0
G1 Y{axismax.Y / 2} E20 F900 ;Draw the first line
G92 E0
G1 Y{axismax.Y - 2} E20 F900
G92 E0
{% endif %}
{% endif %}
G92 E0 ;Reset Extruder
[exclude_object]
#The following code should be added to the start gcode section of the slicer application used.
#start_print EXTRUDER=[initial_extruder] EXTRUDER_TEMP=[nozzle_temperature_initial_layer] BED_TEMP=[bed_temperature_initial_layer_single]
[respond]
default_type: echo
default_prefix:
[gcode_macro SET_FILAMENT_POSITION]
gcode:
RESPOND TYPE=command MSG="action:prompt_begin Set Filament Position"
RESPOND TYPE=command MSG="action:prompt_text Make sure the extruder is sufficiently heated and the correct extruder is selected."
RESPOND TYPE=command MSG="action:prompt_button_group_start"
RESPOND TYPE=command MSG="action:prompt_button T0|T0|primary"
RESPOND TYPE=command MSG="action:prompt_button T1|T1|primary"
RESPOND TYPE=command MSG="action:prompt_button T2|T2|primary"
RESPOND TYPE=command MSG="action:prompt_button T3|T3|primary"
RESPOND TYPE=command MSG="action:prompt_button_group_end"
RESPOND TYPE=command MSG="action:prompt_button_group_start"
RESPOND TYPE=command MSG="action:prompt_button EXTRUDE|EXTRUDE_H|warning"
RESPOND TYPE=command MSG="action:prompt_button SET|SET_FILAMENT|warning"
RESPOND TYPE=command MSG="action:prompt_button_group_end"
RESPOND TYPE=command MSG="action:prompt_show"
[gcode_macro EXTRUDE_H]
gcode:
{% set temperature = printer.extruder.temperature|int %}
{% if temperature > 199 %}
G92 E0
G1 E20 F500
G92 E0
G1 E20 F500
G92 E0
G1 E20 F500
G92 E0
G1 E20 F500
G92 E0
G1 E20 F500
G92 E0
{% endif %}
[gcode_macro SET_FILAMENT]
gcode:
FILAMENT_CUT
G92 E0
G1 E-20 F500
G92 E0
G1 E-20 F500
G92 E0
G1 E-20 F500
G92 E0
G1 E-20 F500
G92 E0
G1 E-20 F500
G92 E0
[gcode_macro FILAMENT_CHANGE]
gcode:
{% set LAYER_NUM = params.LAYER_NUM|int %}
{% set NEXT_EXTRUDER = params.NEXT_EXTRUDER|int %}
{% if LAYER_NUM == -1 %}
{% endif %}
{% if LAYER_NUM != -1 %}
{LAYER_NUM}
FILAMENT_CUT
G4 P300
G91
G1 X10 E-20 F300
G92 E0
G1 X-20 E-40 F500
G92 E0
G1 X10 E-40 F600
T{NEXT_EXTRUDER}
G92 E0
G1 X-10 E25 F500
G92 E0
G1 X10 E25 F300
G92 E0
G1 X-10 E25 F300
G92 E0
G1 X10 E25 F300
G90
{% endif %}
# FILAMENT_CHANGE LAYER_NUM=[layer_num] NEXT_EXTRUDER=[next_extruder]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment