Using Dynamic Macros Features
Now that your macros are dynamic, you can use the powerful feature set of Dynamic Macros.
Recursion
Recursion allows a macro to call itself, something standard GCode macros can't do.
When using recursion, it's important to make sure your macro has an "end case". This is a case when the macro won't call itself again. Otherwise the macro will be stuck in an infinite loop and freeze Klipper.
Here are a few examples of recursion:
Counting to 10 | |
---|---|
Receiving Variable Updates
Receiving variable updates allows Dynamic Macros to update variables without rerunning the macro.
An example of this is getting the printer's position. A standard GCode macro will evaluate all the variables, then run the GCode. However, using three newlines (two blank lines) between code segments in Dynamic Macros will allow each segment to be evaluated at runtime, allowing for variable updates.
Utility Functions
See the link above (the subtitle) for more information on utility functions.
Python
Dynamic Macro's most powerful feature allows you to run Python code from within a macro. See the link above (the subtitle) for more information.
delayed_gcode
Dynamic Macros supports a feature similar to delayed_gcode
. See the link above (the subtitle) for more information.