From d27464b0ae6ced227e2898fe4874ba8691fb727e Mon Sep 17 00:00:00 2001 From: Zach Schimke Date: Mon, 27 Jun 2022 01:08:16 -0700 Subject: [PATCH] Feat: Add object_exclusion --- exclude_object.cfg | 51 ++++++++++++++++++++++++++++++++++++++++++++++ printer.cfg | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 exclude_object.cfg diff --git a/exclude_object.cfg b/exclude_object.cfg new file mode 100644 index 0000000..101bb5f --- /dev/null +++ b/exclude_object.cfg @@ -0,0 +1,51 @@ +# Cancel object (aka Marlin/RRF M486 commands) support +# +# Enable object exclusion +[exclude_object] + +[gcode_macro M486] +gcode: + # Parameters known to M486 are as follows: + # [C] Cancel the current object + # [P] Cancel the object with the given index + # [S] Set the index of the current object. + # If the object with the given index has been canceled, this will cause + # the firmware to skip to the next object. The value -1 is used to + # indicate something that isn’t an object and shouldn’t be skipped. + # [T] Reset the state and set the number of objects + # [U] Un-cancel the object with the given index. This command will be + # ignored if the object has already been skipped + + {% if 'exclude_object' not in printer %} + {action_raise_error("[exclude_object] is not enabled")} + {% endif %} + + {% if 'T' in params %} + EXCLUDE_OBJECT RESET=1 + + {% for i in range(params.T | int) %} + EXCLUDE_OBJECT_DEFINE NAME={i} + {% endfor %} + {% endif %} + + {% if 'C' in params %} + EXCLUDE_OBJECT CURRENT=1 + {% endif %} + + {% if 'P' in params %} + EXCLUDE_OBJECT NAME={params.P} + {% endif %} + + {% if 'S' in params %} + {% if params.S == '-1' %} + {% if printer.exclude_object.current_object %} + EXCLUDE_OBJECT_END NAME={printer.exclude_object.current_object} + {% endif %} + {% else %} + EXCLUDE_OBJECT_START NAME={params.S} + {% endif %} + {% endif %} + + {% if 'U' in params %} + EXCLUDE_OBJECT RESET=1 NAME={params.U} + {% endif %} diff --git a/printer.cfg b/printer.cfg index 06a5492..77dedf3 100644 --- a/printer.cfg +++ b/printer.cfg @@ -48,7 +48,7 @@ # Other ##################################################################### [include other.cfg] - +[include exclude_object.cfg] #*# <---------------------- SAVE_CONFIG ----------------------> #*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.