aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Zellner <37265689+zellneralex@users.noreply.github.com>2021-05-26 20:21:21 +0200
committerGitHub <noreply@github.com>2021-05-26 14:21:21 -0400
commit341fc64a670e96f5be5e63abe41cc51cb90ed898 (patch)
tree5211a4d841c66510321f7c0f9c32588036694078
parentba3bbca8618e3ba2cea961c72474d5a89974b23d (diff)
downloadkutter-341fc64a670e96f5be5e63abe41cc51cb90ed898.tar.gz
kutter-341fc64a670e96f5be5e63abe41cc51cb90ed898.tar.xz
kutter-341fc64a670e96f5be5e63abe41cc51cb90ed898.zip
gcode_macro: add description property (#4317)
Signed-off-by: Alex Zellner <alexander.zellner@googlemail.com>
-rw-r--r--docs/Command_Templates.md19
-rw-r--r--docs/Config_Reference.md3
-rw-r--r--klippy/extras/gcode_macro.py2
3 files changed, 23 insertions, 1 deletions
diff --git a/docs/Command_Templates.md b/docs/Command_Templates.md
index a5e3d323..f27f4a65 100644
--- a/docs/Command_Templates.md
+++ b/docs/Command_Templates.md
@@ -27,6 +27,25 @@ Note how the `gcode:` config option always starts at the beginning of
the line and subsequent lines in the G-Code macro never start at the
beginning.
+### Add a description to your macro
+
+To help identify the functionality a short description can be added.
+Add `description:` with a short text to describe the functionality.
+Default is "G-Code macro" if not specified.
+For example:
+
+```
+[gcode_macro blink_led]
+description: Blink my_led one time
+gcode:
+ SET_PIN PIN=my_led VALUE=1
+ G4 P2000
+ SET_PIN PIN=my_led VALUE=0
+```
+
+This will be showing is you use the `HELP` command or use the autocomplete
+function.
+
### Save/Restore state for G-Code moves
Unfortunately, the G-Code command language can be challenging to use.
diff --git a/docs/Config_Reference.md b/docs/Config_Reference.md
index e2930f1b..f09b90a9 100644
--- a/docs/Config_Reference.md
+++ b/docs/Config_Reference.md
@@ -1237,6 +1237,9 @@ G-Code macros (one may define any number of sections with a
# commands. Care should be taken when overriding commands as it can
# cause complex and unexpected results. The default is to not
# override an existing G-Code command.
+#description: G-Code macro
+# This will add a short description used at the HELP command or while
+# using the auto completion feature. Default "G-Code macro"
```
## [delayed_gcode]
diff --git a/klippy/extras/gcode_macro.py b/klippy/extras/gcode_macro.py
index 3c3f51ac..444614e6 100644
--- a/klippy/extras/gcode_macro.py
+++ b/klippy/extras/gcode_macro.py
@@ -124,6 +124,7 @@ class GCodeMacro:
self.template = gcode_macro.load_template(config, 'gcode')
self.gcode = printer.lookup_object('gcode')
self.rename_existing = config.get("rename_existing", None)
+ self.cmd_desc = config.get("description", "G-Code macro")
if self.rename_existing is not None:
if (self.gcode.is_traditional_gcode(self.alias)
!= self.gcode.is_traditional_gcode(self.rename_existing)):
@@ -177,7 +178,6 @@ class GCodeMacro:
except ValueError as e:
raise gcmd.error("Unable to parse '%s' as a literal" % (value,))
self.variables[variable] = literal
- cmd_desc = "G-Code macro"
def cmd(self, gcmd):
if self.in_script:
raise gcmd.error("Macro %s called recursively" % (self.alias,))