From 2ff2d2db91e522f9f6cd6353030514e41c72bfe0 Mon Sep 17 00:00:00 2001 From: Mikkel Schmidt Date: Sun, 10 Nov 2024 01:02:25 +0100 Subject: [PATCH 1/3] Beacon: emit zero_reference_position for bed_mesh --- src/server/helpers/klipper-config.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/server/helpers/klipper-config.ts b/src/server/helpers/klipper-config.ts index f6f8811c6..4e852852c 100644 --- a/src/server/helpers/klipper-config.ts +++ b/src/server/helpers/klipper-config.ts @@ -908,6 +908,8 @@ export const constructKlipperConfigHelpers = async ( const reminder: string[] = []; reminder.push('# REMEMBER TO CALIBRATE YOUR BEACON!'); reminder.push('# Run BEACON_RATOS_CALIBRATE for automatic calibration.'); + result.push('[bed_mesh]'); + result.push(`zero_reference_position: ${config.size.x / 2},${config.size.y / 2}`); extrasGenerator.addReminder(reminder.join('\n')); } break; From 546696de1977ee1644eb331ca8277a0bdeb21c58 Mon Sep 17 00:00:00 2001 From: Mikkel Schmidt Date: Fri, 27 Dec 2024 03:20:10 +0100 Subject: [PATCH 2/3] Macros: port RatOS-configuration#315 to configurator --- configuration/macros.cfg | 12 ++++++++++++ configuration/macros/mesh.cfg | 27 ++++++++++++++++++++++++--- src/server/helpers/klipper-config.ts | 1 + 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/configuration/macros.cfg b/configuration/macros.cfg index bc688cc9d..45d3d17d3 100644 --- a/configuration/macros.cfg +++ b/configuration/macros.cfg @@ -306,6 +306,7 @@ gcode: # beacon contact config {% 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 %} + {% 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 %} # get macro parameters {% set X0 = params.X0|default(-1)|float %} @@ -597,6 +598,17 @@ gcode: G4 P{(bed_heat_soak_time * 1000)} {% endif %} + # Zero z via contact if enabled. + {% if printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero %} + _MOVE_TO_SAFE_Z_HOME + # Calibrate a new beacon model if enabled. This adapts the beacon model to the current build plate. + {% if beacon_contact_calibrate_model_on_print %} + BEACON_AUTO_CALIBRATE + {% else %} + BEACON_AUTO_CALIBRATE SKIP_MODEL_CREATION=1 + {% endif %} + {% endif %} + # Run the user created "AFTER_HEATING_BED" macro _USER_START_PRINT_AFTER_HEATING_BED { rawparams } diff --git a/configuration/macros/mesh.cfg b/configuration/macros/mesh.cfg index 4cadc7f12..cbc62706e 100644 --- a/configuration/macros/mesh.cfg +++ b/configuration/macros/mesh.cfg @@ -10,6 +10,27 @@ variable_calibrate_bed_mesh: True # True|False = enable bed meshing variable_adaptive_mesh: True # True|False = enable adaptive bed meshing +[gcode_macro _BED_MESH_SANITY_CHECK] +gcode: + {% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %} + {% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %} + {% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %} + {% if safe_home_x is not defined or safe_home_x|lower == 'middle' %} + {% set safe_home_x = printable_x_max / 2 %} + {% endif %} + {% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %} + {% if safe_home_y is not defined or safe_home_y|lower == 'middle' %} + {% set safe_home_y = printable_y_max / 2 %} + {% endif %} + {% 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 %} + + {% if printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero %} + {% set zero_ref_pos = printer.configfile.settings.bed_mesh.zero_reference_position %} + {% if zero_ref_pos is not defined or zero_ref_pos[0] != safe_home_x or zero_ref_pos[1] != safe_home_y %} + 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_" + _STOP_AND_RAISE_ERROR MSG="Zero reference position does not match safe home position" + {% endif %} + {% endif %} [gcode_macro _START_PRINT_BED_MESH] gcode: @@ -230,14 +251,14 @@ gcode: 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 {% else %} {% if beacon_scan_method_automatic %} - 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 + 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} {% else %} - 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 + 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} {% endif %} {% endif %} _BEACON_APPLY_SCAN_COMPENSATION {% else %} - 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 + 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} {% endif %} # probe for priming diff --git a/src/server/helpers/klipper-config.ts b/src/server/helpers/klipper-config.ts index 4e852852c..274d8ee3f 100644 --- a/src/server/helpers/klipper-config.ts +++ b/src/server/helpers/klipper-config.ts @@ -908,6 +908,7 @@ export const constructKlipperConfigHelpers = async ( const reminder: string[] = []; reminder.push('# REMEMBER TO CALIBRATE YOUR BEACON!'); reminder.push('# Run BEACON_RATOS_CALIBRATE for automatic calibration.'); + result.push('# Offset mesh relative to the z height at home position'); result.push('[bed_mesh]'); result.push(`zero_reference_position: ${config.size.x / 2},${config.size.y / 2}`); extrasGenerator.addReminder(reminder.join('\n')); From 6d597af602481bd41aab62172491a50257c7e0eb Mon Sep 17 00:00:00 2001 From: Mikkel Schmidt Date: Fri, 27 Dec 2024 03:28:46 +0100 Subject: [PATCH 3/3] Macros: only apply scan compensation if not using contact meshing --- configuration/macros/mesh.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configuration/macros/mesh.cfg b/configuration/macros/mesh.cfg index cbc62706e..3f0b2480f 100644 --- a/configuration/macros/mesh.cfg +++ b/configuration/macros/mesh.cfg @@ -133,8 +133,8 @@ gcode: {% else %} BED_MESH_CALIBRATE PROFILE={default_profile} {% endif %} + _BEACON_APPLY_SCAN_COMPENSATION {% endif %} - _BEACON_APPLY_SCAN_COMPENSATION {% else %} BED_MESH_CALIBRATE PROFILE={default_profile} {% endif %} @@ -166,8 +166,8 @@ gcode: {% else %} BED_MESH_CALIBRATE PROFILE={default_profile} {% endif %} + _BEACON_APPLY_SCAN_COMPENSATION {% endif %} - _BEACON_APPLY_SCAN_COMPENSATION {% else %} BED_MESH_CALIBRATE PROFILE={default_profile} {% endif %}