-
Notifications
You must be signed in to change notification settings - Fork 0
/
s1pper-automesh.cfg
137 lines (123 loc) · 6.74 KB
/
s1pper-automesh.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
; ------------------------------------------------------------------------------------------------
; BED_MESH_CALIBRATE Macro for Ender 3 S1 Pro
; ------------------------------------------------------------------------------------------------
; This script is an adaptation of the automesh macro by ChipCE.
; Original script: https://gist.github.com/ChipCE/95fdbd3c2f3a064397f9610f915f7d02
;
; Modifications were made to integrate a dynamic purge line near the mesh area,
; ensuring a purge line that scales with the print size.
;
; Author of modifications: carmelosantana
; ------------------------------------------------------------------------------------------------
[gcode_macro BED_MESH_CALIBRATE]
rename_existing: BED_MESH_CALIBRATE_BASE
; gcode parameters
variable_parameter_AREA_START : 0,0
variable_parameter_AREA_END : 0,0
; the clearance between print area and probe area
variable_mesh_area_offset : 5.0
; number of sample per probe point
variable_probe_samples : 2
; minimum probe count
variable_min_probe_count : 4
; scale up the probe count, should be 1.0 ~ < variable_max_probe_count/variable_min_probe_count
variable_probe_count_scale_factor : 1.5
; enable preference index
variable_enable_reference_index : False
gcode:
{% if params.AREA_START and params.AREA_END %}
{% set bedMeshConfig = printer["configfile"].config["bed_mesh"] %}
{% set safe_min_x = bedMeshConfig.mesh_min.split(",")[0]|float %}
{% set safe_min_y = bedMeshConfig.mesh_min.split(",")[1]|float %}
{% set safe_max_x = bedMeshConfig.mesh_max.split(",")[0]|float %}
{% set safe_max_y = bedMeshConfig.mesh_max.split(",")[1]|float %}
{% set area_min_x = params.AREA_START.split(",")[0]|float %}
{% set area_min_y = params.AREA_START.split(",")[1]|float %}
{% set area_max_x = params.AREA_END.split(",")[0]|float %}
{% set area_max_y = params.AREA_END.split(",")[1]|float %}
{% if bedMeshConfig.probe_count.split(",")|length == 2 %}
{% set meshPointX = bedMeshConfig.probe_count.split(",")[0]|int %}
{% set meshPointY = bedMeshConfig.probe_count.split(",")[1]|int %}
{% else %}
{% set meshPointX = bedMeshConfig.probe_count.split(",")[0]|int %}
{% set meshPointY = bedMeshConfig.probe_count.split(",")[0]|int %}
{% endif %}
{% set meshMaxPointX = meshPointX %}
{% set meshMaxPointY = meshPointY %}
{% if (area_min_x < area_max_x) and (area_min_y < area_max_y) %}
{% if area_min_x - mesh_area_offset >= safe_min_x %}
{% set area_min_x = area_min_x - mesh_area_offset %}
{% else %}
{% set area_min_x = safe_min_x %}
{% endif %}
{% if area_min_y - mesh_area_offset >= safe_min_y %}
{% set area_min_y = area_min_y - mesh_area_offset %}
{% else %}
{% set area_min_y = safe_min_y %}
{% endif %}
{% if area_max_x + mesh_area_offset <= safe_max_x %}
{% set area_max_x = area_max_x + mesh_area_offset %}
{% else %}
{% set area_max_x = safe_max_x %}
{% endif %}
{% if area_max_y + mesh_area_offset <= safe_max_y %}
{% set area_max_y = area_max_y + mesh_area_offset %}
{% else %}
{% set area_max_y = safe_max_y %}
{% endif %}
{% set meshPointX = (meshPointX * (area_max_x - area_min_x) / (safe_max_x - safe_min_x) * probe_count_scale_factor)|round(0)|int %}
{% if meshPointX < min_probe_count %}
{% set meshPointX = min_probe_count %}
{% endif %}
{% if meshPointX > meshMaxPointX %}
{% set meshPointX = meshMaxPointX %}
{% endif %}
{% set meshPointY = (meshPointY * (area_max_y -area_min_y ) / (safe_max_y - safe_min_y) * probe_count_scale_factor )|round(0)|int %}
{% if meshPointY < min_probe_count %}
{% set meshPointY = min_probe_count %}
{% endif %}
{% if meshPointY > meshMaxPointY %}
{% set meshPointY = meshMaxPointY %}
{% endif %}
{% set algorithm = "bicubic" %}
{% if "algorithm" in bedMeshConfig %}
{% set algorithm = bedMeshConfig.algorithm %}
{% endif %}
{% if meshPointX >=7 or meshPointY >=7 %}
{% set algorithm = "bicubic" %}
{% endif %}
{% if enable_reference_index %}
{% set referenceIndex = (meshPointX * meshPointY / 2 - 1 )|round(0)|int %}
BED_MESH_CALIBRATE_BASE mesh_min={area_min_x},{area_min_y} mesh_max={area_max_x},{area_max_y} probe_count={meshPointX},{meshPointY} samples={probe_samples|int} algorithm={algorithm} relative_reference_index={referenceIndex}
BED_MESH_PURGE_LINE x_min={area_min_x} y_min={area_min_y} y_max={area_max_y}
{% else %}
BED_MESH_CALIBRATE_BASE mesh_min={area_min_x},{area_min_y} mesh_max={area_max_x},{area_max_y} probe_count={meshPointX},{meshPointY} samples={probe_samples|int} algorithm={algorithm}
BED_MESH_PURGE_LINE x_min={area_min_x} y_min={area_min_y} y_max={area_max_y}
{% endif %}
{% else %}
BED_MESH_CALIBRATE_BASE
{% endif %}
{% else %}
BED_MESH_CALIBRATE_BASE
{% endif %}
[gcode_macro BED_MESH_PURGE_LINE]
description: Custom purge line near mesh area
variable_parameter_X_MIN: 5.1
variable_parameter_Y_MIN: 20
variable_parameter_Y_MAX: 200.0
gcode:
; Calculate the travel distance along Y-axis
{% set travel_distance = params.Y_MAX|default(200.0)|float - params.Y_MIN|default(20)|float %}
; Calculate extrusion length based on travel distance, aiming for 15mm extrusion
{% set extrusion_length = 15 %}
; If the extrusion length is less than 5mm for the given travel distance, set travel distance to 50mm and recalculate extrusion length
{% if (travel_distance * (15 / 200.0)) < 5 %}
{% set travel_distance = 50 %}
{% set extrusion_length = (travel_distance * (15 / 200.0)) %}
{% endif %}
; Purge line G-code
G1 Z2.0 F3000 ; Move Z to 2.0mm at 3000mm/min
G1 X{params.X_MIN|default(5.1)} Y{params.Y_MIN|default(20)} Z0.3 F5000.0 ; Move to start position of purge line near mesh area
G1 X{params.X_MIN|default(5.1)} Y{params.Y_MAX|default(200.0)} Z0.3 F1500.0 E{extrusion_length} ; Extrude along Y-axis to the end of mesh area at 1500mm/min
G1 X{params.X_MIN|default(5.1)|float + 0.3} Y{params.Y_MAX|default(200.0)} Z0.3 F5000.0 ; Move right by 0.3mm at 5000mm/min (no extrusion)
G1 X{params.X_MIN|default(5.1)|float + 0.3} Y{params.Y_MIN|default(20)} Z0.3 F1500.0 E{extrusion_length * 2} ; Extrude along Y-axis back to the start of mesh area at 1500mm/min