Skip to content

Commit 089135e

Browse files
committed
Macros: port RatOS-configuration#315 to configurator
1 parent 5b04938 commit 089135e

3 files changed

Lines changed: 36 additions & 2 deletions

File tree

configuration/macros.cfg

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ gcode:
306306

307307
# beacon contact config
308308
{% 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 %}
309+
{% set beacon_contact_calibrate_model_on_print = true if printer["gcode_macro RatOS"].beacon_contact_calibrate_model_on_print|default(false)|lower == 'true' else false %}
309310

310311
# get macro parameters
311312
{% set X0 = params.X0|default(-1)|float %}
@@ -597,6 +598,17 @@ gcode:
597598
G4 P{(bed_heat_soak_time * 1000)}
598599
{% endif %}
599600

601+
# Zero z via contact if enabled.
602+
{% if printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero %}
603+
_MOVE_TO_SAFE_Z_HOME
604+
# Calibrate a new beacon model if enabled. This adapts the beacon model to the current build plate.
605+
{% if beacon_contact_calibrate_model_on_print %}
606+
BEACON_AUTO_CALIBRATE
607+
{% else %}
608+
BEACON_AUTO_CALIBRATE SKIP_MODEL_CREATION=1
609+
{% endif %}
610+
{% endif %}
611+
600612
# Run the user created "AFTER_HEATING_BED" macro
601613
_USER_START_PRINT_AFTER_HEATING_BED { rawparams }
602614

configuration/macros/mesh.cfg

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,27 @@
1010
variable_calibrate_bed_mesh: True # True|False = enable bed meshing
1111
variable_adaptive_mesh: True # True|False = enable adaptive bed meshing
1212

13+
[gcode_macro _BED_MESH_SANITY_CHECK]
14+
gcode:
15+
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
16+
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
17+
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
18+
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
19+
{% set safe_home_x = printable_x_max / 2 %}
20+
{% endif %}
21+
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
22+
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
23+
{% set safe_home_y = printable_y_max / 2 %}
24+
{% endif %}
25+
{% 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 %}
26+
27+
{% if printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero %}
28+
{% set zero_ref_pos = printer.configfile.settings.bed_mesh.zero_reference_position %}
29+
{% if zero_ref_pos is not defined or zero_ref_pos[0] != safe_home_x or zero_ref_pos[1] != safe_home_y %}
30+
CONSOLE_ECHO TYPE="error" TITLE="Zero reference position does not match safe home position" MSG="Please update your bed mesh zero reference position in printer.cfg, like so:_N__N_[bed_mesh]_N_zero_reference_position: {safe_home_x},{safe_home_y}_N_"
31+
_STOP_AND_RAISE_ERROR MSG="Zero reference position does not match safe home position"
32+
{% endif %}
33+
{% endif %}
1334

1435
[gcode_macro _START_PRINT_BED_MESH]
1536
gcode:
@@ -206,9 +227,9 @@ gcode:
206227
# mesh
207228
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="mesh coordinates X0={mesh_x0} Y0={mesh_y0} X1={mesh_x1} Y1={mesh_y1}"
208229
{% 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
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}
210231
{% 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
232+
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}
212233
{% if printer.configfile.settings.beacon is defined %}
213234
_BEACON_APPLY_SCAN_COMPENSATION
214235
{% endif %}

src/server/helpers/klipper-config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,7 @@ export const constructKlipperConfigHelpers = async (
908908
const reminder: string[] = [];
909909
reminder.push('# REMEMBER TO CALIBRATE YOUR BEACON!');
910910
reminder.push('# Run BEACON_RATOS_CALIBRATE for automatic calibration.');
911+
result.push('# Offset mesh relative to the z height at home position');
911912
result.push('[bed_mesh]');
912913
result.push(`zero_reference_position: ${config.size.x / 2},${config.size.y / 2}`);
913914
extrasGenerator.addReminder(reminder.join('\n'));

0 commit comments

Comments
 (0)