Upload files to "klipper/DNV-TPU-Ender3/klipper_config/klipper-macros"
This commit is contained in:
@@ -0,0 +1,140 @@
|
|||||||
|
# Copyright (C) 2022 Justin Schuh <code@justinschuh.com>
|
||||||
|
#
|
||||||
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
|
|
||||||
|
[gcode_macro _load_unload]
|
||||||
|
variable_is_printing: 1
|
||||||
|
gcode:
|
||||||
|
# Klipper think we're printing if parking homed first, so this is a hack to
|
||||||
|
# prevent that from happening. The caller sets the value and we clear it.
|
||||||
|
SET_GCODE_VARIABLE MACRO=_load_unload VARIABLE=is_printing VALUE="{1}"
|
||||||
|
{% set saved_extruder = printer.toolhead.extruder %}
|
||||||
|
{% set EXTRUDER = params.EXTRUDER|default(saved_extruder)|lower %}
|
||||||
|
{% if 'MINIMUM' in params %}
|
||||||
|
{% set MINIMUM = params.MINIMUM|int %}
|
||||||
|
# This is the special case for a filament change after an idle timeout.
|
||||||
|
{% elif printer.pause_resume.is_paused and printer[EXTRUDER].target == 0 and
|
||||||
|
printer["gcode_macro resume"].saved_extruder_temp %}
|
||||||
|
{% set MINIMUM = printer["gcode_macro resume"].saved_extruder_temp %}
|
||||||
|
{% else %}
|
||||||
|
{% set MINIMUM =
|
||||||
|
printer.configfile.settings[EXTRUDER].min_extrude_temp + 5.0 %}
|
||||||
|
{% endif %}
|
||||||
|
{% if MINIMUM < printer.configfile.settings[EXTRUDER].min_extrude_temp %}
|
||||||
|
{ action_raise_error("Extrude below minimum temp.") }
|
||||||
|
{% elif printer.pause_resume.is_paused %}
|
||||||
|
# Clear the saved E if we're (un-)loading while paused.
|
||||||
|
SET_GCODE_VARIABLE MACRO=resume VARIABLE=saved_e VALUE="{0.0}"
|
||||||
|
{% elif printer.idle_timeout.state == "Printing" and is_printing %}
|
||||||
|
{ action_raise_error("Command not valid during printing.") }
|
||||||
|
{% endif %}
|
||||||
|
{% set km = printer["gcode_macro _km_globals"] %}
|
||||||
|
{% set SPEED = params.SPEED|default(km.load_speed)|int %}
|
||||||
|
{% set priming_length = km.load_priming_length %}
|
||||||
|
{% set LENGTH = params.LENGTH|default(km.load_length)|float - priming_length%}
|
||||||
|
{% if LENGTH < 0 %}
|
||||||
|
{% set priming_length = (priming_length + LENGTH, 0)|max %}
|
||||||
|
{% set LENGTH = 0 %}
|
||||||
|
{% endif %}
|
||||||
|
SAVE_GCODE_STATE NAME=_KM_LOAD_UNLOAD
|
||||||
|
{% if EXTRUDER != saved_extruder%}
|
||||||
|
ACTIVATE_EXTRUDER EXTRUDER={EXTRUDER}
|
||||||
|
{% endif %}
|
||||||
|
{% if printer[EXTRUDER].target < MINIMUM %}
|
||||||
|
M109 S{MINIMUM}
|
||||||
|
{% endif %}
|
||||||
|
M83
|
||||||
|
{% if params.LOAD|int %}
|
||||||
|
G1 E{LENGTH} F{SPEED}
|
||||||
|
G1 E{priming_length} F{(km.load_priming_speed, SPEED)|min}
|
||||||
|
G1 E{'%.4f' % -printer["gcode_macro resume"].saved_e} F{km.load_speed}
|
||||||
|
{% else %}
|
||||||
|
G1 E3.0 F{SPEED}
|
||||||
|
G4 P500
|
||||||
|
G1 E{'%.4f' % -priming_length} F{(km.load_priming_speed, SPEED)|min}
|
||||||
|
G1 E{'%.4f' % -LENGTH} F{SPEED}
|
||||||
|
{% endif %}
|
||||||
|
RESTORE_GCODE_STATE NAME=_KM_LOAD_UNLOAD
|
||||||
|
|
||||||
|
[gcode_macro load_filament]
|
||||||
|
description: Loads filament to the extruder.
|
||||||
|
Usage: LOAD_FILAMENT [LENGTH=<distance>] [SPEED=<speed>]
|
||||||
|
[EXTRUDER=<extruder>] [MINIMUM=<temperature>]
|
||||||
|
gcode:
|
||||||
|
_LOAD_UNLOAD LOAD=1{% for k in params
|
||||||
|
%}{' '~k~'="'~params[k]~'"'}{% endfor %}
|
||||||
|
|
||||||
|
# Dummy argument block for Mainsail
|
||||||
|
{% set dummy = None if True else "
|
||||||
|
{% set dummy = params.LENGTH|default(variable_load_length)|float %}
|
||||||
|
{% set dummy = params.SPEED|default(variable_load_speed)|float %}
|
||||||
|
{% set dummy = params.EXTRUDER|default(current extruder) %}
|
||||||
|
{% set dummy = params.MINIMUM|default(min_extrude_temp)|int %}
|
||||||
|
" %} # End argument block for Mainsail
|
||||||
|
|
||||||
|
[gcode_macro unload_filament]
|
||||||
|
description: Unloads filament from the extruder.
|
||||||
|
Usage: UNLOAD_FILAMENT [LENGTH=<distance>] [SPEED=<speed>]
|
||||||
|
[EXTRUDER=<extruder>] [MINIMUM=<temperature>]
|
||||||
|
gcode:
|
||||||
|
_LOAD_UNLOAD LOAD=0{% for k in params
|
||||||
|
%}{' '~k~'="'~params[k]~'"'}{% endfor %}
|
||||||
|
|
||||||
|
# Dummy argument block for Mainsail
|
||||||
|
{% set dummy = None if True else "
|
||||||
|
{% set dummy = params.LENGTH|default(variable_load_length)|float %}
|
||||||
|
{% set dummy = params.SPEED|default(variable_load_speed)|float %}
|
||||||
|
{% set dummy = params.EXTRUDER|default(default extruder) %}
|
||||||
|
{% set dummy = params.MINIMUM|default(min_extrude_temp)|int %}
|
||||||
|
" %} # End argument block for Mainsail
|
||||||
|
|
||||||
|
[gcode_macro _pause_inner_m700]
|
||||||
|
gcode:
|
||||||
|
{% set extruder = "extruder" ~ params.T|replace('0', '')
|
||||||
|
if "T" in params else printer.toolhead.extruder %}
|
||||||
|
{% if extruder != printer.toolhead.extruder%}
|
||||||
|
ACTIVATE_EXTRUDER EXTRUDER={extruder}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% set z_param = (' Z="%f"' % params.Z) if 'Z' in params else "" %}
|
||||||
|
|
||||||
|
{% if printer.idle_timeout.state|string == "Printing" %}
|
||||||
|
PAUSE P=2{z_param}
|
||||||
|
{% elif not printer.pause_resume.is_paused%}
|
||||||
|
SET_GCODE_VARIABLE MACRO=_load_unload VARIABLE=is_printing VALUE="{0}"
|
||||||
|
PARK P=2{z_param}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
[gcode_macro m701]
|
||||||
|
description: Pauses/parks the toolhead then loads filament to the extruder.
|
||||||
|
Usage: M701 [L<distance>] [Z<pos>] [T<extruder>]
|
||||||
|
gcode:
|
||||||
|
{% if 'U' in params %}
|
||||||
|
{% if not 'L' in params %}
|
||||||
|
RESPOND TYPE=error MSG="Argument \"U\" substituted for missing \"L\"."
|
||||||
|
{% set dummy = params.__setitem__("L", params.U) %}
|
||||||
|
{% else %}
|
||||||
|
RESPOND TYPE=error MSG="Invalid argument \"U\" ignored."
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
_PAUSE_INNER_M700 {% for k in params %}{' '~k~'="'~params[k]~'"'}{% endfor %}
|
||||||
|
LOAD_FILAMENT LENGTH={
|
||||||
|
params.L|default(printer["gcode_macro _km_globals"].load_length)|float}
|
||||||
|
|
||||||
|
[gcode_macro m702]
|
||||||
|
description: Pauses/parks the toolhead then unloads filament from the extruder.
|
||||||
|
Usage: M702 [U<distance>] [Z<pos>] [T<extruder>]
|
||||||
|
gcode:
|
||||||
|
{% if 'L' in params %}
|
||||||
|
{% if not 'U' in params %}
|
||||||
|
RESPOND TYPE=error MSG="Argument \"L\" substituted for missing \"U\"."
|
||||||
|
{% set dummy = params.__setitem__("U", params.L) %}
|
||||||
|
{% else %}
|
||||||
|
RESPOND TYPE=error MSG="Invalid argument \"L\" ignored."
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
_PAUSE_INNER_M700 {% for k in params %}{' '~k~'="'~params[k]~'"'}{% endfor %}
|
||||||
|
UNLOAD_FILAMENT LENGTH={
|
||||||
|
params.U|default(printer["gcode_macro _km_globals"].load_length)|float}
|
||||||
357
klipper/DNV-TPU-Ender3/klipper_config/klipper-macros/globals.cfg
Normal file
357
klipper/DNV-TPU-Ender3/klipper_config/klipper-macros/globals.cfg
Normal file
@@ -0,0 +1,357 @@
|
|||||||
|
# Copyright (C) 2022 Justin Schuh <code@justinschuh.com>
|
||||||
|
#
|
||||||
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Declare any of the below variables in your own [gcode_macro _km_options] to
|
||||||
|
# to override the values here.
|
||||||
|
#
|
||||||
|
# DO NOT CHANGE ANYTHING IN THIS FILE!!!
|
||||||
|
#
|
||||||
|
# This file handles the initialization for all the macros, and difficult to
|
||||||
|
# diagnose errors will result from unexpected values or code changes.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
[gcode_macro _km_globals]
|
||||||
|
# Available bed surfaces for offset adjustments.
|
||||||
|
variable_bed_surface_max_name_length: 10
|
||||||
|
# Available bed surfaces for offset adjustments.
|
||||||
|
variable_bed_surfaces: ['default']
|
||||||
|
# Default beep frequency (in Hz) for M300 command.
|
||||||
|
variable_beep_frequency: 1000
|
||||||
|
# Default beep duration (in ms) for M300 command.
|
||||||
|
variable_beep_duration: 100
|
||||||
|
# Length (in mm) of filament to load (bowden tubes will be longer).
|
||||||
|
variable_load_length: 90.0
|
||||||
|
# Filament loading speed (in mm/m).
|
||||||
|
variable_load_speed: 300
|
||||||
|
# Length (in mm) of the filament loading that feeds at priming speed.
|
||||||
|
variable_load_priming_length: 25.0
|
||||||
|
# Filament priming speed (in mm/m).
|
||||||
|
variable_load_priming_speed: 150
|
||||||
|
# Set to False to hide the Octoprint LCD menus.
|
||||||
|
variable_menu_show_octoprint: True
|
||||||
|
# Set to False to hide the SD Card LCD menus.
|
||||||
|
variable_menu_show_sdcard: True
|
||||||
|
# List up to 10 pre-heat settings in order for the LCD "Temperature" menu
|
||||||
|
variable_menu_temperature: [
|
||||||
|
{'name' : 'PLA', 'extruder' : 200, 'bed' : 60},
|
||||||
|
{'name' : 'PETG', 'extruder' : 230, 'bed' : 85},
|
||||||
|
{'name' : 'ABS', 'extruder' : 245, 'bed' : 110}]
|
||||||
|
# X position to park the toolhead.
|
||||||
|
variable_park_x: 0.0
|
||||||
|
# Y position to park the toolhead.
|
||||||
|
variable_park_y: 0.0
|
||||||
|
# Z position to park the toolhead.
|
||||||
|
variable_park_z: 20.0
|
||||||
|
# Minimum printable XY coordinate. Defaults to X and Y position_min.
|
||||||
|
variable_print_min: () # example: (0, 0)
|
||||||
|
# Maximum printable XY coordinate. Defaults to X and Y position_max.
|
||||||
|
variable_print_max: () # example: (220, 220)
|
||||||
|
# Scaling factor for M900 command (negative values make M900 a no-op).
|
||||||
|
variable_pressure_advance_scale: -1.0
|
||||||
|
# Additional padding around the specified print area for a bed mesh.
|
||||||
|
variable_probe_mesh_padding : 5.0
|
||||||
|
# Minimum number of probes for partial probing of a bed mesh.
|
||||||
|
variable_probe_min_count: 3
|
||||||
|
# Scaling factor to increase probe count for partial bed probes.
|
||||||
|
variable_probe_count_scale: 1.0
|
||||||
|
# Additional delay (in ms) during bed heating, to allow the bed to stabilize.
|
||||||
|
variable_start_bed_heat_delay: 2000
|
||||||
|
# Amount (in degrees C) to overshoot bed target temp before stabilizing.
|
||||||
|
variable_start_bed_heat_overshoot: 2.0
|
||||||
|
# Set to clear adjustments (e.g. feedrate, extrusion, heater) at end of print.
|
||||||
|
variable_start_clear_adjustments_at_end: True
|
||||||
|
# Final Y position of toolhead in PRINT_END. Defaults to print_max Y.
|
||||||
|
variable_start_end_park_y: 0.0
|
||||||
|
# Extruder scale factor during pre-warmup in PRINT_START.
|
||||||
|
variable_start_extruder_preheat_scale: 0.5
|
||||||
|
# Set the extruder target temp before bed level in PRINT_START.
|
||||||
|
variable_start_extruder_set_target_before_level: True
|
||||||
|
# Optional gcode run after all prep is complete, immediately before purge/print.
|
||||||
|
variable_start_gcode_before_print: ''
|
||||||
|
# Set to rehome Z in PRINT_START after bed temp stabilizes; False to disable.
|
||||||
|
variable_start_home_z_at_temp: True
|
||||||
|
# Set to level bed in PRINT_START after bed temp stabilizes; False to disable.
|
||||||
|
variable_start_level_bed_at_temp: True
|
||||||
|
# Distance (in millimeters) between the purge lines and the print area.
|
||||||
|
variable_start_purge_clearance: 2.0
|
||||||
|
# Length of filament (in millimeters) to purge at print start.
|
||||||
|
variable_start_purge_length: 0.0 # 30 is a good starting point.
|
||||||
|
# Length of filament (in millimeters) to prime before drawing purge lines.
|
||||||
|
variable_start_purge_prime_length: 15.0
|
||||||
|
# Level gantry in PRINT_START after bed temp stabilizes; False to disable.
|
||||||
|
variable_start_quad_gantry_level_at_temp: True
|
||||||
|
# Adjust Z tilt in PRINT_START after bed temp stabilizes; False to disable.
|
||||||
|
variable_start_z_tilt_adjust_at_temp: True
|
||||||
|
# X and Y travel speed (in mm/m) for movement macros.
|
||||||
|
variable_travel_speed_xy: 3000
|
||||||
|
# Z travel speed in (mm/m) for movement macros.
|
||||||
|
variable_travel_speed_z: 600
|
||||||
|
# Value to scale acceleration by when setting ACCEL_TO_DECEL in M204, etc.
|
||||||
|
variable_velocity_decel_scale: 0.5
|
||||||
|
################################################################################
|
||||||
|
description: Initializes our globals, including any _km_options overrides.
|
||||||
|
gcode:
|
||||||
|
# Doing a shutdown here is a bit aggressive, but if we're missing required
|
||||||
|
# sections then a lot of things could go very bad later.
|
||||||
|
# To minimize the annoyance we try to identify all the fatal errors at once.
|
||||||
|
# format is:
|
||||||
|
# key = required config section
|
||||||
|
# value[0] = required field in section
|
||||||
|
# value[1] = required string in field
|
||||||
|
# A "None" value means there's no required field
|
||||||
|
{% set required_sections = {"heater_bed" : None,
|
||||||
|
"extruder" : None,
|
||||||
|
"gcode_macro _km_options" : None,
|
||||||
|
"idle_timeout" : ("gcode", "_KM_IDLE_TIMEOUT"),
|
||||||
|
"pause_resume" : None,
|
||||||
|
"respond" : None,
|
||||||
|
"save_variables" : None,
|
||||||
|
"virtual_sdcard" : None
|
||||||
|
} %}
|
||||||
|
{% set output = [] %}
|
||||||
|
{% for s in required_sections %}
|
||||||
|
{% set f = required_sections[s][0] if required_sections[s] else None %}
|
||||||
|
{% set v = required_sections[s][1] if required_sections[s] else None %}
|
||||||
|
{% if s not in printer.configfile.config %}
|
||||||
|
{% set dummy = output.append("Missing [%s] section.\n" | format(s)) %}
|
||||||
|
{% elif f and
|
||||||
|
(v not in printer.configfile.config[s][f]|default("")|upper) %}
|
||||||
|
{% set dummy = output.append("Missing %s in %s for [%s] section.\n"
|
||||||
|
| format(v, f, s)) %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% if output %}
|
||||||
|
{ action_emergency_stop((
|
||||||
|
"required printer.cfg section(s) missing:\n"
|
||||||
|
~ output | join("\n")) ~
|
||||||
|
"See readme: https://github.com/jschuh/klipper-macros\x23klipper-setup")
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
# These are all set to their defaults based on config options:
|
||||||
|
SET_GCODE_VARIABLE MACRO=_km_globals VARIABLE=start_level_bed_at_temp VALUE="{
|
||||||
|
1 if printer.bed_mesh is defined else 0}"
|
||||||
|
BED_MESH_CHECK
|
||||||
|
SET_GCODE_VARIABLE MACRO=_km_globals VARIABLE=start_quad_gantry_level_at_temp VALUE="{
|
||||||
|
1 if printer.quad_gantry_level is defined else 0}"
|
||||||
|
SET_GCODE_VARIABLE MACRO=_km_globals VARIABLE=start_z_tilt_adjust_at_temp VALUE="{
|
||||||
|
1 if printer.z_tilt is defined else 0}"
|
||||||
|
{% set toolhead = printer.toolhead %}
|
||||||
|
SET_GCODE_VARIABLE MACRO=_km_globals VARIABLE=print_min VALUE="{
|
||||||
|
(toolhead.axis_minimum.x, toolhead.axis_minimum.y)}"
|
||||||
|
SET_GCODE_VARIABLE MACRO=_km_globals VARIABLE=print_max VALUE="{
|
||||||
|
(toolhead.axis_maximum.x, toolhead.axis_maximum.y)}"
|
||||||
|
SET_GCODE_VARIABLE MACRO=_km_globals VARIABLE=start_end_park_y VALUE="{
|
||||||
|
toolhead.axis_maximum.y}"
|
||||||
|
{% set settings = printer.configfile.settings %}
|
||||||
|
SET_GCODE_VARIABLE MACRO=_km_globals VARIABLE=start_home_z_at_temp VALUE="{
|
||||||
|
1 if ("stepper_z" in settings and
|
||||||
|
settings.stepper_z.endstop_pin.split()|join("")|lower ==
|
||||||
|
"probe:z_virtual_endstop") else 0}"
|
||||||
|
|
||||||
|
{% set options = printer["gcode_macro _km_options"] %}
|
||||||
|
{% set km = printer["gcode_macro _km_globals"] %}
|
||||||
|
# Force overrides to use the original types in _KM_GLOBALS.
|
||||||
|
{% for k in options %}
|
||||||
|
{% if k not in km %}
|
||||||
|
{action_raise_error("%s is not valid for _KM_OPTIONS." | format(k))}
|
||||||
|
{% endif %}
|
||||||
|
{% if km[k] is string %}
|
||||||
|
SET_GCODE_VARIABLE MACRO=_km_globals VARIABLE={k
|
||||||
|
} VALUE="'{options[k]|replace('\\','\\\\')|replace('\'','\\\'')
|
||||||
|
|replace('\"','\\\"')}'"
|
||||||
|
{% elif km[k] is float %}
|
||||||
|
SET_GCODE_VARIABLE MACRO=_km_globals VARIABLE={k
|
||||||
|
} VALUE="{options[k]|float}"
|
||||||
|
{% elif km[k] is integer or km[k] is boolean %}
|
||||||
|
SET_GCODE_VARIABLE MACRO=_km_globals VARIABLE={k} VALUE="{options[k]|int}"
|
||||||
|
{% elif km[k] is mapping %}
|
||||||
|
{% if options[k] is not mapping %}
|
||||||
|
{action_raise_error("%s requires a mapping type." | format(k))}
|
||||||
|
{% endif %}
|
||||||
|
SET_GCODE_VARIABLE MACRO=_km_globals VARIABLE={k
|
||||||
|
} VALUE="{options[k]|replace('\"','\\\"')}"
|
||||||
|
{% elif km[k] is sequence %}
|
||||||
|
{% if options[k] is not sequence %}
|
||||||
|
{action_raise_error("%s requires a sequence type." | format(k))}
|
||||||
|
{% endif %}
|
||||||
|
SET_GCODE_VARIABLE MACRO=_km_globals VARIABLE={k
|
||||||
|
} VALUE="{options[k]|replace('\"','\\\"')}"
|
||||||
|
{% else %}
|
||||||
|
{action_raise_error("%s is not a valid type for _KM_OPTIONS."|format(k))}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
# Defaults that can alias to a user override.
|
||||||
|
{% if "print_max" in options and "start_end_park_y" not in options %}
|
||||||
|
SET_GCODE_VARIABLE MACRO=_km_globals VARIABLE=start_end_park_y VALUE="{
|
||||||
|
options.print_max[1] }"
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if "homing_override" in printer.configfile.config %}
|
||||||
|
{% for l in printer.configfile.config.homing_override.gcode.split("\n") %}
|
||||||
|
{% if " g28 " in (" " ~ l.split("\x23")[0].split(";")[0]|lower ~ " ") %}
|
||||||
|
{ action_raise_error(
|
||||||
|
"G28 in [homing_override] gcode. Replace with G28.6245197 to "
|
||||||
|
"fix recursive macro call.\n"
|
||||||
|
"See readme: https://github.com/jschuh/klipper-macros\x23g28") }
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
M400
|
||||||
|
|
||||||
|
[delayed_gcode INIT_GLOBALS]
|
||||||
|
# This runs once at startup and initializes all macros.
|
||||||
|
initial_duration: 1
|
||||||
|
gcode:
|
||||||
|
_KM_GLOBALS
|
||||||
|
# This needs to be its own macro so it gets evaluated after _KM_GLOBALS runs.
|
||||||
|
CHECK_KM_CONFIG
|
||||||
|
_INIT_SURFACES
|
||||||
|
# Sets the default drawing parameters.
|
||||||
|
SET_DRAW_PARAMS WIDTH="{printer.configfile.settings.extruder.nozzle_diameter}"
|
||||||
|
# This is any end-user gcode that need to run after macro initialization.
|
||||||
|
_KM_OPTIONS
|
||||||
|
|
||||||
|
[gcode_macro check_km_config]
|
||||||
|
description: Checks global variables and throws an error on any invalid values.
|
||||||
|
Does nothing if the config has no errors.
|
||||||
|
gcode:
|
||||||
|
{% set km = printer["gcode_macro _km_globals"] %}
|
||||||
|
{% set toolhead = printer.toolhead %}
|
||||||
|
{% set output = [] %}
|
||||||
|
{% if km.park_x > toolhead.axis_maximum.x or
|
||||||
|
km.park_x < toolhead.axis_minimum.x %}
|
||||||
|
{% set dummy = output.append("park_x is invalid.") %}
|
||||||
|
{% endif %}
|
||||||
|
{% if km.park_y > toolhead.axis_maximum.y or
|
||||||
|
km.park_y < toolhead.axis_minimum.y %}
|
||||||
|
{% set dummy = output.append("park_y is invalid.") %}
|
||||||
|
{% endif %}
|
||||||
|
{% if km.park_z > toolhead.axis_maximum.z or
|
||||||
|
km.park_z < toolhead.axis_minimum.z %}
|
||||||
|
{% set dummy = output.append("park_z is invalid.") %}
|
||||||
|
{% endif %}
|
||||||
|
{% if km.print_max[0] > toolhead.axis_maximum.x or
|
||||||
|
km.print_max[1] > toolhead.axis_maximum.y %}
|
||||||
|
{% set dummy = output.append("print_max is invalid.") %}
|
||||||
|
{% endif %}
|
||||||
|
{% if km.print_min[0] < toolhead.axis_minimum.x or
|
||||||
|
km.print_min[1] < toolhead.axis_minimum.y %}
|
||||||
|
{% set dummy = output.append("print_min is invalid.") %}
|
||||||
|
{% endif %}
|
||||||
|
{% if km.start_extruder_preheat_scale > 1.0 or
|
||||||
|
km.start_extruder_preheat_scale < 0.0 %}
|
||||||
|
{% set dummy = output.append("extruder_preheat_scale is invalid.") %}
|
||||||
|
{% endif %}
|
||||||
|
{% if km.load_length >
|
||||||
|
printer.configfile.settings["extruder"].max_extrude_only_distance %}
|
||||||
|
{% set dummy = output.append(
|
||||||
|
"load_length exceeds max_extrude_only_distance.") %}
|
||||||
|
{% endif %}
|
||||||
|
{% if km.load_length < km.load_priming_length %}
|
||||||
|
{% set dummy = output.append(
|
||||||
|
"load_length is shorter than load_priming_length.") %}
|
||||||
|
{% endif %}
|
||||||
|
{% if km.load_length < 0.0 %}
|
||||||
|
{% set dummy = output.append("load_length is negative.") %}
|
||||||
|
{% endif %}
|
||||||
|
{% if km.load_priming_length < 0.0 %}
|
||||||
|
{% set dummy = output.append("load_priming_length is negative.") %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
# Emit all the config errors.
|
||||||
|
{% if output %}
|
||||||
|
{ action_raise_error(output|sort|join('\n')) }
|
||||||
|
{% endif %}
|
||||||
|
M400
|
||||||
|
|
||||||
|
[gcode_macro kmvars]
|
||||||
|
description: Lists global variables used by klipper-macros.
|
||||||
|
Usage: KMVARS [SEARCH=<search_string>]
|
||||||
|
gcode:
|
||||||
|
{% set SEARCH = params.SEARCH|default(params.S|default(""))|lower %}
|
||||||
|
{% set km = printer["gcode_macro _km_globals"] %}
|
||||||
|
{% set output = [] %}
|
||||||
|
{% for k in km %}
|
||||||
|
{% if SEARCH in k %}
|
||||||
|
{% set dummy = output.append(k ~ ": " ~ km[k]) %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{ action_respond_info(output|sort|join('\n')) }
|
||||||
|
|
||||||
|
[gcode_macro check_macro_docs]
|
||||||
|
description: Lists macros lacking proper documentation.
|
||||||
|
Usage: CHECK_MACRO_DOCS [USAGE=<0|1>] [HIDDEN=<1|0>] [RENAMED=<1|0>]
|
||||||
|
gcode:
|
||||||
|
{% set USAGE = params.USAGE|default(0)|int %}
|
||||||
|
{% set HIDDEN = params.HIDDEN|default(0)|int %}
|
||||||
|
{% set RENAMED = params.RENAMED|default(0)|int %}
|
||||||
|
{% set output = [] %}
|
||||||
|
{%set config = printer.configfile.config %}
|
||||||
|
{% for k in config|sort %}
|
||||||
|
{% if k.startswith("gcode_macro") %}
|
||||||
|
{% set name = k.split()[1] %}
|
||||||
|
{% set desc = config[k].description|default("") %}
|
||||||
|
{% set is_renamed = config[k].rename_existing|default("") %}
|
||||||
|
{% if (not desc or (USAGE and not "Usage: "~name.upper() in desc)) and
|
||||||
|
(HIDDEN or not name.startswith('_')) and (RENAMED or is_renamed) %}
|
||||||
|
{% set dummy = output.append("%s %s: missing %s."
|
||||||
|
| format("*" if is_renamed else " ", name,
|
||||||
|
"description" if not desc else "usage")) %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{action_respond_info(output|join("\n"))}
|
||||||
|
|
||||||
|
# The below macro is a lightly edited version of the one found here:
|
||||||
|
# https://klipper.discourse.group/t/example-search-printer-objects/164
|
||||||
|
[gcode_macro listvars]
|
||||||
|
description: Lists per-macro variables with a name containing SEARCH. This is
|
||||||
|
useful for debugging macros by allowing you to probe printer state. Be very
|
||||||
|
careful, however, as an overly broad SEARCH parameter can take a long time
|
||||||
|
to process and potentially hang or crash klipper.
|
||||||
|
Usage: LISTVARS SEARCH=<search_string>
|
||||||
|
gcode:
|
||||||
|
|
||||||
|
{% if 'SEARCH' not in params and 'S' not in params %}
|
||||||
|
{ action_raise_error("Must provide a SEARCH parameter.") }
|
||||||
|
{% endif %}
|
||||||
|
{% set SEARCH = params.SEARCH|default(params.S)|lower %}
|
||||||
|
{% set ns = namespace() %}
|
||||||
|
{% set output = [] %}
|
||||||
|
{% for item in printer %}
|
||||||
|
{% if ' ' in item %}
|
||||||
|
{% set ns.path = ['printer', "['%s']" % (item), ''] %}
|
||||||
|
{% else %}
|
||||||
|
{% set ns.path = ['printer.', item, ''] %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if SEARCH in ns.path|lower %}
|
||||||
|
{% set dummy = output.append(ns.path|join) %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if printer[item].items() %}
|
||||||
|
{% for childkey, child in printer[item].items() recursive %}
|
||||||
|
{% set ns.path = ns.path[:loop.depth|int + 1] %}
|
||||||
|
{% if ' ' in childkey %}
|
||||||
|
{% set null = ns.path.append("['%s']" % (childkey)) %}
|
||||||
|
{% else %}
|
||||||
|
{% set null = ns.path.append(".%s" % (childkey)) %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if child is mapping %}
|
||||||
|
{loop(child.items())}
|
||||||
|
{% else %}
|
||||||
|
{% if SEARCH in ns.path|lower %}
|
||||||
|
{% set dummy = output.append("%s : %s" % (ns.path|join, child)) %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{ action_respond_info(output|join("\n")) }
|
||||||
235
klipper/DNV-TPU-Ender3/klipper_config/klipper-macros/heaters.cfg
Normal file
235
klipper/DNV-TPU-Ender3/klipper_config/klipper-macros/heaters.cfg
Normal file
@@ -0,0 +1,235 @@
|
|||||||
|
# Copyright (C) 2022 Justin Schuh <code@justinschuh.com>
|
||||||
|
#
|
||||||
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
|
|
||||||
|
[gcode_macro set_heater_temperature_scaled]
|
||||||
|
gcode:
|
||||||
|
{% set HEATER = params.HEATER.lower() %}
|
||||||
|
{% set TARGET = params.TARGET|default(0.0)|float %}
|
||||||
|
{% set scaled_heaters =
|
||||||
|
printer["gcode_macro set_heater_scaling"].scaled_heaters %}
|
||||||
|
{% if HEATER in scaled_heaters %}
|
||||||
|
{% set scales = scaled_heaters[HEATER] %}
|
||||||
|
{% set dummy = scales.__setitem__("real_target", TARGET) %}
|
||||||
|
{%if TARGET > 0.0 %}
|
||||||
|
{% set TARGET = (((TARGET + scales.bump) * scales.scale, scales.minimum)
|
||||||
|
| max, scales.maximum)|min %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
SET_HEATER_TEMPERATURE HEATER="{HEATER}" TARGET={TARGET}
|
||||||
|
|
||||||
|
[gcode_macro temperature_wait_scaled]
|
||||||
|
gcode:
|
||||||
|
{% set SENSOR = params.SENSOR.lower() %}
|
||||||
|
{% set heater = SENSOR if not SENSOR.startswith("heater_generic") else
|
||||||
|
SENSOR.split()[1] %}
|
||||||
|
{% set scaled_heaters =
|
||||||
|
printer["gcode_macro set_heater_scaling"].scaled_heaters %}
|
||||||
|
{% if heater in scaled_heaters %}
|
||||||
|
{% set scales = scaled_heaters[heater] %}
|
||||||
|
{% if "MINIMUM" in params and MINIMUM > 0.0 %}
|
||||||
|
{% set MINIMUM = (((MINIMUM + scales.bump) * scales.scale, scales.minimum)
|
||||||
|
| max, scales.maximum)|min %}
|
||||||
|
{% endif %}
|
||||||
|
{% if "MAXIMUM" in params and MINIMUM > 0.0 %}
|
||||||
|
{% set MAXIMUM = (((MAXIMUM + scales.bump) * scales.scale, scales.minimum)
|
||||||
|
| max, scales.maximum)|min %}
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
{% set settings = printer.configfile.settings[SENSOR] %}
|
||||||
|
{% set MINIMUM = params.MINIMUM|default(settings.min_temp) %}
|
||||||
|
{% set MAXIMUM = params.MAXIMUM|default(settings.max_temp) %}
|
||||||
|
{% endif %}
|
||||||
|
{% if printer[sensor].temperature < MINIMUM or
|
||||||
|
printer[sensor].temperature > MAXIMUM %}
|
||||||
|
TEMPERATURE_WAIT SENSOR="{SENSOR}" MINIMUM={MINIMUM} MAXIMUM={MAXIMUM}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
[gcode_macro _gcode_wait_wrapper_inner]
|
||||||
|
gcode:
|
||||||
|
# Macro variables are evaluated at instantiation, so this inner macro is what
|
||||||
|
# gets us a scaled target value.
|
||||||
|
{% set sensor = params.HEATER if params.HEATER in
|
||||||
|
printer.heaters.available_heaters
|
||||||
|
else ("heater_generic " ~ params.HEATER) %}
|
||||||
|
{% set target = printer[sensor].target %}
|
||||||
|
{% if 'R' in params and target > 0.0 %}
|
||||||
|
{% set T = params.T|default("") %}
|
||||||
|
M{params.M}.6245197 S{target} { (" T"~T) if T else "" }
|
||||||
|
{% elif printer[sensor].temperature < target %}
|
||||||
|
TEMPERATURE_WAIT SENSOR="{sensor}" MINIMUM={target}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
[gcode_macro _gcode_wait_wrapper]
|
||||||
|
gcode:
|
||||||
|
{% set target = params.S | default(params.R | default(0))| float %}
|
||||||
|
SET_HEATER_TEMPERATURE_SCALED HEATER="{params.HEATER}" TARGET={target}
|
||||||
|
_GCODE_WAIT_WRAPPER_INNER{%
|
||||||
|
for k in params %}{' '~k~'="'~params[k]~'"'}{% endfor %}
|
||||||
|
|
||||||
|
[gcode_macro m109]
|
||||||
|
rename_existing: M109.6245197
|
||||||
|
gcode:
|
||||||
|
{% set extruder = "extruder" ~ params.T|replace('0', '')
|
||||||
|
if "T" in params else printer.toolhead.extruder %}
|
||||||
|
_GCODE_WAIT_WRAPPER HEATER={extruder}{%
|
||||||
|
for k in params %}{' '~k~'="'~params[k]~'"'}{% endfor %}
|
||||||
|
|
||||||
|
[gcode_macro m190]
|
||||||
|
rename_existing: M190.6245197
|
||||||
|
gcode:
|
||||||
|
_GCODE_WAIT_WRAPPER HEATER=heater_bed {%
|
||||||
|
for k in params %}{' '~k~'="'~params[k]~'"'}{% endfor %}
|
||||||
|
|
||||||
|
[gcode_macro m191]
|
||||||
|
description: Sets chamber temperature (with wait for heating).
|
||||||
|
Usage: M191 [S<temp>]
|
||||||
|
gcode:
|
||||||
|
# Just fake the R parameter for the chamber.
|
||||||
|
{% if "R" in params %}
|
||||||
|
{% set dummy = params.__setitem__("S", params.R) %}
|
||||||
|
{% endif %}
|
||||||
|
_GCODE_WAIT_WRAPPER HEATER=chamber {%
|
||||||
|
for k in params %}{' '~k~'="'~params[k]~'"'}{% endfor %}
|
||||||
|
|
||||||
|
[gcode_macro m104]
|
||||||
|
rename_existing: M104.6245197
|
||||||
|
gcode:
|
||||||
|
{% set extruder = "extruder" ~ params.T|replace('0', '')
|
||||||
|
if "T" in params else printer.toolhead.extruder %}
|
||||||
|
SET_HEATER_TEMPERATURE_SCALED HEATER={extruder} TARGET={params.S|default(0)}
|
||||||
|
|
||||||
|
[gcode_macro m140]
|
||||||
|
rename_existing: M140.6245197
|
||||||
|
gcode:
|
||||||
|
SET_HEATER_TEMPERATURE_SCALED HEATER=heater_bed TARGET={params.S|default(0)}
|
||||||
|
|
||||||
|
[gcode_macro m141]
|
||||||
|
description: Sets chamber temperature.
|
||||||
|
Usage: M141 [S<temp>]
|
||||||
|
gcode:
|
||||||
|
SET_HEATER_TEMPERATURE_SCALED HEATER=chamber TARGET={params.S|default(0)}
|
||||||
|
|
||||||
|
[gcode_macro _check_heater_params]
|
||||||
|
gcode:
|
||||||
|
{% set HEATER = params.HEATER|lower %}
|
||||||
|
{% set sensor = params.HEATER %}
|
||||||
|
{% if HEATER not in printer.heaters.available_heaters %}
|
||||||
|
{% set sensor = "heater_generic " ~ HEATER %}
|
||||||
|
{% if sensor not in printer.heaters.available_heaters %}
|
||||||
|
{ action_raise_error("The value '%s' is not valid for HEATER"
|
||||||
|
| format(HEATER)) }
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% set settings = printer.configfile.settings[sensor] %}
|
||||||
|
{% set scaled_heaters =
|
||||||
|
printer["gcode_macro set_heater_scaling"].scaled_heaters %}
|
||||||
|
{% if HEATER is in scaled_heaters %}
|
||||||
|
{% set scales = scaled_heaters[HEATER] %}
|
||||||
|
{% else %}
|
||||||
|
{% set scales = { "scale": 1.0, "bump": 0.0, "minimum": settings.min_temp,
|
||||||
|
"maximum": settings.max_temp,
|
||||||
|
"real_target": printer[sensor].target} %}
|
||||||
|
{% endif %}
|
||||||
|
{% set SCALE = params.SCALE|default(scales.scale)|float %}
|
||||||
|
{% set BUMP = params.BUMP|default(scales.bump)|float %}
|
||||||
|
{% set MINIMUM = params.MINIMUM|default(scales.minimum)|float %}
|
||||||
|
{% set MAXIMUM = params.MAXIMUM|default(scales.maximum)|float %}
|
||||||
|
|
||||||
|
{% if SCALE <= 0 %}
|
||||||
|
{ action_raise_error("SCALE must be a positive value.") }
|
||||||
|
{% elif MINIMUM < settings.min_temp or MINIMUM > settings.max_temp %}
|
||||||
|
{ action_raise_error("MINIMUM must be between %.1f and %.1f" |
|
||||||
|
format(settings.min_temp, settings.max_temp)) }
|
||||||
|
{% elif MAXIMUM < settings.min_temp or MAXIMUM > settings.max_temp %}
|
||||||
|
{ action_raise_error("MAXIMUM must be between %.1f and %.1f" |
|
||||||
|
format(settings.min_temp, settings.max_temp)) }
|
||||||
|
{% elif MINIMUM >= MAXIMUM %}
|
||||||
|
{ action_raise_error("MINIMUM must be less than MAXIMUM.") }
|
||||||
|
{% elif "TARGET" in params and (params.TARGET|float < MINIMUM or
|
||||||
|
params.TARGET|float > MAXIMUM) %}
|
||||||
|
{ action_raise_error("TARGET must be between %.1f and %.1f" |
|
||||||
|
format(settings.min_temp, settings.max_temp)) }
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
[gcode_macro set_heater_scaling]
|
||||||
|
description: Sets scaling parameters for heater. If a new target temperature is passed it will be adjusted to the scaling parameters.
|
||||||
|
Usage: SET_HEATER_SCALING [HEATER=<heater>] [SCALE=<scale_factor>]
|
||||||
|
[BUMP=<degrees>] [MAXIMUM=<degrees>]
|
||||||
|
[MINIMUM=<degrees>] [TARGET=<temp>]
|
||||||
|
variable_scaled_heaters: {}
|
||||||
|
gcode:
|
||||||
|
# If no heater is supplied just list out all the scaled heaters.
|
||||||
|
{% if "HEATER" is not in params %}
|
||||||
|
{% set output = [] %}
|
||||||
|
{% for h in scaled_heaters %}
|
||||||
|
{% set dummy = output.append(
|
||||||
|
"%s: Scale: %.2f Bump: %.1f Minimum:%.1f Maximum: %.1f"
|
||||||
|
| format(h, scaled_heaters[h].scale, scaled_heaters[h].bump,
|
||||||
|
scaled_heaters[h].minimum, scaled_heaters[h].maximum)) %}
|
||||||
|
{% endfor %}
|
||||||
|
{% if output %}}{action_respond_info(output|join('\n'))}{% endif %}
|
||||||
|
{% else %}
|
||||||
|
# See if we need a new scaling entry for this heater.
|
||||||
|
{% set HEATER = params.HEATER.lower() %}
|
||||||
|
{% set settings = printer.configfile.settings[HEATER] %}
|
||||||
|
{% if HEATER is not in scaled_heaters %}
|
||||||
|
{% set dummy = scaled_heaters.__setitem__(HEATER, {"scale": 1.0,
|
||||||
|
"bump": 0.0, "minimum": settings.min_temp,
|
||||||
|
"maximum": settings.max_temp,
|
||||||
|
"real_target": printer[HEATER].target}) %}
|
||||||
|
{% endif %}
|
||||||
|
_CHECK_HEATER_PARAMS{% for k in params %}{' '~k~'='~params[k]}{% endfor %}
|
||||||
|
{% set scales = scaled_heaters[HEATER] %}
|
||||||
|
{% set SCALE = params.SCALE|default(scales.scale)|float %}
|
||||||
|
{% set BUMP = params.BUMP|default(scales.bump)|float %}
|
||||||
|
{% set MAXIMUM = params.MAXIMUM|default(scales.maximum)|float %}
|
||||||
|
{% set MINIMUM = params.MINIMUM|default(scales.minimum)|float %}
|
||||||
|
{% set TARGET = params.TARGET|default(scales.real_target)|float %}
|
||||||
|
{% set dummy = scales.__setitem__("scale", SCALE) %}
|
||||||
|
{% set dummy = scales.__setitem__("bump", BUMP) %}
|
||||||
|
{% set dummy = scales.__setitem__("maximum", MAXIMUM) %}
|
||||||
|
{% set dummy = scales.__setitem__("minimum", MINIMUM) %}
|
||||||
|
{% set dummy = scales.__setitem__("real_target", TARGET) %}
|
||||||
|
|
||||||
|
{% set settings = printer.configfile.settings[HEATER] %}
|
||||||
|
{% if SCALE != 1.0 or BUMP != 0.0 or MINIMUM != settings.min_temp or
|
||||||
|
MAXIMUM != settings.max_temp %}
|
||||||
|
{% set dummy = scaled_heaters.__setitem__(HEATER, scales) %}
|
||||||
|
{% else %} # Remove a redundant scaling entry.
|
||||||
|
{% set dummy = scaled_heaters.__delitem__(HEATER) %}
|
||||||
|
{% endif %}
|
||||||
|
SET_HEATER_TEMPERATURE_SCALED HEATER={HEATER} TARGET={TARGET}
|
||||||
|
{action_respond_info(
|
||||||
|
"%s: Scale: %.2f Bump: %.1f Minimum:%.1f Maximum: %.1f Target: %.1f"
|
||||||
|
| format(HEATER, SCALE, BUMP, MINIMUM, MAXIMUM, TARGET))}
|
||||||
|
{% endif %}
|
||||||
|
# Dummy argument block for Mainsail
|
||||||
|
{% set dummy = None if True else "
|
||||||
|
{% set dummy = params.HEATER|default(e.g. extruder) %}
|
||||||
|
{% set dummy = params.SCALE|default(1.0)|float %}
|
||||||
|
{% set dummy = params.BUMP|default(0.0)|float %}
|
||||||
|
{% set dummy = params.MAXIMUM|default(max_temp)|float %}
|
||||||
|
{% set dummy = params.MINIMUM|default(min_temp)|float %}
|
||||||
|
{% set dummy = params.TARGET|default(current target)|float %}
|
||||||
|
" %} # End argument block for Mainsail
|
||||||
|
|
||||||
|
[gcode_macro reset_heater_scaling]
|
||||||
|
description: Clears scaling for heater (or all heaters if none specified).
|
||||||
|
Usage: RESET_HEATER_SCALING [HEATER=<heater>]
|
||||||
|
gcode:
|
||||||
|
{% if "HEATER" in params %}
|
||||||
|
{% set HEATER = params.HEATER.lower() %}
|
||||||
|
{% if HEATER not in printer.heaters.available_heaters %}
|
||||||
|
{ action_raise_error("The value '%s' is not valid for HEATER"
|
||||||
|
| format(HEATER)) }
|
||||||
|
{% endif %}
|
||||||
|
{% set settings = printer.configfile.settings[HEATER] %}
|
||||||
|
SET_HEATER_SCALING HEATER={HEATER
|
||||||
|
} SCALE=1.0 BUMP=0.0 MINIMUM={settings.min_temp
|
||||||
|
} MAXIMUM={settings.max_temp}
|
||||||
|
{% else %}
|
||||||
|
# Clear everything if no heater was provided.
|
||||||
|
SET_GCODE_VARIABLE MACRO=set_heater_scaling VARIABLE=scaled_heaters VALUE={
|
||||||
|
"{}"}
|
||||||
|
{% endif %}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
# Copyright (C) 2022 Justin Schuh <code@justinschuh.com>
|
||||||
|
#
|
||||||
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
|
|
||||||
|
[gcode_macro _km_idle_timeout]
|
||||||
|
gcode:
|
||||||
|
{% if printer.pause_resume.is_paused %}
|
||||||
|
{action_respond_info("Extruder powered down on idle timeout.")}
|
||||||
|
SET_GCODE_VARIABLE MACRO=resume VARIABLE=saved_extruder_temp VALUE="{
|
||||||
|
printer[printer.toolhead.extruder].target}"
|
||||||
|
M104; Turn off extruder but leave the bed on.
|
||||||
|
{% else %}
|
||||||
|
TURN_OFF_HEATERS
|
||||||
|
M107; turn off fan
|
||||||
|
M84
|
||||||
|
{% endif %}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
# Copyright (C) 2022 Justin Schuh <code@justinschuh.com>
|
||||||
|
#
|
||||||
|
# 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 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 do_homing = True %}
|
||||||
|
{% if 'O' in params %}
|
||||||
|
# No axes means home them all, so add the list in before pruning.
|
||||||
|
{% if params|select('in', 'XYZ')|list|length == 0 %}
|
||||||
|
{% for k in 'XYZ' %}
|
||||||
|
{% set dummy = params.__setitem__(k, '') %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
# Prune out the already homed axes.
|
||||||
|
{% for k in params|select('in', 'XYZ')|list %}
|
||||||
|
{% if k|lower in printer.toolhead.homed_axes %}
|
||||||
|
{% set dummy = params.__delitem__(k) %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% set dummy = params.__delitem__('O') %}
|
||||||
|
# If we don't have anything left we can skip homing.
|
||||||
|
{% set do_homing = params|select('in', 'XYZ')|list|length > 0 %}
|
||||||
|
{% else %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if do_homing %}
|
||||||
|
G28.6245197{% for k in params %}{' ' ~ k ~ params[k]}{% endfor %}
|
||||||
|
{% endif %}
|
||||||
Reference in New Issue
Block a user