-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdebug_macro.cfg
105 lines (92 loc) · 3.93 KB
/
debug_macro.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#####################################################################
# Macros to debug the printer variable
#####################################################################
[gcode_macro DUMP_PARAMETERS]
description: Debug: Print all entries of the printer object
gcode:
{% set parameters = namespace(output = '') %}
{% for name1 in printer %}
{% for name2 in printer[name1] %}
{% set donotwant = ['configfile'] %}
{% if name1 is not in donotwant %}
{% set param = "printer['%s'].%s = %s" % (name1, name2, printer[name1][name2]) %}
{% set parameters.output = parameters.output + param + "\n" %}
{% endif %}
{% else %}
{% set param = "printer['%s'] = %s" % (name1, printer[name1]) %}
{% set parameters.output = parameters.output + param + "\n" %}
{% endfor %}
{% endfor %}
{action_respond_info(parameters.output)}
[gcode_macro DUMP_CONFIGFILE]
description: Debug: Print all entries of the printer object
gcode:
{% set parameters = namespace(output = '') %}
{% for name1 in printer %}
{% for name2 in printer[name1] %}
{% set donotwant = ['configfile'] %}
{% if name1 is in donotwant %}
{% set param = "printer['%s'].%s = %s" % (name1, name2, printer[name1][name2]) %}
{% set parameters.output = parameters.output + param + "\n" %}
{% endif %}
{% endfor %}
{% endfor %}
{action_respond_info(parameters.output)}
[gcode_macro DUMP_CONFIG]
description: Debug: Print all entries of the printer config object
gcode:
{% set parameters = namespace(output = '') %}
{% for name1 in printer.configfile.config %}
{% set param = "printer.configfile.config['%s'] = %s" % (name1, printer.configfile.config[name1]) %}
{% set parameters.output = parameters.output + param + "\n" %}
{% endfor %}
{action_respond_info(parameters.output)}
[gcode_macro DUMP_SETTINGS]
description: Debug: Print all entries of the printer settings object
gcode:
{% set parameters = namespace(output = '') %}
{% for name1 in printer.configfile.settings %}
{% set param = "printer.configfile.settings['%s'] = %s" % (name1, printer.configfile.settings[name1]) %}
{% set parameters.output = parameters.output + param + "\n" %}
{% endfor %}
{action_respond_info(parameters.output|string)}
[gcode_macro DUMP_WARNINGS]
description: Debug: Print all warning messages from klipper
gcode:
{% set parameters = ["printer.configfile.warnings:"] %}
{% for name1 in printer.configfile.warnings %}
{% set parameters = parameters.append("%s -> %s -> %s\n%s" % (name1.type, name1.section, name1.option, name1.message)) %}
{% endfor %}
{action_respond_info(parameters|join("\n"))}
[gcode_macro SEARCH_VARS]
description: Search printer.name use S=""
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)) }
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}