-
Notifications
You must be signed in to change notification settings - Fork 0
/
Voron_Purge.cfg
95 lines (85 loc) · 7.04 KB
/
Voron_Purge.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# # # Klipper Adaptive Purging - VoronDesign Logo # # #
# This macro will parse information from objects in your gcode to define a min and max area, creating a nearby purge with Voron flair!
# For successful purging, you may need to configure:
#
# [extruder]
# ...
# max_extrude_cross_section: 5
[gcode_macro VORON_PURGE]
description: A purge macro that adapts to be near your actual printed objects
variable_adaptive_enable: True # Change to False if you'd like the purge to be in the same spot every print
variable_z_height: 0.4 # Height above the bed to purge
variable_tip_distance: 10 # Distance between filament tip and nozzle before purge (this will require some tuning)
variable_purge_amount: 40 # Amount of filament to purge
variable_flow_rate: 4 # Desired flow rate in mm3/s
variable_x_default: 10 # X location to purge, overwritten if adaptive is True
variable_y_default: 10 # Y location to purge, overwritten if adaptive is True
variable_size: 10 # Size of the logo
variable_distance_to_object_x: 10 # Distance in x to the print area
variable_distance_to_object_y: 10 # Distance in y to the print area
### This section is for those who are using Moonraker's Update Manager for KAMP, or want a more verbose macro. ###
variable_display_parameters: True # Display macro paramters in the console, useful for debugging the SETUP_VORON_PURGE call, or more verbosity.
gcode:
{% if display_parameters == True %}
{ action_respond_info("adaptive_enable : %d" % (adaptive_enable)) }
{ action_respond_info("z_height : %f" % (z_height)) }
{ action_respond_info("tip_distance : %f" % (tip_distance)) }
{ action_respond_info("purge_amount : %f" % (purge_amount)) }
{ action_respond_info("flow_rate : %f" % (flow_rate)) }
{ action_respond_info("x_default : %f" % (x_default)) }
{ action_respond_info("y_default : %f" % (y_default)) }
{ action_respond_info("size : %f" % (size)) }
{ action_respond_info("distance_to_object_x : %f" % (distance_to_object_x)) }
{ action_respond_info("distance_to_object_y : %f" % (distance_to_object_y)) }
{% endif %}
{% if adaptive_enable == True %}
{% set all_points = printer.exclude_object.objects | map(attribute='polygon') | sum(start=[]) %}
{% set x_origin = (all_points | map(attribute=0) | min | default(x_default + distance_to_object_x + size)) - distance_to_object_x - size %}
{% set y_origin = (all_points | map(attribute=1) | min | default(y_default + distance_to_object_y + size)) - distance_to_object_y - size %}
{% set x_origin = ([x_origin, 0] | max) %}
{% set y_origin = ([y_origin, 0] | max) %}
{% else %}
{% set x_origin = x_default | float %}
{% set y_origin = y_default | float %}
{% endif %}
{% set purge_move_speed = 2.31 * size * flow_rate / (purge_amount * 2.405) %}
{% set prepurge_speed = flow_rate / 2.405 %}
{% set travel_speed = printer.toolhead.max_velocity %}
{ action_respond_info( "x: " + x_origin|string + " y: " + y_origin|string + " purge_move_speed: " + purge_move_speed|string + " prepurge_speed: " + prepurge_speed|string ) }
G92 E0 # Reset extruder
G0 F{travel_speed*60} # Set travel speed
G90 # Absolute positioning
G0 X{x_origin} Y{y_origin+size/2} # Move to purge position
G0 Z{z_height} # Move to purge Z height
M83 # Relative extrusion mode
G1 E{tip_distance} F{prepurge_speed*60} # Move tip of filament to nozzle
G1 X{x_origin+size*0.289} Y{y_origin+size} E{purge_amount/4} F{purge_move_speed*60} # Purge first line of logo
G1 E-.5 F2100 # Retract
G0 Z{z_height*2} # Z hop
G0 X{x_origin+size*0.789} Y{y_origin+size} # Move to second purge line origin
G0 Z{z_height} # Move to purge Z height
G1 E.5 F2100 # Recover
G1 X{x_origin+size*0.211} Y{y_origin} E{purge_amount/2} F{purge_move_speed*60} # Purge second line of logo
G1 E-.5 F2100 # Retract
G0 Z{z_height*2} # Z hop
G0 X{x_origin+size*0.711} Y{y_origin} # Move to third purge line origin
G0 Z{z_height} # Move to purge Z height
G1 E.5 F2100 # Recover
G1 X{x_origin+size} Y{y_origin+size/2} E{purge_amount/4} F{purge_move_speed*60} # Purge third line of logo
G1 E-.5 F2100 # Retract
G92 E0 # Reset extruder distance
M82 # Absolute extrusion mode
G0 Z{z_height*2} # Z hop
[gcode_macro SETUP_VORON_PURGE]
gcode:
SET_GCODE_VARIABLE MACRO=VORON_PURGE VARIABLE=display_parameters VALUE={params.DISPLAY_PARAMETERS|default(True)|int}
SET_GCODE_VARIABLE MACRO=VORON_PURGE VARIABLE=adaptive_enable VALUE={params.ADAPTIVE_ENABLE|default(True)|int}
SET_GCODE_VARIABLE MACRO=VORON_PURGE VARIABLE=z_height VALUE={params.Z_HEIGHT|default(0.4)|float}
SET_GCODE_VARIABLE MACRO=VORON_PURGE VARIABLE=tip_distance VALUE={params.TIP_DISTANCE|default(10)|float}
SET_GCODE_VARIABLE MACRO=VORON_PURGE VARIABLE=purge_amount VALUE={params.PURGE_AMOUNT|default(40)|float}
SET_GCODE_VARIABLE MACRO=VORON_PURGE VARIABLE=flow_rate VALUE={params.FLOW_RATE|default(10)|float}
SET_GCODE_VARIABLE MACRO=VORON_PURGE VARIABLE=x_default VALUE={params.X_DEFAULT|default(10)|float}
SET_GCODE_VARIABLE MACRO=VORON_PURGE VARIABLE=y_default VALUE={params.Y_DEFAULT|default(10)|float}
SET_GCODE_VARIABLE MACRO=VORON_PURGE VARIABLE=size VALUE={params.SIZE|default(10)|float}
SET_GCODE_VARIABLE MACRO=VORON_PURGE VARIABLE=distance_to_object_x VALUE={params.DISTANCE_TO_OBJECT_X|default(10)|float}
SET_GCODE_VARIABLE MACRO=VORON_PURGE VARIABLE=distance_to_object_y VALUE={params.DISTANCE_TO_OBJECT_Y|default(10)|float}