Files
3dprinters/klipper/DNV-TPU-Ender3/klipper_config/klipper-macros/velocity.cfg

87 lines
2.8 KiB
INI

# Copyright (C) 2022 Justin Schuh <code@justinschuh.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
[gcode_macro m201]
description: Sets maximum accelleration.
Usage: M201 [X<accel>] [Y<accel>]
variable_max_accel: 1.7976931348623157e+308
gcode:
{% set km = printer["gcode_macro _km_globals"] %}
{% if 'X' in params or 'Y' in params %}
{% set accel = (params.X|default(params.Y)|float,
params.Y|default(params.X)|float)|min %}
SET_GCODE_VARIABLE MACRO=m201 VARIABLE=max_accel VALUE="{accel}"
{% if accel < printer.toolhead.max_accel %}
SET_VELOCITY_LIMIT ACCEL="{accel
}" ACCEL_TO_DECEL="{accel * km.velocity_decel_scale}"
{% endif %}
{% else %}
SET_VELOCITY_LIMIT
{% endif %}
[gcode_macro m203]
description: Sets maximum velocity.
Usage: M203 [X<velocity>] [Y<velocity>]
gcode:
{% if 'X' in params or 'Y' in params %}
{% set velocity = (params.X|default(params.Y)|float,
params.Y|default(params.X)|float)|min %}
SET_VELOCITY_LIMIT VELOCITY="{velocity}"
{% else %}
SET_VELOCITY_LIMIT
{% endif %}
[gcode_macro m204]
description: Sets maximum accelleration.
Usage: M204 [S<accel>] [P<accel> T<accel>]
rename_existing: M204.6245197
gcode:
{% set km = printer["gcode_macro _km_globals"] %}
{% set max_accel = printer["gcode_macro m201"].max_accel %}
{% set accel = 0.0 %}
{% if 'S' in params %}
{% set accel = (params.S|float, max_accel)|min %}
{% elif 'P' in params %}
{% set accel = (params.P|float, params.T|default(params.P)|float,
max_accel)|min %}
{% endif %}
{% if accel %}
SET_VELOCITY_LIMIT ACCEL="{accel
}" ACCEL_TO_DECEL="{accel * km.velocity_decel_scale}"
{% else %}
SET_VELOCITY_LIMIT
{% endif %}
[gcode_macro m205]
description: Sets square corner velocity.
Usage: M203 [X<velocity>] [Y<velocity>]
gcode:
{% if 'X' in params or 'Y' in params %}
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY="{
(params.X|default(0)|float, params.Y|default(0)|float)|min}"
{% else %}
SET_VELOCITY_LIMIT
{% endif %}
[gcode_macro m900]
description: Sets pressure advance.
Usage: M900 [K<advance>] [T<extruder_index>]
gcode:
{% set km = printer["gcode_macro _km_globals"] %}
{% if km.pressure_advance_scale > 0.0 %}
{% set extruder = "extruder" ~ params.T|replace('0', '')
if "T" in params else printer.toolhead.extruder %}
{% if 'K' in params %}
SET_PRESSURE_ADVANCE EXTRUDER="{extruder}" ADVANCE="{
params.K|float * km.pressure_advance_scale}"
{% endif %}
{% endif %}
[gcode_macro _reset_velocity_limits]
description: Sets maximum accelleration.
Usage: M204 [S<accel>] [P<accel> T<accel>]
gcode:
SET_GCODE_VARIABLE MACRO=m201 VARIABLE=max_accel VALUE="{1.7976931348623157e+308}"