forked from jschuh/klipper-macros
-
Notifications
You must be signed in to change notification settings - Fork 2
/
kinematics.cfg
67 lines (62 loc) · 2.98 KB
/
kinematics.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Copyright (C) 2022 Justin Schuh <[email protected]>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
[gcode_macro _check_kinematic_limits]
gcode:
{% set toolhead = printer.toolhead %}
{% if params.X and (params.X|float < toolhead.axis_minimum.x or
params.X|float > toolhead.axis_maximum.x) %}
{action_raise_error("X[%.3f] must be between %.3f and %.3f."
| format(params.X|float, toolhead.axis_minimum.x,
toolhead.axis_maximum.x))}
{% elif params.Y and (params.Y|float < toolhead.axis_minimum.y or
params.Y|float > toolhead.axis_maximum.y) %}
{action_raise_error("Y[%.3f] must be between %.3f and %.3f."
| format(params.Y|float, toolhead.axis_minimum.y,
toolhead.axis_maximum.y))}
{% elif params.Z and (params.Z|float < toolhead.axis_minimum.z or
params.Z|float > toolhead.axis_maximum.z) %}
{action_raise_error("Z[%.3f] must be between %.3f and %.3f."
| format(params.Z|float, toolhead.axis_minimum.z,
toolhead.axis_maximum.z))}
{% elif params.E and (params.E|float|abs > printer.configfile.settings[
"extruder"].max_extrude_only_distance) %}
{action_raise_error("E[%.4f] exceeds max_extrude_only_distance[%.4f]."
| format(params.E|float|abs, printer.configfile.settings[
"extruder"].max_extrude_only_distance))}
{% endif %}
[gcode_macro lazy_home]
description: Homes the specified axes. If lazy is true, already homed axes
are skipped.
Usage: LAZY_HOME [LAZY=<1|0>] [AXES=<axes_string>]
gcode:
# This is split apart so we can force the macro rename cache to be ready.
LIST_MACROS SILENT=1
_LAZY_HOME_INNER {rawparams}
[gcode_macro _lazy_home_inner]
gcode:
# Find the real g28 command.
{% set G28 = (printer["gcode_macro list_macros"].macros.g28|
default(["g28"],True))[-1] %}
{% set axes = 'XYZ'|select('in', params.AXES|default("XYZ")|upper|list) %}
{% if not axes %} # No axes means home everything.
{% set axes = 'XYZ' %}
{% endif %}
{% if params.LAZY|default(1)|int %} # Prune out the already homed axes.
{% set axes = axes|reject('in', printer.toolhead.homed_axes|upper)|join() %}
{% endif %}
{% if axes %}
_KM_PRINT_STATUS ACTION=PUSH_STATUS
_KM_PRINT_STATUS ACTION=CHANGE STATUS=homing
{G28}{% for k in axes %}{' ' ~ k}{% endfor %}
_KM_PRINT_STATUS ACTION=CHANGE STATUS=pop_status
{% endif %}
[gcode_macro g28]
description: Wraps the G28 command to add the Marlin "O" parameter so that
already homed axes will not be homed again. See the Klipper documentation on
G28 for the behavior of the other parameters.
Usage: G28 [O] ...
rename_existing: G28.6245197
gcode:
{% set axes = 'XYZ'|select('in', params)|join() %}
LAZY_HOME LAZY={('O' in params)|int}{%if axes%} AXES={axes}{%endif%}