From 57420ed384a55cddbb34f50864276d0f092e073b Mon Sep 17 00:00:00 2001 From: Reijii Date: Thu, 3 Apr 2025 02:11:51 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=81=D0=BA=D1=80=D1=8B=D1=82=D1=8B=D0=B5=20=D0=BD=D0=B0=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=B5=D1=87=D0=BD=D1=8B=D0=B5=20=D0=BC=D0=B0?= =?UTF-8?q?=D0=BA=D1=80=D0=BE=D1=81=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/macros.cfg | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/Scripts/macros.cfg b/Scripts/macros.cfg index 70e4145..e426017 100644 --- a/Scripts/macros.cfg +++ b/Scripts/macros.cfg @@ -397,7 +397,7 @@ gcode: PID_CALIBRATE HEATER=heater_bed TARGET={T} -[gcode_macro PSTATUS] +[gcode_macro _PSTATUS] gcode: {% if params.S3 %} {% set info = printer[params.S1][params.S2][params.S3] %} @@ -409,3 +409,44 @@ gcode: {% set info = printer.idle_timeout.state %} {% endif %} {action_respond_info(info|string)} + +[gcode_macro _SEARCH_VARS] +gcode: + {% set search = params.S|lower %} + {% set ns = namespace() %} + {% for item in printer %} + {% if ' ' in item %} + {% set ns.path = ['printer', "['%s']" % (item), ''] %} + {% else %} + {% set ns.path = ['printer.', item, ''] %} + {% endif %} + + {% if search in ns.path|lower %} + { action_respond_info(ns.path|join) } + {% endif %} + + {% if printer[item].items() %} + {% for childkey, child in printer[item].items() recursive %} + {% set ns.path = ns.path[:loop.depth|int + 1] %} + + {% if ' ' in childkey %} + {% set null = ns.path.append("['%s']" % (childkey)) %} + {% else %} + {% set null = ns.path.append(".%s" % (childkey)) %} + {% endif %} + + {% if child is mapping %} + { loop(child.items()) } + {% else %} + {% if search in ns.path|lower %} + { action_respond_info("%s : %s" % (ns.path|join, child)) } + {% else %} + {% if search in child|lower %} + { action_respond_info("%s : %s" % (ns.path|join, child)) } + {% endif %} + {% endif %} + {% endif %} + + {% endfor %} + {% endif %} + {% endfor %} \ No newline at end of file