Upload files to "klipper/DNV-TPU-Ender3/klipper_config/klipper-macros"
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
[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, and
|
||||
# not sure how to make relative reference index work.
|
||||
{%if "mesh_radius" not in bed_mesh and
|
||||
"MESH_RADIUS" not in params and
|
||||
"relative_reference_index" not in bed_mesh and
|
||||
"RELATIVE_REFERENCE_INDEX" not in params %}
|
||||
{% 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 %}
|
||||
|
||||
# Always bound MESH_MIN and MESH_MAX.
|
||||
{% 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(",") %}
|
||||
# Don't scale the probe count if one was explicitly provided.
|
||||
{% if "PROBE_COUNT" not in params %}
|
||||
{% 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 %}
|
||||
# Add probes for bicubic if one axis has too many probes for lagrange.
|
||||
{% if x_probes > 6 and y_probes < 4 %}
|
||||
{% set y_probes = 4 %}
|
||||
{% elif y_probes > 6 and x_probes < 4 %}
|
||||
{% set x_probes = 4 %}
|
||||
{% endif %}
|
||||
{% set probe_count = [x_probes,y_probes] %}
|
||||
{% endif %}
|
||||
{% 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", probe_count|join(',')) %}
|
||||
# Force bicubic if we've exceeded the max for lagrange.
|
||||
{% if probe_count[0]|int > 6 or probe_count[1]|default(0)|int > 6 %}
|
||||
{% set dummy = params.__setitem__("ALGORITHM", "bicubic") %}
|
||||
{% endif %}
|
||||
{% 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 %}
|
||||
BED_MESH_CHECK
|
||||
{calibrate_cmd}{%for k in params%}{' '~k~'="'~params[k]~'"'}{%endfor%}
|
||||
|
||||
[gcode_macro bed_mesh_check]
|
||||
description: Warns if bed_mesh config may generate an invalid mesh.
|
||||
Usage: See Klipper documentation.
|
||||
gcode:
|
||||
{% if printer.bed_mesh is defined %}
|
||||
{% set x_min = printer.configfile.settings.stepper_x.position_min %}
|
||||
{% set y_min = printer.configfile.settings.stepper_y.position_min %}
|
||||
{% set x_max = printer.configfile.settings.stepper_x.position_max %}
|
||||
{% set y_max = printer.configfile.settings.stepper_y.position_max %}
|
||||
|
||||
{% set mesh_min_x = printer.configfile.settings.bed_mesh.mesh_min[0] %}
|
||||
{% set mesh_min_y = printer.configfile.settings.bed_mesh.mesh_min[1] %}
|
||||
{% set mesh_max_x = printer.configfile.settings.bed_mesh.mesh_max[0] %}
|
||||
{% set mesh_max_y = printer.configfile.settings.bed_mesh.mesh_max[1] %}
|
||||
|
||||
{% if "bltouch" in printer.configfile.settings %}
|
||||
{% set x_offset = printer.configfile.settings.bltouch.x_offset %}
|
||||
{% set y_offset = printer.configfile.settings.bltouch.y_offset %}
|
||||
{% set probe = "bltouch" %}
|
||||
{% elif "probe" in printer.configfile.settings %}
|
||||
{% set x_offset = printer.configfile.settings.probe.x_offset %}
|
||||
{% set y_offset = printer.configfile.settings.probe.y_offset %}
|
||||
{% set probe = "probe" %}
|
||||
{% else %}
|
||||
{% set x_offset = 0.0 %}
|
||||
{% set y_offset = 0.0 %}
|
||||
{% endif %}
|
||||
|
||||
{% set output = [] %}
|
||||
{% set warn =
|
||||
"* bed_mesh.mesh_%s (%f, %f) does not account for " ~ probe ~
|
||||
".%s_offset (%f) and can move out of range for "
|
||||
"stepper_%s.position_%s (%f)." %}
|
||||
{% if x_offset > 0 and (mesh_min_x - x_offset) < x_min %}
|
||||
{% set dummy = output.append(warn % ('min', mesh_min_x, mesh_min_y,
|
||||
'x', x_offset, 'x', 'min', x_min)) %}
|
||||
{% elif x_offset < 0 and (mesh_max_x - x_offset) > x_max %}
|
||||
{% set dummy = output.append(warn % ('max', mesh_max_x, mesh_max_y,
|
||||
'x', x_offset, 'x', 'max', x_max)) %}
|
||||
{% endif %}
|
||||
{% if y_offset > 0 and (mesh_min_y - y_offset) < y_min %}
|
||||
{% set dummy = output.append(warn % ('min', mesh_min_x, mesh_min_y,
|
||||
'y', y_offset, 'y', 'min', y_min)) %}
|
||||
{% elif y_offset < 0 and (mesh_max_y - y_offset) > y_max %}
|
||||
{% set dummy = output.append(warn % ('max', mesh_max_x, mesh_max_y,
|
||||
'y', y_offset, 'y', 'max', y_max)) %}
|
||||
{% endif %}
|
||||
|
||||
{% if output %}
|
||||
{ action_respond_info(
|
||||
"Warning: The following issue(s) were detected in your [bed_mesh] "
|
||||
" config:\n" ~ output|join("\n")) }
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
@@ -0,0 +1,184 @@
|
||||
# Copyright (C) 2022 Justin Schuh <code@justinschuh.com>
|
||||
#
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
#
|
||||
# Credit to original source:
|
||||
# https://klipper.discourse.group/t/saving-and-adjusting-per-build-surface-z-offsets/696
|
||||
|
||||
[gcode_macro _apply_bed_surface_offset]
|
||||
gcode:
|
||||
{% set surfaces = printer.save_variables.variables.bed_surfaces %}
|
||||
{% if surfaces.active %}
|
||||
SET_SURFACE_ACTIVE SURFACE={surfaces.active}
|
||||
{% endif %}
|
||||
|
||||
[gcode_macro _init_surfaces]
|
||||
gcode:
|
||||
{% set km = printer["gcode_macro _km_globals"] %}
|
||||
{% if "bed_surfaces" in printer.save_variables.variables %}
|
||||
{% set old_surfaces = printer.save_variables.variables.bed_surfaces %}
|
||||
{% else %}
|
||||
{% set old_surfaces = { 'active' : '', 'available' : {} } %}
|
||||
{% endif %}
|
||||
{% set settings = printer.configfile.settings %}
|
||||
{% set new_probe_z = (settings.probe | default(settings.bltouch) |
|
||||
default(settings.smart_effector) | default({})
|
||||
).z_offset|default(0.0)|float %}
|
||||
{% set new_endstop_z = (settings.stepper_z | default({})).position_endstop |
|
||||
default(0.0)|float %}
|
||||
{% if 'endstop_z' not in old_surfaces %}
|
||||
{% set dummy = old_surfaces.__setitem__('endstop_z', new_endstop_z) %}
|
||||
{% endif %}
|
||||
{% if 'probe_z' not in old_surfaces %}
|
||||
{% set dummy = old_surfaces.__setitem__('probe_z', new_probe_z) %}
|
||||
{% endif %}
|
||||
{% set surfaces = { 'active' : '', 'available' : {},
|
||||
'endstop_z' : old_surfaces.endstop_z,
|
||||
'probe_z' : old_surfaces.probe_z } %}
|
||||
{% for s in km.bed_surfaces %}
|
||||
{% set s = s.split()|join(' ')|lower %}
|
||||
{% if s|length > km.bed_surface_max_name_length or
|
||||
s|list|select("in", " \r\n\"\'")|list %}
|
||||
{action_raise_error('Invalid surface name "%s". Name must be %d or fewer '
|
||||
'characters and must not include space or quotation characters'
|
||||
| format(s, km.bed_surface_max_name_length))}
|
||||
{% endif %}
|
||||
{% if s in old_surfaces.available %}
|
||||
{% set dummy = surfaces.available.__setitem__(s,
|
||||
old_surfaces.available[s]) %}
|
||||
{% else %}
|
||||
{% set dummy = surfaces.available.__setitem__(s, {'offset' : 0.0}) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if old_surfaces.active in surfaces.available %}
|
||||
{% set dummy = surfaces.__setitem__('active', old_surfaces.active) %}
|
||||
{% elif km.bed_surfaces %}
|
||||
{% set dummy = surfaces.__setitem__('active', km.bed_surfaces[0]|lower) %}
|
||||
{% endif %}
|
||||
SAVE_VARIABLE VARIABLE=bed_surfaces VALUE="{surfaces}"
|
||||
_APPLY_BED_SURFACE_OFFSET
|
||||
{% if new_probe_z != surfaces.probe_z or
|
||||
new_endstop_z != surfaces.endstop_z %}
|
||||
{ action_respond_info(
|
||||
'Z probe offset or endstop position changed. Run ADJUST_SURFACE_OFFSETS '
|
||||
'to adjust the offset for all saved surfaces by the change differential, '
|
||||
'or run ADJUST_SURFACE_OFFSETS IGNORE=1 to hide this message without '
|
||||
'making changes.') }
|
||||
{% endif %}
|
||||
|
||||
[gcode_macro adjust_surface_offsets]
|
||||
description: Adjusts surface offsets to account for changes in the Z endstop position or probe Z offset.
|
||||
Usage: ADJUST_SURFACE_OFFSETS [IGNORE]
|
||||
gcode:
|
||||
{% set surfaces = printer.save_variables.variables.bed_surfaces %}
|
||||
{% set settings = printer.configfile.settings %}
|
||||
{% set new_probe_z = (settings.probe | default(settings.bltouch) |
|
||||
default(settings.smart_effector) | default({})
|
||||
).z_offset|default(0.0)|float %}
|
||||
{% set new_endstop_z = (settings.stepper_z | default({})).position_endstop |
|
||||
default(0.0)|float %}
|
||||
{% set diff = (surfaces.probe_z - new_probe_z +
|
||||
surfaces.endstop_z - new_endstop_z)|round(6) %}
|
||||
{% if not params.IGNORE|default(0)|int %}
|
||||
{% for s in surfaces.available %}
|
||||
{% set offset = (surfaces.available[s].offset - diff)|round(6) %}
|
||||
{% set dummy = surfaces.available.__setitem__(s, {'offset' : offset}) %}
|
||||
{% endfor %}
|
||||
{ action_respond_info("All bed surfaces now adjusted by %1.4f"|
|
||||
format(diff))}
|
||||
{% elif diff != 0 %}
|
||||
{ action_respond_info("Status cleared without adjustment") }
|
||||
{% endif %}
|
||||
{% set dummy = surfaces.__setitem__('endstop_z', new_endstop_z| round(6)) %}
|
||||
{% set dummy = surfaces.__setitem__('probe_z', new_probe_z|round(6)) %}
|
||||
SAVE_VARIABLE VARIABLE=bed_surfaces VALUE="{surfaces}"
|
||||
|
||||
[gcode_macro set_surface_offset]
|
||||
description: Sets the offset for a surface and moves the toolhead (if homed).
|
||||
Usage: SET_SURFACE_OFFSET [OFFSET=<offset>] [SURFACE=<surface>]
|
||||
gcode:
|
||||
{% set surfaces = printer.save_variables.variables.bed_surfaces %}
|
||||
{% set SURFACE = params.SURFACE|default(surfaces.active)|lower %}
|
||||
{% if SURFACE not in surfaces.available %}
|
||||
{ action_raise_error("Bed surface %s does not exist." | format(SURFACE)) }
|
||||
{% endif %}
|
||||
{% set active = surfaces.available[SURFACE] %}
|
||||
# If no offset is provided just print out the current offset.
|
||||
{% set OFFSET = params.OFFSET|default(active.offset)|float %}
|
||||
{% if OFFSET != active.offset %}
|
||||
{% set dummy = surfaces.available[SURFACE].__setitem__("offset", OFFSET) %}
|
||||
SAVE_VARIABLE VARIABLE=bed_surfaces VALUE="{surfaces}"
|
||||
{% if SURFACE == surfaces.active %}
|
||||
_km_set_gcode_offset_base Z="{OFFSET}" MOVE={
|
||||
1 if printer.toolhead.homed_axes == 'xyz' else 0}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{ action_respond_info("Bed surface: %s Offset: %.3f"
|
||||
| format(SURFACE, OFFSET)) }
|
||||
# Dummy argument block for Mainsail
|
||||
{% set dummy = None if True else "
|
||||
{% set dummy = params.SURFACE|default(active surface) %}
|
||||
{% set dummy = params.OFFSET|default(none)|float %}
|
||||
" %} # End argument block for Mainsail
|
||||
|
||||
[gcode_macro set_surface_active]
|
||||
description: Sets the active bed surface and moves the toolhead (if homed). If no SURFACE argument is present the available surfaces are listed and the active one is preceded by a "*".
|
||||
Usage: SET_SURFACE_ACTIVE [SURFACE=<surface>]
|
||||
gcode:
|
||||
{% set surfaces = printer.save_variables.variables.bed_surfaces %}
|
||||
{% if "SURFACE" in params %}
|
||||
{% set SURFACE = params.SURFACE|lower %}
|
||||
{% if SURFACE not in surfaces.available %}
|
||||
{ action_raise_error("Bed surface %s does not exist." | format(SURFACE)) }
|
||||
{% endif %}
|
||||
{% if SURFACE != surfaces.active %}
|
||||
{% set dummy = surfaces.__setitem__("active", SURFACE) %}
|
||||
SAVE_VARIABLE VARIABLE=bed_surfaces VALUE="{surfaces}"
|
||||
{% endif %}
|
||||
{% if surfaces.available[SURFACE].offset !=
|
||||
printer.gcode_move.homing_origin.z %}
|
||||
_km_set_gcode_offset_base Z="{surfaces.available[SURFACE].offset
|
||||
}" MOVE={1 if printer.toolhead.homed_axes == 'xyz' else 0}
|
||||
{% endif %}
|
||||
{action_respond_info("Active bed surface: %s; offset: %.3f"
|
||||
| format(SURFACE, surfaces.available[SURFACE].offset))}
|
||||
{% else %}
|
||||
{% set output = [] %}
|
||||
{% for s in surfaces.available|list|sort %}
|
||||
{% set dummy = output.append("%s %s - offset: %.3f"
|
||||
| format("*" if s == surfaces.active else " ",
|
||||
s, surfaces.available[s].offset)) %}
|
||||
{% endfor %}
|
||||
{action_respond_info(output|join('\n'))}
|
||||
{% endif %}
|
||||
# Dummy argument block for Mainsail
|
||||
{% set dummy = None if True else "
|
||||
{% set dummy = params.SURFACE|default(none) %}
|
||||
" %} # End argument block for Mainsail
|
||||
|
||||
[gcode_macro set_gcode_offset]
|
||||
description: Wraps SET_GCODE_OFFSET to update the current bed sheet offset.
|
||||
Usage: SET_GCODE_OFFSET [X=<pos>|X_ADJUST=<adjust>]
|
||||
[Y=<pos>|Y_ADJUST=<adjust>]
|
||||
[Z=<pos>|Z_ADJUST=<adjust>]
|
||||
[MOVE=1 [MOVE_SPEED=<speed>]]
|
||||
rename_existing: _KM_SET_GCODE_OFFSET_BASE
|
||||
gcode:
|
||||
{% set surfaces = printer.save_variables.variables.bed_surfaces %}
|
||||
{% if surfaces.active and
|
||||
not printer["gcode_macro _km_save_state"].is_ephemeral %}
|
||||
{% set Z = params.Z|default(0.0)|float|round(6) %}
|
||||
{% set Z_ADJUST = params.Z_ADJUST|default(0.0)|float %}
|
||||
{% if 'Z' in params and
|
||||
Z != surfaces.available[surfaces.active].offset %}
|
||||
{% set dummy = surfaces.available[surfaces.active].__setitem__("offset",
|
||||
Z) %}
|
||||
SAVE_VARIABLE VARIABLE=bed_surfaces VALUE="{surfaces}"
|
||||
{% elif Z_ADJUST != 0.0 %}
|
||||
{% set dummy = surfaces.available[surfaces.active].__setitem__(
|
||||
"offset", (Z_ADJUST + printer.gcode_move.homing_origin.z)|round(6)) %}
|
||||
SAVE_VARIABLE VARIABLE=bed_surfaces VALUE="{surfaces}"
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
_km_set_gcode_offset_base{% for k in params%}{' '~k~'="'~params[k]~'"'
|
||||
}{% endfor %}
|
||||
@@ -0,0 +1,22 @@
|
||||
# Copyright (C) 2022 Justin Schuh <code@justinschuh.com>
|
||||
#
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
[gcode_macro m300]
|
||||
description: Emits and audible beep.
|
||||
Usage: M300 [P<duration>] [S<frequency>]
|
||||
gcode:
|
||||
{% set km = printer["gcode_macro _km_globals"] %}
|
||||
{% set settings = printer.configfile.settings %}
|
||||
{% if "output_pin beeper" in printer %}
|
||||
{% set P = (params.P|default(km.beep_duration)|int, 0)|max %}
|
||||
{% set S = (params.S|default(km.beep_frequency)|int, 1)|max %}
|
||||
SET_PIN PIN=beeper VALUE={
|
||||
settings["output_pin beeper"].scale|default(1.0) * 0.5
|
||||
}{% if settings["output_pin beeper"].pwm %} CYCLE_TIME={
|
||||
1.0 / S }{% endif %}
|
||||
G4 P{P}
|
||||
SET_PIN PIN=beeper VALUE=0
|
||||
{% else %}
|
||||
{action_respond_info(
|
||||
"M300 is disabled. To enable create an [output_pin beeper] config.")}
|
||||
{% endif %}
|
||||
117
klipper/DNV-TPU-Ender3/klipper_config/klipper-macros/draw.cfg
Normal file
117
klipper/DNV-TPU-Ender3/klipper_config/klipper-macros/draw.cfg
Normal file
@@ -0,0 +1,117 @@
|
||||
# Copyright (C) 2022 Justin Schuh <code@justinschuh.com>
|
||||
#
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
|
||||
[gcode_macro set_draw_params]
|
||||
description: Sets the default parameters used by DRAW_LINE_TO.
|
||||
Usage: SET_DRAW_PARAMS [HEIGHT=<mm>] [WIDTH=<mm>] [FEEDRATE=<mm/m>]
|
||||
variable_height: 0.2
|
||||
variable_width: 0.0 # Set to nozzle_diameter at startup
|
||||
variable_feedrate: 1200
|
||||
gcode:
|
||||
{% set dparams = printer["gcode_macro set_draw_params"] %}
|
||||
{% for k in params %}
|
||||
{% set kl = k|lower %}
|
||||
{% if kl in dparams %}
|
||||
{% if dparams[kl] is float %}
|
||||
{% set v = params[k]|float %}
|
||||
{% elif dparams[kl] is integer %}
|
||||
{% set v = params[k]|int %}
|
||||
{% endif %}
|
||||
SET_GCODE_VARIABLE MACRO=set_draw_params VARIABLE={kl} VALUE="{v}"
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
[gcode_macro draw_line_to]
|
||||
description: Extrudes a line of filament at the specified height and width from the current coordinate to the supplied XY coordinate. (The height is used only to calculate the extrusion volume.)
|
||||
Usage: DRAW_LINE_TO [X=<pos>] [Y=<pos>] [HEIGHT=<mm>] [WIDTH=<mm>]
|
||||
[FEEDRATE=<mm/m>]
|
||||
gcode:
|
||||
{% set dparams = printer["gcode_macro set_draw_params"] %}
|
||||
{% set position = printer.gcode_move.position %}
|
||||
{% set X = params.X|default(position.x)|float %}
|
||||
{% set Y = params.Y|default(position.y)|float %}
|
||||
{% set HEIGHT = params.HEIGHT|default(dparams.height)|float %}
|
||||
{% set WIDTH = params.WIDTH|default(dparams.width)|float %}
|
||||
{% set FEEDRATE = params.FEEDRATE|default(dparams.feedrate)|int %}
|
||||
|
||||
{% set distance = ((X - position.x) ** 2 + (Y - position.y) ** 2) ** 0.5 %}
|
||||
|
||||
{% set filament_area = 3.14159 *
|
||||
(printer.configfile.settings[
|
||||
printer.toolhead.extruder].filament_diameter ** 2) / 4 %}
|
||||
{% set E = distance * ((WIDTH * HEIGHT) / filament_area) %}
|
||||
|
||||
# Use the base state call here so offset adjustments get persisted.
|
||||
_KM_SAVE_GCODE_STATE NAME=_KM_PURGE
|
||||
G90
|
||||
G92 E0.0
|
||||
G1 X{"%.3f" % X} Y{"%.3f" % Y} E{"%.5f" % E} F{FEEDRATE}
|
||||
_KM_RESTORE_GCODE_STATE NAME=_KM_PURGE MOVE=0
|
||||
|
||||
[gcode_macro draw_purge_line]
|
||||
description: Purges the specified length of filament as a line (or rows of lines) in front of the supplied print area. If no print area is specified the purge lines are drawn at the front edge of the maximum printable area. If no printable area is set it defaults to the XY axis limits.
|
||||
Usage: DRAW_PURGE_LINE [PRINT_MIN=<X,Y>] [PRINT_MAX=<X,Y>] [HEIGHT=<mm>]
|
||||
[WIDTH=<mm>] [LENGTH=<mm>]
|
||||
gcode:
|
||||
# TODO: Make this work for delta printers.
|
||||
{% set km = printer["gcode_macro _km_globals"] %}
|
||||
{% if "PRINT_MIN" in params %}
|
||||
{% set PRINT_MIN = (
|
||||
(params.PRINT_MIN.split(",")[0]|float, km.print_min[0])|max,
|
||||
(params.PRINT_MIN.split(",")[1]|float, km.print_min[1])|max
|
||||
) %}
|
||||
{% else %}
|
||||
{% set PRINT_MIN = km.print_min %}
|
||||
{% endif %}
|
||||
{% if "PRINT_MAX" in params %}
|
||||
{% set PRINT_MAX = (
|
||||
(params.PRINT_MAX.split(",")[0]|float, km.print_max[0])|min,
|
||||
(params.PRINT_MAX.split(",")[1]|float, km.print_max[1])|min
|
||||
) %}
|
||||
{% else %}
|
||||
{% set PRINT_MAX = km.print_max %}
|
||||
{% endif %}
|
||||
{% set extruder = printer.toolhead.extruder|string %}
|
||||
{% set HEIGHT = params.HEIGHT|default(
|
||||
printer.configfile.settings[extruder].nozzle_diameter * 0.625)|float %}
|
||||
{% set WIDTH = params.WIDTH|default(
|
||||
printer.configfile.settings[extruder].nozzle_diameter * 1.25)|float %}
|
||||
{% set LENGTH = params.LENGTH|default(km.start_purge_length)|float %}
|
||||
|
||||
{% set dparams = printer["gcode_macro set_draw_params"] %}
|
||||
{% set filament_area = 3.14159 *
|
||||
(printer.configfile.settings[extruder].filament_diameter ** 2) / 4 %}
|
||||
{% set purge_length = (LENGTH * filament_area) / (WIDTH * HEIGHT) %}
|
||||
{% set printable_length = PRINT_MAX[0] - PRINT_MIN[0] %}
|
||||
{% set purge_rows = (purge_length / printable_length)|round(0,'ceil')|int %}
|
||||
{% set printable_inset = (printable_length - purge_length / purge_rows) / 2 %}
|
||||
{% set PRINT_MIN = (PRINT_MIN[0] + printable_inset, PRINT_MIN[1]) %}
|
||||
{% set PRINT_MAX = (PRINT_MAX[0] - printable_inset, PRINT_MAX[1]) %}
|
||||
# This will purge into the print area when the bed is filled to the front.
|
||||
{% set y_start = (km.print_min[1], PRINT_MIN[1] - km.start_purge_clearance -
|
||||
(purge_rows + 0.5) * WIDTH )|max %}
|
||||
G90
|
||||
# Jog to the front left corner to get strings out of the print area.
|
||||
G1 X{"%.3f" % (PRINT_MIN[0] - 30, km.print_min[0])|max} Y{
|
||||
"%.3f" % (y_start - 10, km.print_min[1])|max} F{km.travel_speed_xy}
|
||||
# Move to the starting corner.
|
||||
G1 X{"%.3f" % (PRINT_MIN[0] - 2, km.print_min[0])|max} Y{"%.3f" % y_start} Z{
|
||||
"%.4f" % HEIGHT} F{km.travel_speed_xy}
|
||||
# Prime the extruder before beginning the purge lines.
|
||||
G92 E0.0
|
||||
G1 E{"%.3f" % km.start_purge_prime_length} F{km.load_priming_speed}
|
||||
G92 E0.0
|
||||
# Purge.
|
||||
G1 X{"%.3f" % PRINT_MIN[0]} F{km.travel_speed_xy}
|
||||
{% for n in range(purge_rows - 1) %}
|
||||
{% set x_pos = PRINT_MIN[0] if n % 2 else PRINT_MAX[0] %}
|
||||
DRAW_LINE_TO HEIGHT="{HEIGHT}" WIDTH="{WIDTH}" X="{x_pos}" Y="{
|
||||
WIDTH * n + y_start}"
|
||||
DRAW_LINE_TO HEIGHT="{HEIGHT}" WIDTH="{WIDTH}" X="{x_pos}" Y="{
|
||||
WIDTH * (n + 1) + y_start}"
|
||||
{% endfor %}
|
||||
{% set x_pos = PRINT_MAX[0] if purge_rows % 2 else PRINT_MIN[0] %}
|
||||
DRAW_LINE_TO HEIGHT="{HEIGHT}" WIDTH="{WIDTH}" X="{x_pos}" Y="{
|
||||
WIDTH * (purge_rows - 1) + y_start}"
|
||||
G92 E0.0
|
||||
@@ -0,0 +1,90 @@
|
||||
# Copyright (C) 2022 Justin Schuh <code@justinschuh.com>
|
||||
#
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
|
||||
# Sets optional scaling factor, minimum, and maximum applied to M106 commmand.
|
||||
# If a MINIMUM greater than 0 is specified the fan will not stop unless an
|
||||
# M107 command is issued. SET_FAN_SCALING always displays the current paramaters
|
||||
# if scaling is active. SET_FAN_SCALING without any arguments will display the
|
||||
# current scaling parameters without changing them.
|
||||
|
||||
[gcode_macro _check_fan_params]
|
||||
gcode:
|
||||
{% set MAXIMUM = params.MAXIMUM|default(
|
||||
printer["gcode_macro set_fan_scaling"].maximum)|int %}
|
||||
{% set MINIMUM = params.MINIMUM|default(
|
||||
printer["gcode_macro set_fan_scaling"].minimum)|int %}
|
||||
|
||||
{% if params.SCALE and params.SCALE|float <= 0 %}
|
||||
{ action_raise_error("SCALE must be a positive value.") }
|
||||
{% elif MINIMUM < 0 or MINIMUM > 255 %}
|
||||
{ action_raise_error("MINIMUM must be between 0 and 255.") }
|
||||
{% elif MAXIMUM < 0 or MAXIMUM > 255 %}
|
||||
{ action_raise_error("MAXIMUM must be between 0 and 255.") }
|
||||
{% elif params.SPEED and (params.SPEED|int < 0 or params.SPEED|int > 255) %}
|
||||
{ action_raise_error("SPEED must be between 0 and 255.") }
|
||||
{% elif params.BOOST and (params.BOOST|int < 0 or params.BOOST|int > 255) %}
|
||||
{ action_raise_error("BOOST must be between 0 and 255.") }
|
||||
{% elif MINIMUM > MAXIMUM %}
|
||||
{ action_raise_error("MINIMUM must be less than or equal to MAXIMUM.") }
|
||||
{% endif %}
|
||||
|
||||
[gcode_macro set_fan_scaling]
|
||||
description: Sets fan scaling factors applied to M106 command. If a speed is provided it will be adjusted according to the scaling parameters.
|
||||
Usage: SET_FAN_SCALING [SCALE=<scale>] [BOOST=<boost>] [MAXIMUM=<max>]
|
||||
[MINIMUM=<min>] [SPEED=<speed>]
|
||||
variable_scale: 1.0
|
||||
variable_boost: 0
|
||||
variable_minimum: 0
|
||||
variable_maximum: 255
|
||||
variable_real_speed: 0
|
||||
gcode:
|
||||
_CHECK_FAN_PARAMS{% for k in params %}{' '~k~'='~params[k]}{% endfor %}
|
||||
{% set SCALE = params.SCALE|default(scale)|float %}
|
||||
{% set BOOST = params.BOOST|default(boost)|float %}
|
||||
{% set MAXIMUM = params.MAXIMUM|default(maximum)|int %}
|
||||
{% set MINIMUM = params.MINIMUM|default(minimum)|int %}
|
||||
{% set SPEED = params.SPEED|default(real_speed)|int %}
|
||||
|
||||
{% if SCALE != 1.0 or BOOST != 0 or MAXIMUM != 255 or MINIMUM != 0 %}
|
||||
{action_respond_info("Fan: Scale: %.2f Minimum:%i Maximum: %i Speed: %i"|
|
||||
format(SCALE, MINIMUM, MAXIMUM, SPEED))}
|
||||
{% endif %}
|
||||
|
||||
# Update parameters on change.
|
||||
{% if params|length > 0 %}
|
||||
SET_GCODE_VARIABLE MACRO=set_fan_scaling VARIABLE=scale VALUE="{SCALE}"
|
||||
SET_GCODE_VARIABLE MACRO=set_fan_scaling VARIABLE=boost VALUE="{BOOST}"
|
||||
SET_GCODE_VARIABLE MACRO=set_fan_scaling VARIABLE=minimum VALUE="{MINIMUM}"
|
||||
SET_GCODE_VARIABLE MACRO=set_fan_scaling VARIABLE=maximum VALUE="{MAXIMUM}"
|
||||
# Run fan at adusted speed
|
||||
M106 S{SPEED}
|
||||
{% endif %}
|
||||
# Dummy argument block for Mainsail
|
||||
{% set dummy = None if True else "
|
||||
{% set dummy = params.SCALE|default(1.0)|float %}
|
||||
{% set dummy = params.BUMP|default(0)|int %}
|
||||
{% set dummy = params.MAXIMUM|default(255)|int %}
|
||||
{% set dummy = params.MINIMUM|default(0)|int %}
|
||||
{% set dummy = params.SPEED|default(current speed)|int %}
|
||||
" %} # End argument block for Mainsail
|
||||
|
||||
[gcode_macro reset_fan_scaling]
|
||||
description: Clears all fan scaling factors.
|
||||
Usage: RESET_FAN_SCALING
|
||||
gcode:
|
||||
SET_FAN_SCALING SCALE=1.0 BOOST=0 MAXIMUM=255 MINIMUM=0
|
||||
|
||||
[gcode_macro m106]
|
||||
description: Wraps M106 to implement scaling overrides.
|
||||
rename_existing: M106.6245197
|
||||
gcode:
|
||||
{% set S = params.S|default(255)|int %}
|
||||
{% if S > 255 or S < 0 %}
|
||||
{ action_raise_error("S[%i] out of range.") | format(S) }
|
||||
{% endif %}
|
||||
|
||||
{% set scale = printer["gcode_macro set_fan_scaling"] %}
|
||||
SET_GCODE_VARIABLE MACRO=set_fan_scaling VARIABLE=real_speed VALUE="{S}"
|
||||
M106.6245197 S{((((S + scale.boost) * scale.scale) | round | int,
|
||||
scale.minimum) | max, scale.maximum) | min}
|
||||
Reference in New Issue
Block a user