forked from zellneralex/klipper_config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug_macro.cfg
145 lines (121 loc) · 6.69 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Use:
# - DUMP_PARAMETER print all parameter expect configfile
# - DUMP_PARAMETER P='gcode_macro _TEST' print the defined parameter group
# - DUMP_PARAMETER C='printer' print the defined config values
# - DUMP_PARAMETER S='printer' print the defined settings values
[gcode_macro DUMP_PARAMETER]
description: Debug: Print entries of the printer object
gcode:
{% set config = True if params.C or params.S else False %}
{% set path = 'config' if params.C
else 'settings' if params.S %}
{% set search = params.C if params.C
else params.S if params.S
else params.P if params.P %}
{% set out = [] %}
{% for name1 in printer|sort %}
{% if config %} ; print the searched printer.configfile[path] parameter
{% if name1 is in ['configfile'] %}
{% for name2 in printer[name1][path]|sort %}
{% if name2 is in [search] %}
{% for name3, value in printer[name1][path][name2].items()|sort %}
{% set _dummy = out.append("printer.configfile.%s['%s'].%s = %s" %
(path, name2, name3, value)) %}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
{% else %}
{% for name2, value in printer[name1].items()|sort %} ; search for anything expext printer.configfile
{% if search is not defined and name1 is not in ['configfile'] %} ; print all printer. parameter
{% set _dummy = out.append("printer['%s'].%s = %s" % (name1, name2, value)) %}
{% elif search is defined and name1 is in [search] %} ; print the searched printer. parameter
{% set _dummy = out.append("printer['%s'].%s = %s" % (name1, name2, value)) %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% if out|length > 0 %}
{action_respond_info(out|join("\n"))}
{% else %}
{action_respond_info("Nothing found for \"DUMP_PARAMETER %s\"" % rawparams)}
{% endif %}
[gcode_macro DUMP_PRINT_AREA_LIMITS]
description: Debug: Print information about print volume and probeable area
gcode:
{% set min = printer.toolhead.axis_minimum %}
{% set max = printer.toolhead.axis_maximum %}
{% set probe_offset = {'x' : printer.configfile.settings.probe.x_offset,
'y' : printer.configfile.settings.probe.y_offset} %}
{% set probe_area = {'min' : {'x' : [min.x,(min.x-probe_offset.x)]|max,
'y' : [min.y,(min.y-probe_offset.y)]|max},
'max' : {'x' : [max.x,(max.x-probe_offset.x)]|min,
'y' : [max.y,(max.y-probe_offset.y)]|min}} %}
{action_respond_info("Print Volume Limits:
Min X:%7.1f, Y:%7.1f, Z:%7.1f
Max X:%7.1f, Y:%7.1f, Z:%7.1f
Probe Area Limits:
Min X:%7.1f, Y:%7.1f
Max X:%7.1f, Y:%7.1f" %
(min.x,min.y,min.z,max.x,max.y,max.z,probe_area.min.x,probe_area.min.y, probe_area.max.x,probe_area.max.y))}
#####################################################################
# Macros needed for several debug activities
#####################################################################
[gcode_macro _PROC_START]
description: for trace debug purposes - presents depth as leading back-tics
# passed params:
# function=_some_macro_name
# func_params='"{rawparams|string}"' #<-- can have spaces (i.e. multiple paramaters) thus need to encapsulate as string
gcode:
{% set svv = printer.save_variables.variables %} # set eazy accesss context for save_variables object
_SAVE_VARIABLE_STOCK VARIABLE=proc_depth VALUE={svv.proc_depth + 1|int} # increment depth counter
{% set this1 = namespace(depth_indent = "`") %} # btic is proc_depth indicator
# using namespace so it can be manipulated in for loop
{% for iter in range(svv.proc_depth|int) %}
{% set this1.depth_indent = this1.depth_indent + "`" %} # add a btic for each layer of nested code
{% endfor %}
{% if printer["gcode_macro _USER_VARIABLE"].respond.codeflow %}
{% set new_params = rawparams|replace("function=", "") %} # strip function= from passed params
{% set new_params = new_params|replace("func_params=", "") %} # strip func_params=
{% set new_params = new_params|replace("'", "") %} # strip ' portion of string encapsulation
{% set new_params = new_params|replace("\"", "") %} # strip " portion of string encapsulation
M118 {this1.depth_indent ~ " " ~ new_params|upper} # concatenate depth btics and (macro and params) and display in console
{% endif %}
[gcode_macro _PROC_END]
description: for trace debug purposes - presents depth as leading back-tics
# function=_some_macro_name
gcode:
{% set svv = printer.save_variables.variables %} # set eazy accesss context for save_variables object
{% set this1 = namespace(depth_indent = "`") %} # proc_depth
_SAVE_VARIABLE_STOCK VARIABLE=proc_depth VALUE={svv.proc_depth - 1|int} # decrement depth counter
{% if svv.proc_depth|int < 0 %}
_SAVE_VARIABLE_STOCK VARIABLE=proc_depth VALUE=0 # in theory, we should never get here...
{% endif %}
{% if printer["gcode_macro _USER_VARIABLE"].respond.codeflow or params.FORCE|default(0)|int %}
{% for iter in range(svv.proc_depth - 1|int) %}
{% set this1.depth_indent = this1.depth_indent ~ "`" %}
{% endfor %}
{% if printer["gcode_macro _USER_VARIABLE"].show_proc_exit %}
{% if params.FUNCTION|string != "" and printer["gcode_macro _USER_VARIABLE"].show_proc_exit_details %}
# M118 {this1.depth_indent ~ " " ~ params.FUNCTION ~ " End"}
# M118 {this1.depth_indent ~ " [" ~ params.FUNCTION|lower ~ "]"}
# M118 {this1.depth_indent ~ " [" ~ params.FUNCTION|lower ~ "] exit"}
M118 {this1.depth_indent ~ " [" ~ params.FUNCTION|lower ~ "] done"}
{% else %}
M118 {this1.depth_indent}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _debug_vars]
description: macro for debug variables
variable_debug_verb_error: 1 # set to 0 to mute error reporting (um, errors. lol)
variable_debug_verb_info: 0 # set to 0 to mute info reporting (has data)
variable_debug_verb_status: 0 # set to 0 to mute status reporting (useful modes, update, etc.)
variable_debug_verb_debug: 0 # set to 0 to mute debugs stuffs I added
variable_debug_verb_codeflow: 0 # set to 0 to mute debugs stuffs I added (proc entry/exit)
variable_gmove_debug: 0 # start with gmove debug disabled
variable_save_var_debug: 0 # start with svv debug disabled
variable_gcode_state_debug: 0 # start with gcode_state debug disabled
variable_force_svv_typing: 0 # if enabled, forces type conv from str to int/flt, if numbers are stringified
gcode:
# there is none, this is for module variable use only