Bluey-Firmware/macros.cfg

177 lines
6.1 KiB
INI
Raw Normal View History

# This file provides examples of Klipper G-Code macros. The snippets
# in this file may be copied into the main printer.cfg file and
# customized.
# See docs/Config_Reference.md for a description of parameters.
######################################################################
# Start Print and End Print
######################################################################
# Replace the slicer's custom start and end g-code scripts with
# START_PRINT and END_PRINT. See docs/Slicers.md for more information on using these macros.
[gcode_macro START_PRINT]
gcode:
{% set BED_TEMP = params.BED_TEMP|default(60)|float %}
{% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(190)|float %}
# Start bed heating
M140 S{BED_TEMP}
# Use absolute coordinates
G90
# Reset the G-Code Z offset (adjust Z offset if needed)
SET_GCODE_OFFSET Z=0.0
# Home the printer
G28
# Move the nozzle near the bed
SMART_PARK
# Wait for bed to reach temperature
M190 S{BED_TEMP}
# KAMP bed mesh calibration
BED_MESH_CALIBRATE
# KAMP Smart Park
SMART_PARK
# Set and wait for nozzle to reach temperature
M109 S{EXTRUDER_TEMP}
# KAMP adaptive purge
VORON_PURGE
[gcode_macro END_PRINT]
gcode:
# Turn off bed, extruder, and fan
M140 S0
M104 S0
M106 S0
# Move nozzle away from print while retracting
G91
G1 X-2 Y-2 E-3 F300
# Raise nozzle by 10mm
G1 Z10 F3000
G90
# Disable steppers
M84
######################################################################
# Override M117 command with rawparams
######################################################################
# The macro below will override the default M117 command to echo the message.
#
# It uses the rawparams pseudo-variable that contains the full unparsed
# parameters that was passed to the M117 command.
#
# As this can include comments, we are trimming the text when a `;` or `#` is
# found, and escaping any existing `"`
[gcode_macro M117]
rename_existing: M117.1
gcode:
{% if rawparams %}
{% set escaped_msg = rawparams.split(';', 1)[0].split('\x23', 1)[0]|replace('"', '\\"') %}
SET_DISPLAY_TEXT MSG="{escaped_msg}"
RESPOND TYPE=command MSG="{escaped_msg}"
{% else %}
SET_DISPLAY_TEXT
{% endif %}
# Cancel object (aka Marlin/RRF M486 commands) support
#
# Enable object exclusion
[exclude_object]
[gcode_macro M486]
gcode:
# Parameters known to M486 are as follows:
# [C<flag>] Cancel the current object
# [P<index>] Cancel the object with the given index
# [S<index>] Set the index of the current object.
# If the object with the given index has been canceled, this will cause
# the firmware to skip to the next object. The value -1 is used to
# indicate something that isnt an object and shouldnt be skipped.
# [T<count>] Reset the state and set the number of objects
# [U<index>] Un-cancel the object with the given index. This command will be
# ignored if the object has already been skipped
{% if 'exclude_object' not in printer %}
{action_raise_error("[exclude_object] is not enabled")}
{% endif %}
{% if 'T' in params %}
EXCLUDE_OBJECT RESET=1
{% for i in range(params.T | int) %}
EXCLUDE_OBJECT_DEFINE NAME={i}
{% endfor %}
{% endif %}
{% if 'C' in params %}
EXCLUDE_OBJECT CURRENT=1
{% endif %}
{% if 'P' in params %}
EXCLUDE_OBJECT NAME={params.P}
{% endif %}
{% if 'S' in params %}
{% if params.S == '-1' %}
{% if printer.exclude_object.current_object %}
EXCLUDE_OBJECT_END NAME={printer.exclude_object.current_object}
{% endif %}
{% else %}
EXCLUDE_OBJECT_START NAME={params.S}
{% endif %}
{% endif %}
{% if 'U' in params %}
EXCLUDE_OBJECT RESET=1 NAME={params.U}
{% endif %}
######################################################################
# G130: Set digital potentiometer value
######################################################################
# The macro below uses the MCP4018 SET_DIGIPOT command to implement
# a `G130` as used on classic Mightyboard-based printers such as
# The Makerbot Replicator 2/2X.
#
# The `G130` command can be used to lower the stepper current
# during preheating and raise the current again prior to starting
# the print. This is necessary for printers with smaller power
# supplies that needed all the power to heat the bed.
#
# This macro requires one or more [mcp4018] configuration sections:
# (x_axis_pot, y_axis_pot, z_axis_pot, a_axis_pot, b_axis_pot)
#
# Example: G130 X20 Y20 Z20 A20 B20 ; Lower stepper Vrefs while heating
[gcode_macro G130]
gcode:
M400
{% if ('X' in params) and ('mcp4018 x_axis_pot' in printer.configfile.config) %}
{% set x_value = params['X']|float %}
{% set x_axis_pot_scale = printer.configfile.config["mcp4018 x_axis_pot"].scale|float %}
SET_DIGIPOT DIGIPOT=x_axis_pot WIPER={ x_axis_pot_scale * (x_value / 127.0)}
{% endif %}
{% if ('Y' in params) and ('mcp4018 y_axis_pot' in printer.configfile.config) %}
{% set y_value = params['Y']|float %}
{% set y_axis_pot_scale = printer.configfile.config["mcp4018 y_axis_pot"].scale|float %}
SET_DIGIPOT DIGIPOT=y_axis_pot WIPER={ y_axis_pot_scale * (y_value / 127.0)}
{% endif %}
{% if ('Z' in params) and ('mcp4018 z_axis_pot' in printer.configfile.config) %}
{% set z_value = params['Z']|float %}
{% set z_axis_pot_scale = printer.configfile.config["mcp4018 z_axis_pot"].scale|float %}
SET_DIGIPOT DIGIPOT=z_axis_pot WIPER={ z_axis_pot_scale * (z_value / 127.0)}
{% endif %}
{% if ('A' in params) and ('mcp4018 a_axis_pot' in printer.configfile.config) %}
{% set a_value = params['A']|float %}
{% set a_axis_pot_scale = printer.configfile.config["mcp4018 a_axis_pot"].scale|float %}
SET_DIGIPOT DIGIPOT=a_axis_pot WIPER={ a_axis_pot_scale * (a_value / 127.0)}
{% endif %}
{% if ('B' in params) and ('mcp4018 b_axis_pot' in printer.configfile.config) %}
{% set b_value = params['B']|float %}
{% set b_axis_pot_scale = printer.configfile.config["mcp4018 b_axis_pot"].scale|float %}
SET_DIGIPOT DIGIPOT=b_axis_pot WIPER={ b_axis_pot_scale * (b_value / 127.0)}
{% endif %}