forked from jschuh/klipper-macros
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bed_mesh: Fix config issue (jschuh#12)
* Ensure we don't call BED_MESH_CALIBRATE with unbounded params * Make fast mesh level the default in START_PRINT * Update bed mesh documentation
- Loading branch information
Showing
4 changed files
with
101 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
[gcode_macro bed_mesh_calibrate_fast] | ||
description: Wraps BED_MESH_CALIBRATE, scaling probe count to specified area. | ||
Usage: See Klipper documentation. | ||
gcode: | ||
{% set km = printer["gcode_macro _km_globals"] %} | ||
{% set probe_mesh_padding = km.probe_mesh_padding %} | ||
{% set probe_min_count = km.probe_min_count %} | ||
{% set probe_count_scale = km.probe_count_scale %} | ||
{% set bed_mesh = printer.configfile.config.bed_mesh %} | ||
|
||
# don't have the math functions available to work on a delta bed. | ||
{%if "mesh_radius" not in bed_mesh %} | ||
{% set safe_min_x = bed_mesh.mesh_min.split(",")[0]|float %} | ||
{% set safe_min_y = bed_mesh.mesh_min.split(",")[1]|float %} | ||
{% set safe_max_x = bed_mesh.mesh_max.split(",")[0]|float %} | ||
{% set safe_max_y = bed_mesh.mesh_max.split(",")[1]|float %} | ||
|
||
{% if "MESH_MIN" in params %} | ||
{% set mesh_min_x = (params.MESH_MIN.split(",")[0]|float - | ||
probe_mesh_padding, safe_min_x)|max %} | ||
{% set mesh_min_y = (params.MESH_MIN.split(",")[1]|float - | ||
probe_mesh_padding, safe_min_y)|max %} | ||
{% else %} | ||
{% set mesh_min_x = safe_min_x %} | ||
{% set mesh_min_y = safe_min_y %} | ||
{% endif %} | ||
{% if "MESH_MAX" in params %} | ||
{% set mesh_max_x = (params.MESH_MAX.split(",")[0]|float + | ||
probe_mesh_padding, safe_max_x)|min %} | ||
{% set mesh_max_y = (params.MESH_MAX.split(",")[1]|float + | ||
probe_mesh_padding, safe_max_y)|min %} | ||
{% else %} | ||
{% set mesh_max_x = safe_max_x %} | ||
{% set mesh_max_y = safe_max_y %} | ||
{% endif %} | ||
|
||
{% set probe_count = (params.PROBE_COUNT | | ||
default(bed_mesh.probe_count)).split(",") %} | ||
{% set max_x_probes = probe_count[0]|int %} | ||
{% set max_y_probes = probe_count[1]|default(max_x_probes)|int %} | ||
|
||
{% set x_probes = (max_x_probes * (mesh_max_x - mesh_min_x) / | ||
(safe_max_x - safe_min_x) * probe_count_scale) | ||
| round(0) | int %} | ||
{% set x_probes = ((x_probes, probe_min_count)|max, max_x_probes)|min %} | ||
|
||
{% set y_probes = (max_y_probes * (mesh_max_y - mesh_min_y ) / | ||
(safe_max_y - safe_min_y) * probe_count_scale ) | ||
| round(0) | int %} | ||
{% set y_probes = ((y_probes, probe_min_count)|max, max_y_probes)|min %} | ||
|
||
{% set dummy = params.__setitem__("MESH_MIN", mesh_min_x~","~mesh_min_y) %} | ||
{% set dummy = params.__setitem__("MESH_MAX", mesh_max_x~","~mesh_max_y) %} | ||
{% set dummy = params.__setitem__("PROBE_COUNT", x_probes~","~y_probes) %} | ||
{% endif %} | ||
{% if printer["gcode_macro bed_mesh_calibrate"].km_override|default(False) %} | ||
{% set calibrate_cmd = "_km_bed_mesh_calibrate_base" %} | ||
{% else %} | ||
{% set calibrate_cmd = "BED_MESH_CALIBRATE" %} | ||
{% endif %} | ||
|
||
{calibrate_cmd}{%for k in params%}{' '~k~'="'~params[k]~'"'}{%endfor%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters