Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
3DCoded authored Jul 23, 2024
1 parent 47fc2c4 commit 4575aeb
Showing 1 changed file with 12 additions and 42 deletions.
54 changes: 12 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,31 @@

---

Klipper Dynamic Macros is an unofficial way to update macros without restarting Klipper, so you can update macros mid-print and see their results live.
Klipper Dynamic Macros is an unofficial way to update macros without restarting Klipper, so you can update macros mid-print and see their results live. It also supports extra features that normal GCode Macros don't have.

## Documentation

Read the documentation [here](https://3dcoded.github.io/DynamicMacros)

[![Built with Material for MkDocs](https://img.shields.io/badge/Material_for_MkDocs-526CFE?style=for-the-badge&logo=MaterialForMkDocs&logoColor=white)](https://squidfunk.github.io/mkdocs-material/)

## How Normal Macros Work

Your macros are written in a `.cfg` file, then included into your `printer.cfg`. When Klipper restarts, it parses these files and saves the macros internally (you can't change them without restarting Klipper). When a macro is called, the cached code is interpreted and run. This method is faster, as the macros don't have to be reread every time.

## How Dynamic Macros Work

Your macros are written in a `.cfg` file, then the relative path to that file is configured in a `[dynamicmacros]` config section. The config files are read and parsed every time you run the macro. This method is slightly slower, as the macros have to be reread every time.

## Additional Features

Dynamic Macros also supports additional features over normal GCode macros:

- Recursion
- Receiving variable updates within one macro
- In development: Retrieving all variables from another macro

## Variables

Dynamic Macros support all features of normal `gcode_macros`, EXCEPT variables. Here's a simple example of which kind of variables work and won't work with Dynamic Macros.

**Works:**

```cfg
[gcode_macro test]
gcode:
{% set number = params.NUMBER|int %}
M117 Number: {number}
```
## Features

**Doesn't Work:**
```cfg
[gcode_macro test]
variable_number: 10
gcode:
M117 Number: {printer["gcode_macro test"].number}
```
- [Recursion]([recursion.md](https://3dcoded.github.io/DynamicMacros/features/recursion)
- [Receiving Variables](https://3dcoded.github.io/DynamicMacros/features/receivingvariables)
- [Utility Functions](https://3dcoded.github.io/DynamicMacros/features/utilities)
- [Variables](https://3dcoded.github.io/DynamicMacros/features/variables)

Dynamic Macros can still read macro variables from normal `gcode_macros`, but they can't store variables themselves.
## How Normal Macros Work

## Should a Macro be Dynamic?
Your macros are written in a `.cfg` file, then included into your `printer.cfg`. When Klipper restarts, it parses these files and saves the macros internally (you can't change them without restarting Klipper). When a macro is called, the cached code is interpreted and run.

Not all macros will benefit from being dynamic. Here's a few questions you can ask about the macro to see if it should be dynamic:
## How Dynamic Macros Work

- Is it a macro that is unstable/may break?
- Is it a macro that may need to be edited several times?
Your macros are written in a `.cfg` file, then the relative path to that file is configured in a `[dynamicmacros]` config section. The config files are read and parsed every time you run the macro, allowing you to update macros without restarting Klipper.

If your answer to either of those was yes, then your macro will likely benefit from being dynamic. Follow the [Tutorial](https://3dcoded.github.io/DynamicMacros/tutorial) to get started with Dynamic Macros.
## Get Started
Follow the [Tutorial](https://3dcoded.github.io/DynamicMacros/tutorial) to get started with Dynamic Macros.

## Features

Expand Down

0 comments on commit 4575aeb

Please sign in to comment.