Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions configuration/macros.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down Expand Up @@ -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 }

Expand Down
31 changes: 26 additions & 5 deletions configuration/macros/mesh.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -112,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 %}
Expand Down Expand Up @@ -145,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 %}
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/server/helpers/klipper-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,9 @@ 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'));
}
break;
Expand Down
Loading