Skip to content

Commit ad9fe6d

Browse files
authored
MACRO: add beacon variable for enabling METHOD="automatic" (#51)
1 parent e51c26c commit ad9fe6d

File tree

2 files changed

+50
-23
lines changed

2 files changed

+50
-23
lines changed

configuration/macros/mesh.cfg

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ gcode:
3434
{% set X=[0, printable_x_max] %}
3535
{% endif %}
3636

37-
# beacon contact config
37+
# beacon config
3838
{% set beacon_bed_mesh_scv = printer["gcode_macro RatOS"].beacon_bed_mesh_scv|default(25)|int %}
3939
{% set beacon_contact_bed_mesh_samples = printer["gcode_macro RatOS"].beacon_contact_bed_mesh_samples|default(2)|int %}
4040
{% set beacon_contact_bed_mesh = true if printer["gcode_macro RatOS"].beacon_contact_bed_mesh|default(false)|lower == 'true' else false %}
41+
{% set beacon_scan_method_automatic = true if printer["gcode_macro RatOS"].beacon_scan_method_automatic|default(false)|lower == 'true' else false %}
4142
{% if printer.configfile.settings.beacon is defined and not beacon_contact_bed_mesh %}
4243
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={beacon_bed_mesh_scv}
4344
{% endif %}
@@ -49,13 +50,19 @@ gcode:
4950
{% if printer["gcode_macro RatOS"].adaptive_mesh|lower == 'true' %}
5051
CALIBRATE_ADAPTIVE_MESH PROFILE={default_profile} X0={X[0]} X1={X[1]} Y0={Y[0]} Y1={Y[1]} T={params.T|int} BOTH_TOOLHEADS={params.BOTH_TOOLHEADS} IDEX_MODE={idex_mode}
5152
{% else %}
52-
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
53-
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
53+
{% if printer.configfile.settings.beacon is defined %}
54+
{% if beacon_contact_bed_mesh %}
55+
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
56+
{% else %}
57+
{% if beacon_scan_method_automatic %}
58+
BED_MESH_CALIBRATE METHOD=automatic PROFILE={default_profile}
59+
{% else %}
60+
BED_MESH_CALIBRATE PROFILE={default_profile}
61+
{% endif %}
62+
{% endif %}
63+
_BEACON_APPLY_SCAN_COMPENSATION
5464
{% else %}
5565
BED_MESH_CALIBRATE PROFILE={default_profile}
56-
{% if printer.configfile.settings.beacon is defined %}
57-
_BEACON_APPLY_SCAN_COMPENSATION
58-
{% endif %}
5966
{% endif %}
6067
{% endif %}
6168
BED_MESH_PROFILE LOAD={default_profile}
@@ -73,9 +80,10 @@ gcode:
7380
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
7481
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
7582

76-
# beacon contact config
83+
# beacon config
7784
{% set beacon_contact_bed_mesh_samples = printer["gcode_macro RatOS"].beacon_contact_bed_mesh_samples|default(2)|int %}
7885
{% set beacon_contact_bed_mesh = true if printer["gcode_macro RatOS"].beacon_contact_bed_mesh|default(false)|lower == 'true' else false %}
86+
{% set beacon_scan_method_automatic = true if printer["gcode_macro RatOS"].beacon_scan_method_automatic|default(false)|lower == 'true' else false %}
7987

8088
# idex mode
8189
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
@@ -95,13 +103,19 @@ gcode:
95103
{% if x0 >= x1 or y0 >= y1 %}
96104
# coordinates are invalid, fall back to full bed mesh
97105
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Invalid coordinates received. Please check your slicer settings. Falling back to full bed mesh."
98-
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
99-
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
106+
{% if printer.configfile.settings.beacon is defined %}
107+
{% if beacon_contact_bed_mesh %}
108+
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
109+
{% else %}
110+
{% if beacon_scan_method_automatic %}
111+
BED_MESH_CALIBRATE METHOD=automatic PROFILE={default_profile}
112+
{% else %}
113+
BED_MESH_CALIBRATE PROFILE={default_profile}
114+
{% endif %}
115+
{% endif %}
116+
_BEACON_APPLY_SCAN_COMPENSATION
100117
{% else %}
101118
BED_MESH_CALIBRATE PROFILE={default_profile}
102-
{% if printer.configfile.settings.beacon is defined %}
103-
_BEACON_APPLY_SCAN_COMPENSATION
104-
{% endif %}
105119
{% endif %}
106120
{% else %}
107121
# get bed mesh config object
@@ -122,13 +136,19 @@ gcode:
122136
{% if mesh_x0 == min_x and mesh_y0 == min_y and mesh_x1 == max_x and mesh_y1 == max_y %}
123137
# coordinates are invalid, fall back to full bed mesh
124138
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Print is using the full bed, falling back to full bed mesh."
125-
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
126-
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
127-
{% else %}
128-
BED_MESH_CALIBRATE PROFILE={default_profile}
129-
{% if printer.configfile.settings.beacon is defined %}
130-
_BEACON_APPLY_SCAN_COMPENSATION
139+
{% if printer.configfile.settings.beacon is defined %}
140+
{% if beacon_contact_bed_mesh %}
141+
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
142+
{% else %}
143+
{% if beacon_scan_method_automatic %}
144+
BED_MESH_CALIBRATE METHOD=automatic PROFILE={default_profile}
145+
{% else %}
146+
BED_MESH_CALIBRATE PROFILE={default_profile}
147+
{% endif %}
131148
{% endif %}
149+
_BEACON_APPLY_SCAN_COMPENSATION
150+
{% else %}
151+
BED_MESH_CALIBRATE PROFILE={default_profile}
132152
{% endif %}
133153
{% else %}
134154
{% if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
@@ -205,13 +225,19 @@ gcode:
205225

206226
# mesh
207227
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="mesh coordinates X0={mesh_x0} Y0={mesh_y0} X1={mesh_x1} Y1={mesh_y1}"
208-
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
209-
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile} ALGORITHM={algorithm} MESH_MIN={mesh_x0},{mesh_y0} MESH_MAX={mesh_x1},{mesh_y1} PROBE_COUNT={mesh_count_x},{mesh_count_y} RELATIVE_REFERENCE_INDEX=-1
228+
{% if printer.configfile.settings.beacon is defined %}
229+
{% if beacon_contact_bed_mesh %}
230+
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile} ALGORITHM={algorithm} MESH_MIN={mesh_x0},{mesh_y0} MESH_MAX={mesh_x1},{mesh_y1} PROBE_COUNT={mesh_count_x},{mesh_count_y} RELATIVE_REFERENCE_INDEX=-1
231+
{% else %}
232+
{% if beacon_scan_method_automatic %}
233+
BED_MESH_CALIBRATE METHOD=automatic PROFILE={default_profile} ALGORITHM={algorithm} MESH_MIN={mesh_x0},{mesh_y0} MESH_MAX={mesh_x1},{mesh_y1} PROBE_COUNT={mesh_count_x},{mesh_count_y} RELATIVE_REFERENCE_INDEX=-1
234+
{% else %}
235+
BED_MESH_CALIBRATE PROFILE={default_profile} ALGORITHM={algorithm} MESH_MIN={mesh_x0},{mesh_y0} MESH_MAX={mesh_x1},{mesh_y1} PROBE_COUNT={mesh_count_x},{mesh_count_y} RELATIVE_REFERENCE_INDEX=-1
236+
{% endif %}
237+
{% endif %}
238+
_BEACON_APPLY_SCAN_COMPENSATION
210239
{% else %}
211240
BED_MESH_CALIBRATE PROFILE={default_profile} ALGORITHM={algorithm} MESH_MIN={mesh_x0},{mesh_y0} MESH_MAX={mesh_x1},{mesh_y1} PROBE_COUNT={mesh_count_x},{mesh_count_y} RELATIVE_REFERENCE_INDEX=-1
212-
{% if printer.configfile.settings.beacon is defined %}
213-
_BEACON_APPLY_SCAN_COMPENSATION
214-
{% endif %}
215241
{% endif %}
216242

217243
# probe for priming

configuration/z-probe/beacon.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ variable_beacon_scan_compensation_profile: "Offset" # The beacon offset prof
5555
variable_beacon_scan_compensation_resolution: 40 # The mesh resolution in mm for the scan compensation
5656

5757
variable_beacon_contact_poke_bottom_limit: -1 # The bottom limit for the contact poke test
58+
variable_beacon_scan_method_automatic: False # Enables the METHOD=automatic scan option
5859

5960

6061
#####

0 commit comments

Comments
 (0)