forked from jschuh/klipper-macros
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
state: Ignore ephemeral SET_GCODE_OFFSET calls
Tracks SAVE_GCODE_STATE and RESTORE_GCODE_STATE (issue jschuh#13 follow up).
- Loading branch information
Showing
2 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright (C) 2022 Justin Schuh <[email protected]> | ||
# | ||
# This file may be distributed under the terms of the GNU GPLv3 license. | ||
|
||
[gcode_macro _km_save_state] | ||
description: Tracks gcode state. | ||
variable_state_set: {} | ||
variable_is_ephemeral: 0 | ||
gcode: | ||
{% if params.SAVE|int %} | ||
{% set dummy = state_set.__setitem__(params.NAME, None) %} | ||
{% else %} | ||
{% set dummy = state_set.__delitem__(params.NAME) %} | ||
{% endif %} | ||
SET_GCODE_VARIABLE MACRO=_km_save_state VARIABLE=is_ephemeral VALUE="{ | ||
1 if state_set|length > 0 else 0 }" | ||
|
||
[gcode_macro save_gcode_state] | ||
description: Wraps SAVE_GCODE_STATE to track persistence state. | ||
Usage: See Klipper documentation | ||
rename_existing: _KM_SAVE_GCODE_STATE | ||
gcode: | ||
_KM_SAVE_GCODE_STATE {rawparams} | ||
{% set NAME = params.NAME|default("default") %} | ||
_km_save_state NAME={NAME} SAVE=1 | ||
|
||
[gcode_macro restore_gcode_state] | ||
description: Wraps RESTORE_GCODE_STATE to track persistence state. | ||
Usage: See Klipper documentation | ||
rename_existing: _KM_RESTORE_GCODE_STATE | ||
gcode: | ||
_KM_RESTORE_GCODE_STATE {rawparams} | ||
{% set NAME = params.NAME|default("default") %} | ||
_km_save_state NAME={NAME} SAVE=0 |