Skip to content

Commit

Permalink
feat: Dynamic start print actions
Browse files Browse the repository at this point in the history
Revamp the current logic to hook into the START_PRINT macro and
implement the same dynamic approach as END_PRINT for Gcode macros
starting with `_START_PRINT_ACTION`, again verifying existence
before calling the macro.
  • Loading branch information
mjonuschat committed Dec 20, 2024
1 parent 053297a commit 32b6b7b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion macros/base/start_print.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ gcode:

# Here is the core of the START_PRINT were we get the startprint_actions variable
# to do the procedure in the correct order for the configured probe (or user custom override)
#
# Custom actions can be called by defining a gcode macro as in the following example and
# adding `custom1` to the startprint_actions override config.
# [gcode_macro _START_PRINT_ACTION_CUSTOM1]
# gcode:
# ## Your custom code here
#
{% set sp_actions = printer["gcode_macro _USER_VARIABLES"].startprint_actions %}
{% for action in sp_actions %}
{% if action == "bed_soak" %}
Expand Down Expand Up @@ -169,7 +176,11 @@ gcode:
{% elif action == "custom3" %}
_MODULE_CUSTOM3 {rawparams}
{% else %}
{ action_raise_error("Unknown module called in START_PRINT! Please verify your startprint_actions variable override!") }
{% if "_START_PRINT_ACTION_%s" % (action|upper) in printer.gcode.commands %}
_START_PRINT_ACTION_{action|upper} {rawparams}
{% else %}
{ action_raise_error("Unknown module %s called in START_PRINT! Please verify your startprint_actions variable override!" % (action)) }
{% endif %}
{% endif %}
{% endfor %}

Expand Down

0 comments on commit 32b6b7b

Please sign in to comment.