-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathprint_area_bed_mesh.cfg
119 lines (101 loc) · 4.92 KB
/
print_area_bed_mesh.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
[gcode_macro BED_MESH_CALIBRATE]
# print surface bed mesh calibrate
# November 24, 2021
# Steve Turgeon
rename_existing: _BED_MESH_CALIBRATE
variable_buffer: 20
gcode:
;status_homing
{% if printer.toolhead.homed_axes != "xyz" %}
G28
{% else %}
G28 Z
{% endif %}
{% if params.PRINT_MIN %}
{ action_respond_info("print_min: %s" % params.PRINT_MIN) }
{ action_respond_info("print_max: %s" % params.PRINT_MAX) }
{% set probeConfig = printer['configfile'].config["probe"] %}
{% if probeConfig %}
{% set OffsetX = probeConfig.x_offset|default(0)|float %}
{% set OffsetY = probeConfig.y_offset|default(0)|float %}
{% endif %}
{% set print_min_x = params.PRINT_MIN.split(",")[0]|float %}
{% set print_min_y = params.PRINT_MIN.split(",")[1]|float %}
{% set print_max_x = params.PRINT_MAX.split(",")[0]|float %}
{% set print_max_y = params.PRINT_MAX.split(",")[1]|float %}
# The > 0 tests were added for the SuperSlicer bed level thing which is very weird.
{% if (print_min_x < print_max_x) and (print_min_y < print_max_y) and (print_min_x > 0) and (print_min_y > 0) %}
# Get bed_mesh config (probe count, mesh_min and mesh_max for x and y
{% set bedMeshConfig = printer['configfile'].config["bed_mesh"] %}
{% set algo = bedMeshConfig.algorithm %}
{% set probe_count = bedMeshConfig.probe_count.split(",") %}
{% set probe_count_x = probe_count[0]|int %}
{% if probe_count.__len__() > 1 %}
{% set probe_count_y = probe_count[1]|int %}
{% else %}
{% set probe_count_y = probe_count_x|int %}
{% endif %}
{% set mesh_min_x = bedMeshConfig.mesh_min.split(",")[0]|float %}
{% set mesh_min_y = bedMeshConfig.mesh_min.split(",")[1]|float %}
{% set mesh_max_x = bedMeshConfig.mesh_max.split(",")[0]|float %}
{% set mesh_max_y = bedMeshConfig.mesh_max.split(",")[1]|float %}
{% set probe_count_x = ((print_max_x - print_min_x) / ((mesh_max_x - mesh_min_x) / probe_count_x) + 0.99)|int %}
{% set probe_count_y = ((print_max_y - print_min_y) / ((mesh_max_y - mesh_min_y) / probe_count_y) + 0.99)|int %}
# If either count is over 6, we need to use bicubic and the minimum is 5
{% if (probe_count_x > 6) and (probe_count_y < 5) %}
{% set probe_count_y = 5 %}
{% endif %}
{% if (probe_count_y > 6) and (probe_count_x < 5) %}
{% set probe_count_x = 5 %}
{% endif %}
{% if (probe_count_x < 3) %}
{% set probe_count_x = 3 %}
{% endif %}
{% if (probe_count_y < 3) %}
{% set probe_count_y = 3 %}
{% endif %}
{% if (probe_count_x < 5) or (probe_count_y < 5) %}
{% set algo = 'lagrange' %}
{% endif %}
{% if print_min_x - buffer >= mesh_min_x %}
{% set mesh_min_x = print_min_x - buffer %}
{% endif %}
{% if print_min_y - buffer >= mesh_min_y %}
{% set mesh_min_y = print_min_y - buffer %}
{% endif %}
{% if print_max_x + buffer <= mesh_max_x %}
{% set mesh_max_x = print_max_x + buffer %}
{% endif %}
{% if print_max_y + buffer <= mesh_max_y %}
{% set mesh_max_y = print_max_y + buffer %}
{% endif %}
{ action_respond_info("mesh_min: %s,%s" % (mesh_min_x, mesh_min_y)) }
{ action_respond_info("mesh_max: %s,%s" % (mesh_max_x, mesh_max_y)) }
{ action_respond_info("probe_count: %s,%s" % (probe_count_x,probe_count_y)) }
; Cool down nozzle for mesh
{% if printer[printer.toolhead.extruder].target > 0 %}
M104 S{[(printer[printer.toolhead.extruder].target - 40),150]|min}
{% endif %}
; Bed Mesh
status_meshing
_BED_MESH_CALIBRATE mesh_min={mesh_min_x},{mesh_min_y} mesh_max={mesh_max_x},{mesh_max_y} probe_count={probe_count_x},{probe_count_y} mesh_algotithm={algo}
{% else %}
; Cool down nozzle for mesh
{% if printer[printer.toolhead.extruder].target > 0 %}
M104 S{[(printer[printer.toolhead.extruder].target - 40),150]|min}
{% endif %}
; Bed Mesh
status_meshing
{ action_respond_info("doing full mesh") }
_BED_MESH_CALIBRATE
{% endif %}
{% else %}
{ action_respond_info("doing full mesh") }
; Cool down nozzle for mesh
{% if printer[printer.toolhead.extruder].target > 0 %}
M104 S{[(printer[printer.toolhead.extruder].target - 40),150]|min}
{% endif %}
; Bed Mesh
status_meshing
_BED_MESH_CALIBRATE
{% endif %}