diff --git a/macros/mesh.cfg b/macros/mesh.cfg index 3dbfe525..cc0d60ae 100644 --- a/macros/mesh.cfg +++ b/macros/mesh.cfg @@ -26,6 +26,7 @@ gcode: # config {% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %} + {% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %} {% if idex_mode == "copy" or idex_mode == "mirror" %} # in copy and mirror mode we mesh the whole x bed length of the print area # this is later needed for the live toohlead z-offset compensation @@ -38,10 +39,26 @@ gcode: {% set beacon_bed_mesh_scv = printer["gcode_macro RatOS"].beacon_bed_mesh_scv|default(25)|int %} {% set beacon_contact_bed_mesh_samples = printer["gcode_macro RatOS"].beacon_contact_bed_mesh_samples|default(2)|int %} {% set beacon_contact_bed_mesh = true if printer["gcode_macro RatOS"].beacon_contact_bed_mesh|default(false)|lower == 'true' else false %} + {% 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 not beacon_contact_bed_mesh %} SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={beacon_bed_mesh_scv} {% endif %} + # zero reference position + {% set zero_reference_position = '' %} + {% 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 %} + + {% if printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero %} + {% set zero_reference_position = 'zero_reference_position={safe_home_x},{safe_home_y}' %} + {% endif %} + # calibrate bed mesh {% set default_profile = printer["gcode_macro RatOS"].bed_mesh_profile|default('ratos') %} {% if printer["gcode_macro RatOS"].calibrate_bed_mesh|lower == 'true' %} @@ -50,9 +67,9 @@ gcode: 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} {% else %} {% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %} - BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile} + BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile} {zero_reference_position} {% else %} - BED_MESH_CALIBRATE PROFILE={default_profile} + BED_MESH_CALIBRATE PROFILE={default_profile} {zero_reference_position} {% if printer.configfile.settings.beacon is defined %} _BEACON_APPLY_SCAN_COMPENSATION {% endif %} @@ -70,12 +87,29 @@ gcode: [gcode_macro CALIBRATE_ADAPTIVE_MESH] gcode: # config + {% 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 default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %} # beacon contact config {% set beacon_contact_bed_mesh_samples = printer["gcode_macro RatOS"].beacon_contact_bed_mesh_samples|default(2)|int %} {% set beacon_contact_bed_mesh = true if printer["gcode_macro RatOS"].beacon_contact_bed_mesh|default(false)|lower == 'true' else false %} + {% 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 %} + + # zero reference position + {% set zero_reference_position = '' %} + {% 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 %} + + {% if printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero %} + {% set zero_reference_position = 'zero_reference_position={safe_home_x},{safe_home_y}' %} + {% endif %} # idex mode {% set idex_mode = params.IDEX_MODE|default('')|lower %} @@ -96,9 +130,9 @@ gcode: # coordinates are invalid, fall back to full bed mesh RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Invalid coordinates received. Please check your slicer settings. Falling back to full bed mesh." {% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %} - BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile} + BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile} {zero_reference_position} {% else %} - BED_MESH_CALIBRATE PROFILE={default_profile} + BED_MESH_CALIBRATE PROFILE={default_profile} {zero_reference_position} {% if printer.configfile.settings.beacon is defined %} _BEACON_APPLY_SCAN_COMPENSATION {% endif %} @@ -123,9 +157,9 @@ gcode: # coordinates are invalid, fall back to full bed mesh RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Print is using the full bed, falling back to full bed mesh." {% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %} - BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile} + BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile} {zero_reference_position} {% else %} - BED_MESH_CALIBRATE PROFILE={default_profile} + BED_MESH_CALIBRATE PROFILE={default_profile} {zero_reference_position} {% if printer.configfile.settings.beacon is defined %} _BEACON_APPLY_SCAN_COMPENSATION {% endif %} @@ -206,9 +240,9 @@ gcode: # mesh RATOS_ECHO PREFIX="Adaptive Mesh" MSG="mesh coordinates X0={mesh_x0} Y0={mesh_y0} X1={mesh_x1} Y1={mesh_y1}" {% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %} - 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 + 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} {% 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} {zero_reference_position} {% if printer.configfile.settings.beacon is defined %} _BEACON_APPLY_SCAN_COMPENSATION {% endif %}