Skip to content

Commit e2ac221

Browse files
committed
Macros: use zero_reference_position when using beacon true zero
1 parent dbed201 commit e2ac221

1 file changed

Lines changed: 42 additions & 8 deletions

File tree

macros/mesh.cfg

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ gcode:
2626

2727
# config
2828
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
29+
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
2930
{% if idex_mode == "copy" or idex_mode == "mirror" %}
3031
# in copy and mirror mode we mesh the whole x bed length of the print area
3132
# this is later needed for the live toohlead z-offset compensation
@@ -38,10 +39,26 @@ gcode:
3839
{% set beacon_bed_mesh_scv = printer["gcode_macro RatOS"].beacon_bed_mesh_scv|default(25)|int %}
3940
{% set beacon_contact_bed_mesh_samples = printer["gcode_macro RatOS"].beacon_contact_bed_mesh_samples|default(2)|int %}
4041
{% set beacon_contact_bed_mesh = true if printer["gcode_macro RatOS"].beacon_contact_bed_mesh|default(false)|lower == 'true' else false %}
42+
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
4143
{% if printer.configfile.settings.beacon is defined and not beacon_contact_bed_mesh %}
4244
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={beacon_bed_mesh_scv}
4345
{% endif %}
4446

47+
# zero reference position
48+
{% set zero_reference_position = '' %}
49+
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
50+
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
51+
{% set safe_home_x = printable_x_max / 2 %}
52+
{% endif %}
53+
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
54+
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
55+
{% set safe_home_y = printable_y_max / 2 %}
56+
{% endif %}
57+
58+
{% if printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero %}
59+
{% set zero_reference_position = 'zero_reference_position={safe_home_x},{safe_home_y}' %}
60+
{% endif %}
61+
4562
# calibrate bed mesh
4663
{% set default_profile = printer["gcode_macro RatOS"].bed_mesh_profile|default('ratos') %}
4764
{% if printer["gcode_macro RatOS"].calibrate_bed_mesh|lower == 'true' %}
@@ -50,9 +67,9 @@ gcode:
5067
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}
5168
{% else %}
5269
{% 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}
70+
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile} {zero_reference_position}
5471
{% else %}
55-
BED_MESH_CALIBRATE PROFILE={default_profile}
72+
BED_MESH_CALIBRATE PROFILE={default_profile} {zero_reference_position}
5673
{% if printer.configfile.settings.beacon is defined %}
5774
_BEACON_APPLY_SCAN_COMPENSATION
5875
{% endif %}
@@ -70,12 +87,29 @@ gcode:
7087
[gcode_macro CALIBRATE_ADAPTIVE_MESH]
7188
gcode:
7289
# config
90+
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
7391
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
7492
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
7593

7694
# beacon contact config
7795
{% set beacon_contact_bed_mesh_samples = printer["gcode_macro RatOS"].beacon_contact_bed_mesh_samples|default(2)|int %}
7896
{% set beacon_contact_bed_mesh = true if printer["gcode_macro RatOS"].beacon_contact_bed_mesh|default(false)|lower == 'true' else false %}
97+
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
98+
99+
# zero reference position
100+
{% set zero_reference_position = '' %}
101+
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
102+
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
103+
{% set safe_home_x = printable_x_max / 2 %}
104+
{% endif %}
105+
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
106+
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
107+
{% set safe_home_y = printable_y_max / 2 %}
108+
{% endif %}
109+
110+
{% if printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero %}
111+
{% set zero_reference_position = 'zero_reference_position={safe_home_x},{safe_home_y}' %}
112+
{% endif %}
79113

80114
# idex mode
81115
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
@@ -96,9 +130,9 @@ gcode:
96130
# coordinates are invalid, fall back to full bed mesh
97131
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Invalid coordinates received. Please check your slicer settings. Falling back to full bed mesh."
98132
{% 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}
133+
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile} {zero_reference_position}
100134
{% else %}
101-
BED_MESH_CALIBRATE PROFILE={default_profile}
135+
BED_MESH_CALIBRATE PROFILE={default_profile} {zero_reference_position}
102136
{% if printer.configfile.settings.beacon is defined %}
103137
_BEACON_APPLY_SCAN_COMPENSATION
104138
{% endif %}
@@ -123,9 +157,9 @@ gcode:
123157
# coordinates are invalid, fall back to full bed mesh
124158
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Print is using the full bed, falling back to full bed mesh."
125159
{% 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}
160+
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile} {zero_reference_position}
127161
{% else %}
128-
BED_MESH_CALIBRATE PROFILE={default_profile}
162+
BED_MESH_CALIBRATE PROFILE={default_profile} {zero_reference_position}
129163
{% if printer.configfile.settings.beacon is defined %}
130164
_BEACON_APPLY_SCAN_COMPENSATION
131165
{% endif %}
@@ -206,9 +240,9 @@ gcode:
206240
# mesh
207241
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="mesh coordinates X0={mesh_x0} Y0={mesh_y0} X1={mesh_x1} Y1={mesh_y1}"
208242
{% 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
243+
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} {zero_reference_position}
210244
{% else %}
211-
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
245+
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} {zero_reference_position}
212246
{% if printer.configfile.settings.beacon is defined %}
213247
_BEACON_APPLY_SCAN_COMPENSATION
214248
{% endif %}

0 commit comments

Comments
 (0)