aboutsummaryrefslogtreecommitdiffstats
path: root/docs/Command_Templates.md
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2020-12-03 12:05:46 -0500
committerKevin O'Connor <kevin@koconnor.net>2020-12-03 12:19:47 -0500
commitd7053f6e718e0a51b48054b90e38a1b0a698ca52 (patch)
treefeed961b91a80beff2a22a3063cbf63e19a1944a /docs/Command_Templates.md
parent91de1560a727264e6955f7581a5864bdb9c1653e (diff)
downloadkutter-d7053f6e718e0a51b48054b90e38a1b0a698ca52.tar.gz
kutter-d7053f6e718e0a51b48054b90e38a1b0a698ca52.tar.xz
kutter-d7053f6e718e0a51b48054b90e38a1b0a698ca52.zip
save_variables: Support saving variables to a disk file
Signed-off-by: Dushyant Ahuja dusht.ahuja@gmail.com Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'docs/Command_Templates.md')
-rw-r--r--docs/Command_Templates.md35
1 files changed, 35 insertions, 0 deletions
diff --git a/docs/Command_Templates.md b/docs/Command_Templates.md
index 47f7755e..26271b75 100644
--- a/docs/Command_Templates.md
+++ b/docs/Command_Templates.md
@@ -396,3 +396,38 @@ gcode:
```
UPDATE_DELAYED_GCODE ID=report_temp DURATION=0
```
+
+### Save Variables to disk
+
+If a
+[save_variables config section](Config_Reference.md#save_variables)
+has been enabled, `SAVE_VARIABLE VARIABLE=<name> VALUE=<value>` can be
+used to save the variable to disk so that it can be used across
+restarts. All stored variables are loaded into the
+`printer.save_variables.variables` dict at startup and can be used in
+gcode macros. to avoid overly long lines you can add the following at
+the top of the macro:
+```
+{% set svv = printer.save_variables.variables %}
+```
+
+As an example, it could be used to save the state of 2-in-1-out hotend
+and when starting a print ensure that the active extruder is used,
+instead of T0:
+
+```
+[gcode_macro T1]
+gcode:
+ ACTIVATE_EXTRUDER extruder=extruder1
+ SAVE_VARIABLE VARIABLE=currentextruder VALUE='"extruder1"'
+
+[gcode_macro T0]
+gcode:
+ ACTIVATE_EXTRUDER extruder=extruder
+ SAVE_VARIABLE VARIABLE=currentextruder VALUE='"extruder"'
+
+[gcode_macro START_GCODE]
+gcode:
+ {% set svv = printer.save_variables.variables %}
+ ACTIVATE_EXTRUDER extruder={svv.currentextruder}
+```