-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbed_mesh.cfg
88 lines (75 loc) · 3.09 KB
/
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
[gcode_macro BED_MESH_CALIBRATE]
# Bed mesh override with automatic probe/bltouch offset calculation
# November 20, 2021
# Steve Turgeon
rename_existing: _BED_MESH_CALIBRATE
variable_buffer: 10
gcode:
{% if printer.toolhead.homed_axes != "xyz" %}
G28
{% endif %}
{% set printerSettings = printer["gcode_macro printer_settings"] %}
{% if printerSettings %}
{% set print_area_x = printerSettings.print_area_x %}
{% set print_area_y = printerSettings.print_area_y %}
{% else %}
{ action_raise_error("Missing [printer_settings] section in your config.") }
{% endif %}
{ action_respond_info("print_area: %s,%s" % (print_area_x, print_area_y)) }
{% set bltouchSection = printer['configfile'].config["bltouch"] %}
{% if bltouchSection %}
{ action_respond_info("Found bltouch config") }
{% set OffsetX = bltouchSection.x_offset|default(0)|float %}
{% set OffsetY = bltouchSection.y_offset|default(0)|float %}
{% endif %}
{% set probeSection = printer['configfile'].config["probe"] %}
{% if probeSection %}
{ action_respond_info("Found probe config") }
{% set OffsetX = probeSection.x_offset|default(0)|float %}
{% set OffsetY = probeSection.y_offset|default(0)|float %}
{% endif %}
{ action_respond_info("OffsetX: %s" % OffsetX) }
{ action_respond_info("OffsetY: %s" % OffsetY) }
{% set MinX = printer['configfile'].config["stepper_x"]["position_min"]|default(0)|int %}
{% set MaxX = printer['configfile'].config["stepper_x"]["position_max"]|default(print_area_x)|int %}
{% set MinY = printer['configfile'].config["stepper_y"]["position_min"]|default(0)|int %}
{% set MaxY = printer['configfile'].config["stepper_y"]["position_max"]|default(print_area_y)|int %}
# mesh_min_x
{% if OffsetX < 0 %}
{% set mesh_min_x = buffer %}
{% else %}
{% set mesh_min_x = buffer + OffsetX %}
{% endif %}
{% if mesh_min_x < MinX %}
{% set mesh_min_x = MinX %}
{% endif %}
# mesh_max_x
{% if OffsetX < 0 %}
{% set mesh_max_x = print_area_x - buffer + OffsetX %}
{% else %}
{% set mesh_max_x = print_area_x - buffer %}
{% endif %}
{% if mesh_max_x > MaxX %}
{% set mesh_max_x = MaxX - buffer %}
{% endif %}
# mesh_min_y
{% if OffsetY < 0 %}
{% set mesh_min_y = buffer %}
{% else %}
{% set mesh_min_y = buffer + OffsetY %}
{% endif %}
{% if mesh_min_y < MinY %}
{% set mesh_min_y = MinY %}
{% endif %}
# mesh_max_y
{% if OffsetY < 0 %}
{% set mesh_max_y = print_area_y - buffer + OffsetY %}
{% else %}
{% set mesh_max_y = print_area_y - buffer %}
{% endif %}
{% if mesh_max_y > MaxY %}
{% set mesh_max_y = MaxY - 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)) }
_BED_MESH_CALIBRATE mesh_min={mesh_min_x|float},{mesh_min_y|float} mesh_max={mesh_max_x|float},{mesh_max_y|float}