-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathprint_debug.cfg
622 lines (602 loc) · 32.5 KB
/
print_debug.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
## Copyright (C) 2023 Chris Laprade ([email protected])
##
## This file is part of printcfg.
##
## printcfg is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## printcfg is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with printcfg. If not, see <http://www.gnu.org/licenses/>.
#####################################
## Print Debugging ##
## Version 4.1.0 2023-7-3 ##
#####################################
## This file contains optional macros
## that can be used to debug operation
## of your printer or check variables
## and settings for troubleshooting.
################################
######### GET_SYS_INFO #########
################################
[gcode_macro GET_SYS_INFO]
gcode:
RESPOND MSG="Load: "{printer.system_stats.sysload} ; System Load
RESPOND MSG="CPU: "{printer.system_stats.cputime}"%" ; CPU Usage
RESPOND MSG="Free Mem: "{printer.system_stats.memavail}" B" ; Free Memory
################################
######### PRINT_STATS ##########
################################
[gcode_macro GET_PRINT_STATS]
gcode:
RESPOND MSG="File: "{printer.print_stats.filename} ; File Name
RESPOND MSG="File Path: "{printer.virtual_sdcard.file_path} ; File Path
RESPOND MSG="File Position: "{printer.virtual_sdcard.file_position} ; File Position
RESPOND MSG="File Size: "{printer.virtual_sdcard.file_size} ; File Size
RESPOND MSG="Total Duration: "{printer.print_stats.total_duration} ; Total Duration
RESPOND MSG="Print Duration: "{printer.print_stats.print_duration} ; Print Duration
RESPOND MSG="Filament Used: "{printer.print_stats.filament_used} ; Filament Used
RESPOND MSG="State: "{printer.print_stats.state} ; Print State
RESPOND MSG="State: "{printer.print_stats.message} ; Print Message
RESPOND MSG="Total Layers: "{printer.print_stats.info.total_layer} ; Total Layers
RESPOND MSG="Current Layer: "{printer.print_stats.info.current_layer} ; Current Layer
RESPOND MSG="Paused: "{printer.pause_resume.is_paused} ; Paused State
RESPOND MSG="Idle State: "{printer.idle_timeout.state} ; Idle State
RESPOND MSG="Printing Time: "{printer.idle_timeout.printing_time} ; Printing Time
RESPOND MSG="Print Active: "{printer.virtual_sdcard.is_active} ; Print Active
RESPOND MSG="Print Progress: "{printer.virtual_sdcard.progress} ; Print Progress
################################
######## POSITION_STATS ########
################################
[gcode_macro GET_POSITION_STATS]
gcode:
{% set printcfg = printer['gcode_macro _printcfg'] %} ; get printcfg variables
{% set FIL_SWITCH = 'filament_switch_sensor filament_sensor' %} ; Filament Switch Sensor
{% set FIL_MOTION = 'filament_motion_sensor filament_motion' %} ; Filament Motion Sensor
{% set CHAMBER_HEAT = printcfg.chamber_type + ' ' + printcfg.chamber_name %} ; chamber sensor
{% set config = printer.configfile.settings %} ; get realtime configfile settings
{% if printer.toolhead.homed_axes %} ; check if printer supports homing
RESPOND MSG="Homed Axis: "{printer.toolhead.homed_axes} ; List homed axes
{% else %} ; if not homed
RESPOND MSG="Homed Axis: none" ; List homed axes
{% endif %}
{% if "xyz" in printer.toolhead.homed_axes %} ; check if printer is homed
GET_POSITION ; get current position stats
RESPOND MSG="Gcode Position: X{printer.gcode_move.gcode_position.x}, Y{printer.gcode_move.gcode_position.y}, Z{printer.gcode_move.gcode_position.z}, E{printer.gcode_move.gcode_position.e}"
RESPOND MSG="Stalls: "{printer.toolhead.stalls}
RESPOND MSG="Minimum Position: X{printer.toolhead.axis_minimum.x}, Y{printer.toolhead.axis_minimum.y}, Z{printer.toolhead.axis_minimum.z}"
RESPOND MSG="Maximum Position: X{printer.toolhead.axis_maximum.x}, Y{printer.toolhead.axis_maximum.y}, Z{printer.toolhead.axis_maximum.z}"
RESPOND MSG="Maximum Velocity: {printer.toolhead.max_velocity}mm/s"
RESPOND MSG="Maximum Acceleration: {printer.toolhead.max_accel}mm/s/s"
RESPOND MSG="Maximum Accel-to-Decel: {printer.toolhead.max_accel_to_decel}mm/s/s"
RESPOND MSG="Square Corner Velocity: {printer.toolhead.square_corner_velocity}mm/s"
RESPOND MSG="Live Velocity: {printer.motion_report.live_velocity}mm/s"
RESPOND MSG="Gcode Speed: {printer.gcode_move.speed}mm/s"
RESPOND MSG="Gcode Speed Factor: {(printer.gcode_move.speed_factor * 100)}%"
RESPOND MSG="Gcode Extrude Factor: {(printer.gcode_move.extrude_factor * 100)}%"
RESPOND MSG="Absolute Positioning: "{printer.gcode_move.absolute_coordinates}
RESPOND MSG="Absolute Extrusion: "{printer.gcode_move.absolute_extrude}
GET_PROBE_LIMITS
{% if printer.quad_gantry_level %} ; check if printer supports quad gantry level
RESPOND MSG="Quad gantry Level Applied: "{printer.quad_gantry_level.applied}
{% endif %}
{% if printer.z_tilt %} ; check if printer supports z_tilt
RESPOND MSG="Z-Tilt Applied: "{printer.z_tilt.applied}
{% endif %}
{% if printer.bed_mesh %} ; check if printer supports bed_mesh
{% set bed_mesh = printer.bed_mesh %}
RESPOND MSG="Bed Mesh Profile: "{bed_mesh.profile_name}
RESPOND MSG="Bed Mesh Min: {bed_mesh.mesh_min}"
RESPOND MSG="Bed Mesh Max: {bed_mesh.mesh_max}"
{% endif %}
{% if printer[FIL_SWITCH] %} ; check if printer supports filament switch sensor
{% set fil_sensor = printer[FIL_SWITCH] %}
RESPOND MSG="Filament Sensor Enabled: "{fil_sensor.enabled}
RESPOND MSG="Filament Detected: "{fil_sensor.filament_detected}
{% endif %}
{% if printer[FIL_MOTION] %} ; check if printer supports filament motion sensor
{% set fil_sensor = printer[FIL_MOTION] %}
RESPOND MSG="Filament Sensor Enabled: "{fil_sensor.enabled}
RESPOND MSG="Filament Detected: "{fil_sensor.filament_detected}
{% endif %}
{% set extruder = printer['extruder'] %}
{% set heater_bed = printer['heater_bed'] %}
{% set chamber = printer[CHAMBER_HEAT] %}
RESPOND MSG="Extruder Temperature: {extruder.temperature}C"
RESPOND MSG="Extruder Target Temp: {extruder.target}C"
RESPOND MSG="Extruder Power: {(extruder.power * 100)}%"
RESPOND MSG="Extruder Can Extrude: {extruder.can_extrude}"
RESPOND MSG="Bed Temperature: {heater_bed.temperature}C"
RESPOND MSG="Bed Target Temp: {heater_bed.target}C"
RESPOND MSG="Bed Power: {(heater_bed.power * 100)}%"
{% if chamber %} ; check if printer has chamber heating/sensing
RESPOND MSG="Chamber Temperature: {chamber.temperature}C"
RESPOND MSG="Chamber Target Temp: {chamber.target}C"
{% if chamber.speed %} ; check if printer has chamber fan
RESPOND MSG="Chamber Fan: {(chamber.speed * 100)}%"
{% elif chamber.power %} ; check if printer has chamber heater
RESPOND MSG="Chamber Power: {(heater_bed.power * 100)}%"
{% endif %}
{% endif %}
{% if config["tmc2130 stepper_x"] %} ; check if printer has tmc2130 drivers
{% set xyz_drive = True %}
{% set driver_x = printer["tmc2130 stepper_x"] %}
{% set driver_y = printer["tmc2130 stepper_y"] %}
{% set driver_z = printer["tmc2130 stepper_z"] %}
{% if config["tmc2130 stepper_z1"] %}
{% set driver_z1 = printer["tmc2130 stepper_z1"] %}
{% else %}
{% set driver_z1 = 0 %}
{% endif %}
{% elif config["tmc2208 stepper_x"] %} ; check if printer has tmc2208 drivers
{% set xyz_drive = True %}
{% set driver_x = printer["tmc2208 stepper_x"] %}
{% set driver_y = printer["tmc2208 stepper_y"] %}
{% set driver_z = printer["tmc2208 stepper_z"] %}
{% if config["tmc2208 stepper_z1"] %}
{% set driver_z1 = printer["tmc2208 stepper_z1"] %}
{% else %}
{% set driver_z1 = 0 %}
{% endif %}
{% elif config["tmc2209 stepper_x"] %} ; check if printer has tmc2209 drivers
{% set xyz_drive = True %}
{% set driver_x = printer["tmc2209 stepper_x"] %}
{% set driver_y = printer["tmc2209 stepper_y"] %}
{% set driver_z = printer["tmc2209 stepper_z"] %}
{% if config["tmc2209 stepper_z1"] %}
{% set driver_z1 = printer["tmc2209 stepper_z1"] %}
{% else %}
{% set driver_z1 = 0 %}
{% endif %}
{% elif config["tmc2240 stepper_x"] %} ; check if printer has tmc2240 drivers
{% set xyz_drive = True %}
{% set driver_x = printer["tmc2240 stepper_x"] %}
{% set driver_y = printer["tmc2240 stepper_y"] %}
{% set driver_z = printer["tmc2240 stepper_z"] %}
{% if config["tmc2240 stepper_z1"] %}
{% set driver_z1 = printer["tmc2240 stepper_z1"] %}
{% else %}
{% set driver_z1 = 0 %}
{% endif %}
{% elif config["tmc2660 stepper_x"] %} ; check if printer has tmc2660 drivers
{% set xyz_drive = True %}
{% set driver_x = printer["tmc2660 stepper_x"] %}
{% set driver_y = printer["tmc2660 stepper_y"] %}
{% set driver_z = printer["tmc2660 stepper_z"] %}
{% if config["tmc2660 stepper_z1"] %}
{% set driver_z1 = printer["tmc2660 stepper_z1"] %}
{% else %}
{% set driver_z1 = 0 %}
{% endif %}
{% elif config["tmc5160 stepper_x"] %} ; check if printer has tmc5160 drivers
{% set xyz_drive = True %}
{% set driver_x = printer["tmc5160 stepper_x"] %}
{% set driver_y = printer["tmc5160 stepper_y"] %}
{% set driver_z = printer["tmc5160 stepper_z"] %}
{% if config["tmc5160 stepper_z1"] %}
{% set driver_z1 = printer["tmc5160 stepper_z1"] %}
{% else %}
{% set driver_z1 = 0 %}
{% endif %}
{% elif config["tmc2130 stepper_a"] %} ; check if printer has tmc2130 drivers
{% set xyz_drive = False %}
{% set driver_x = printer["tmc2130 stepper_a"] %}
{% set driver_y = printer["tmc2130 stepper_b"] %}
{% set driver_z = printer["tmc2130 stepper_c"] %}
{% set driver_z1 = 0 %}
{% elif config["tmc2208 stepper_a"] %}
{% set xyz_drive = False %}
{% set driver_x = printer["tmc2208 stepper_a"] %}
{% set driver_y = printer["tmc2208 stepper_b"] %}
{% set driver_z = printer["tmc2208 stepper_c"] %}
{% set driver_z1 = 0 %}
{% elif config["tmc2209 stepper_a"] %}
{% set xyz_drive = False %}
{% set driver_x = printer["tmc2209 stepper_a"] %}
{% set driver_y = printer["tmc2209 stepper_b"] %}
{% set driver_z = printer["tmc2209 stepper_c"] %}
{% set driver_z1 = 0 %}
{% elif config["tmc2260 stepper_a"] %}
{% set xyz_drive = False %}
{% set driver_x = printer["tmc2260 stepper_a"] %}
{% set driver_y = printer["tmc2260 stepper_b"] %}
{% set driver_z = printer["tmc2260 stepper_c"] %}
{% set driver_z1 = 0 %}
{% elif config["tmc5160 stepper_a"] %}
{% set xyz_drive = False %}
{% set driver_x = printer["tmc5160 stepper_a"] %}
{% set driver_y = printer["tmc5160 stepper_b"] %}
{% set driver_z = printer["tmc5160 stepper_c"] %}
{% set driver_z1 = 0 %}
{% else %}
{% set driver = 0 %}
{% endif %}
{% if config["tmc2130 extruder"] %} ; check if printer has tmc2130 extruder driver
{% set driver_e = printer["tmc2130 extruder"] %}
{% elif config["tmc2208 extruder"] %} ; check if printer has tmc2208 extruder driver
{% set driver_e = printer["tmc2208 extruder"] %}
{% elif config["tmc2209 extruder"] %} ; check if printer has tmc2209 extruder driver
{% set driver_e = printer["tmc2209 extruder"] %}
{% elif config["tmc2240 extruder"] %} ; check if printer has tmc2240 extruder driver
{% set driver_e = printer["tmc2240 extruder"] %}
{% elif config["tmc2260 extruder"] %} ; check if printer has tmc2260 extruder driver
{% set driver_e = printer["tmc2260 extruder"] %}
{% elif config["tmc5160 extruder"] %} ; check if printer has tmc5160 extruder driver
{% set driver_e = printer["tmc5160 extruder"] %}
{% else %}
{% set driver = 0 %}
{% endif %}
{% if driver != 0 %}
{% if xyz_driver == True %}
RESPOND MSG="X Stepper Run Current: "{driver_x.run_current}
{% if driver_x.hold_current %}
RESPOND MSG="X Stepper Hold Current: "{driver_x.hold_current}
{% endif %}
RESPOND MSG="Y Stepper Run Current: "{driver_y.run_current}
{% if driver_y.hold_current %}
RESPOND MSG="Y Stepper Hold Current: "{driver_y.hold_current}
{% endif %}
{% if driver_z1 == 0 %}
RESPOND MSG="Z Stepper Run Current: "{driver_z.run_current}
{% if driver_z.hold_current %}
RESPOND MSG="Z Stepper Hold Current: "{driver_z.hold_current}
{% endif %}
{% else %}
RESPOND MSG="Z0 Stepper Run Current: "{driver_z.run_current}
{% if driver_z.hold_current %}
RESPOND MSG="Z0 Stepper Hold Current: "{driver_z.hold_current}
{% endif %}
RESPOND MSG="Z1 Stepper Run Current: "{driver_z1.run_current}
{% if driver_z1.hold_current %}
RESPOND MSG="Z1 Stepper Hold Current: "{driver_z1.hold_current}
{% endif %}
{% endif %}
{% else %}
RESPOND MSG="A Stepper Run Current: "{driver_x.run_current}
{% if driver_x.hold_current %}
RESPOND MSG="A Stepper Hold Current: "{driver_x.hold_current}
{% endif %}
RESPOND MSG="B Stepper Run Current: "{driver_y.run_current}
{% if driver_y.hold_current %}
RESPOND MSG="B Stepper Hold Current: "{driver_y.hold_current}
{% endif %}
RESPOND MSG="C Stepper Run Current: "{driver_z.run_current}
{% if driver_z.hold_current %}
RESPOND MSG="C Stepper Hold Current: "{driver_z.hold_current}
{% endif %}
{% endif %}
RESPOND MSG="Extruder Run Current: "{driver_e.run_current}
{% if driver_e.hold_current %}
RESPOND MSG="Extruder Hold Current: "{driver_e.hold_current}
{% endif %}
{% endif %}
{% else %}
RESPOND TYPE=error MSG="All axis must be homed to retrieve position stats."
{% endif %}
################################
######### PROBE_LIMITS #########
################################
[gcode_macro GET_PROBE_LIMITS]
description: Calculates the probe min/max/current coordinates
gcode:
{% set config = printer.configfile.settings %}
## Find probe config in configfile
{% if config["bltouch"] %} ; check if printer has bltouch probe
## bltouch section found
{% set probe = config["bltouch"] %}
{% set has_probe = True %}
{% elif config["probe"] %} ; check if printer has generic probe
## probe section found
{% set probe = config["probe"] %}
{% set has_probe = True %}
{% elif config["beacon"] %} ; check if printer has beacon probe
## beacon section found
{% set probe = config["beacon"] %}
{% set has_probe = True %}
{% else %}
## No probe or bltouch sections found
RESPOND MSG="Failed to detect probe in configfile"
{% endif %}
{% if has_probe %} ; check if probe was found
{% set stepperx = config["stepper_x"] %}
{% set steppery = config["stepper_y"] %}
{% set xprobemin = stepperx["position_min"]|float + probe["x_offset"]|float %}
{% set xprobemax = stepperx["position_max"]|float + probe["x_offset"]|float %}
{% set yprobemin = steppery["position_min"]|float + probe["y_offset"]|float %}
{% set yprobemax = steppery["position_max"]|float + probe["y_offset"]|float %}
RESPOND MSG="Configured Probe X-Offset {probe.x_offset}"
RESPOND MSG="Configured Probe Y-Offset {probe.y_offset}"
{% if probe.z_offset is defined %} ; check if probe has z_offset defined
RESPOND MSG="Configured Probe Z-Offset {probe.z_offset}"
{% elif probe.trigger_distance is defined %} ; check if probe has trigger_distance defined
RESPOND MSG="Configured Probe Trigger Distance {probe.trigger_distance}"
{% endif %}
RESPOND MSG="Minimum PROBE position X={xprobemin} Y={yprobemin}"
RESPOND MSG="Maximum PROBE position X={xprobemax} Y={yprobemax}"
## check if printer homed
{% if "xyz" in printer.toolhead.homed_axes %} ; check if printer has been homed
{% set curprobex = printer.toolhead.position.x|float + probe["x_offset"]|float %}
{% set curprobey = printer.toolhead.position.y|float + probe["y_offset"]|float %}
RESPOND MSG="Current PROBE position X={curprobex} Y={curprobey}"
{% endif %}
{% endif %}
################################
######## DUMP_VARIABLES ########
################################
## From Ellis's Klipper Tuning Guide
## Arguments ####################
## NAME (string) - Filter results based on name (only show varables with names containing this string)
## VALUE (string) - Filter results based on value (only show values containing this value)
## SHOW_CFG (integer, 0-1) - Set to 1 to include entire config in output. Default 0 (config filtered out)
## Examples ####################
## DUMP_VARIABLES: Returns all variables (excluding printer['configfile'].config and printer['configfile'].settings as they contain the entire config).
## DUMP_VARIABLES NAME=stepper: Returns all variables which have the string stepper in their name.
## DUMP_VARIABLES VALUE=extruder : Returns all variables which have the string extruder in their value.
## DUMP_VARIABLES NAME=stepper VALUE=extruder : Returns all variables which have the string stepper in their name and the string extruder in their value.
## DUMP_VARIABLES SHOW_CFG=1 : Returns all variables, including the config.
[gcode_macro DUMP_VARIABLES]
description: Dumps all current Klipper variables to the g-code terminal.
gcode:
{% set filter_name = params.NAME|default('')|string|lower %} ; filter by name
{% set filter_value = params.VALUE|default('')|string|lower %} ; filter by value
{% set show_cfg = params.SHOW_CFG|default(0)|int %} ; Show entire config in output
{% set out = [] %} ; output array
{% for key1 in printer %} ; loop through all variables
{% for key2 in printer[key1] %} ; loop through all sub-variables
{% if (show_cfg or not (key1|lower == 'configfile' and key2|lower in ['config', 'settings'])) and (filter_name in key1|lower or filter_name in key2|lower) and filter_value in printer[key1][key2]|string|lower %} ; check if variable should be included in output
{% set dummy = out.append("printer['%s'].%s = %s" % (key1, key2, printer[key1][key2])) %} ; add variable to output
{% endif %}
{% else %} ; no sub-variables found
{% if filter_name in key1|lower and filter_value in printer[key1]|string|lower %} ; check if variable should be included in output
{% set dummy = out.append("printer['%s'] = %s" % (key1, printer[key1])) %} ; add variable to output
{% endif %}
{% endfor %}
{% endfor %}
{action_respond_info(out|join("\n"))} ; output all variables
################################
######## DUMP_VARIABLES ########
################################
## 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 %}
################################
########## TEST_SPEED ##########
################################
## From Ellis's Klipper Tuning Guide
## Home, get position, throw around toolhead, home again.
## If MCU stepper positions (first line in GET_POSITION) are greater than a full step different (your number of microsteps), then skipping occured.
## We only measure to a full step to accomodate for endstop variance.
## Example: TEST_SPEED SPEED=300 ACCEL=5000 ITERATIONS=10
[gcode_macro TEST_SPEED]
description: Throw around toolhead to test for skipping.
gcode:
# Speed
{% set speed = params.SPEED|default(printer.configfile.settings.printer.max_velocity)|int %}
# Iterations
{% set iterations = params.ITERATIONS|default(5)|int %}
# Acceleration
{% set accel = params.ACCEL|default(printer.configfile.settings.printer.max_accel)|int %}
# Bounding inset for large pattern (helps prevent slamming the toolhead into the sides after small skips, and helps to account for machines with imperfectly set dimensions)
{% set bound = params.BOUND|default(20)|int %}
# Size for small pattern box
{% set smallpatternsize = SMALLPATTERNSIZE|default(20)|int %}
# Large pattern
# Max positions, inset by BOUND
{% set x_min = printer.toolhead.axis_minimum.x + bound %}
{% set x_max = printer.toolhead.axis_maximum.x - bound %}
{% set y_min = printer.toolhead.axis_minimum.y + bound %}
{% set y_max = printer.toolhead.axis_maximum.y - bound %}
# Small pattern at center
# Find X/Y center point
{% set x_center = (printer.toolhead.axis_minimum.x|float + printer.toolhead.axis_maximum.x|float ) / 2 %}
{% set y_center = (printer.toolhead.axis_minimum.y|float + printer.toolhead.axis_maximum.y|float ) / 2 %}
# Set small pattern box around center point
{% set x_center_min = x_center - (smallpatternsize/2) %}
{% set x_center_max = x_center + (smallpatternsize/2) %}
{% set y_center_min = y_center - (smallpatternsize/2) %}
{% set y_center_max = y_center + (smallpatternsize/2) %}
# Save current gcode state (absolute/relative, etc)
SAVE_GCODE_STATE NAME=TEST_SPEED
# Output parameters to g-code terminal
{ action_respond_info("TEST_SPEED: starting %d iterations at speed %d, accel %d" % (iterations, speed, accel)) }
# Home and get position for comparison later:
G28
# QGL if not already QGLd (only if QGL section exists in config)
{% if printer.configfile.settings.quad_gantry_level %}
{% if printer.quad_gantry_level.applied == False %}
QUAD_GANTRY_LEVEL
G28 Z
{% endif %}
{% endif %}
# Move 50mm away from max position and home again (to help with hall effect endstop accuracy - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/24)
G90
G1 X{printer.toolhead.axis_maximum.x-50} Y{printer.toolhead.axis_maximum.y-50} F{30*60}
G28 X Y
G0 X{printer.toolhead.axis_maximum.x-1} Y{printer.toolhead.axis_maximum.y-1} F{30*60}
G4 P1000
GET_POSITION
# Go to starting position
G0 X{x_min} Y{y_min} Z{bound + 10} F{speed*60}
# Set new limits
SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} ACCEL_TO_DECEL={accel / 2}
{% for i in range(iterations) %}
# Large pattern
# Diagonals
G0 X{x_min} Y{y_min} F{speed*60}
G0 X{x_max} Y{y_max} F{speed*60}
G0 X{x_min} Y{y_min} F{speed*60}
G0 X{x_max} Y{y_min} F{speed*60}
G0 X{x_min} Y{y_max} F{speed*60}
G0 X{x_max} Y{y_min} F{speed*60}
# Box
G0 X{x_min} Y{y_min} F{speed*60}
G0 X{x_min} Y{y_max} F{speed*60}
G0 X{x_max} Y{y_max} F{speed*60}
G0 X{x_max} Y{y_min} F{speed*60}
# Small pattern
# Small diagonals
G0 X{x_center_min} Y{y_center_min} F{speed*60}
G0 X{x_center_max} Y{y_center_max} F{speed*60}
G0 X{x_center_min} Y{y_center_min} F{speed*60}
G0 X{x_center_max} Y{y_center_min} F{speed*60}
G0 X{x_center_min} Y{y_center_max} F{speed*60}
G0 X{x_center_max} Y{y_center_min} F{speed*60}
# Small box
G0 X{x_center_min} Y{y_center_min} F{speed*60}
G0 X{x_center_min} Y{y_center_max} F{speed*60}
G0 X{x_center_max} Y{y_center_max} F{speed*60}
G0 X{x_center_max} Y{y_center_min} F{speed*60}
{% endfor %}
# Restore max speed/accel/accel_to_decel to their configured values
SET_VELOCITY_LIMIT VELOCITY={printer.configfile.settings.printer.max_velocity} ACCEL={printer.configfile.settings.printer.max_accel} ACCEL_TO_DECEL={printer.configfile.settings.printer.max_accel_to_decel}
# Re-home and get position again for comparison:
G28
# Go to XY home positions (in case your homing override leaves it elsewhere)
G90
G0 X{printer.toolhead.axis_maximum.x-1} Y{printer.toolhead.axis_maximum.y-1} F{30*60}
G4 P1000
GET_POSITION
# Restore previous gcode state (absolute/relative, etc)
RESTORE_GCODE_STATE NAME=TEST_SPEED
################################
######### FORCE_MOVES ##########
################################
## Commands that use the force_move feature to move the toolhead without homing
## UNSAFE_RAISE_TOOL
## Raise the toolhead without homing
########## Parameters ##########
## Z: The Z height to raise by (default: 10) mm
## F: The feedrate to use (default: 10) mm/s
[gcode_macro UNSAFE_RAISE_TOOL]
description: Raise the toolhead without homing
gcode:
{% set z = params.Z|default(10)|float %}
{% set f = params.F|default(10)|float %}
G90
SET_KINEMATIC_POSITION Z=0
G0 Z{z} F{ (f*60) }
M84
## UNSAFE_MOVE_TOOL
## Move the toolhead without homing
########## Parameters ##########
## X: The X distance to move by (default: 0) mm
## Y: The Y distance to move by (default: 0) mm
## Z: The Z distance to move by (default: 10) mm
## F: The feedrate to use (default: 10) mm/s
[gcode_macro UNSAFE_MOVE_TOOL]
description: Move the toolhead without homing
gcode:
{% set z = params.Z|default(0)|float %}
{% set x = params.X|default(0)|float %}
{% set y = params.Y|default(0)|float %}
{% set f = params.F|default(10)|float %}
G90
SET_KINEMATIC_POSITION Z={(printer.toolhead.axis_maximum.z/2)} X={(printer.toolhead.axis_maximum.x/2)} Y={(printer.toolhead.axis_maximum.y/2)}
G0 X{(printer.toolhead.axis_maximum.x/2)+x} Y{(printer.toolhead.axis_maximum.y/2)+y} Z{(printer.toolhead.axis_maximum.z/2)+z} F{ (f*60) }
M84
## WHAT_MESH
## Respond with the name of the currently loaded mesh
[gcode_macro WHAT_MESH]
description: Respond with the name of the currently loaded mesh
gcode:
{% if printer.bed_mesh.profile_name == "" %} ; If no mesh is loaded, the profile_name is an empty string
{ action_respond_info( "No mesh is loaded" ) } ; Respond with no mesh loaded
{% else %} ; If a mesh is loaded, the profile_name is the mesh name
{ action_respond_info( "The {} mesh is loaded".format(printer.bed_mesh.profile_name) ) } ; Respond with the mesh name
{ action_respond_info( "The mesh min is {}".format(printer.bed_mesh.mesh_min) ) } ; Respond with the mesh min
{ action_respond_info( "The mesh max is {}".format(printer.bed_mesh.mesh_max) ) } ; Respond with the mesh max
{% endif %}
{% if params.LIST|lower == 'true' or params.ALL == 'true'%} ; If the LIST parameter is true, or the ALL parameter is true
{ action_respond_info( "Available profiles are: \n {}".format(printer.bed_mesh.profiles) ) } ; Respond with the list of available profiles
{% endif %}
## WHAT_IDLE
## Respond with the current idle timeout setting
[gcode_macro WHAT_IDLE]
description: Respond with the current idle timeout setting
gcode:
{ action_respond_info( "The idle timeout is set to {} seconds".format(printer.configfile.settings.idle_timeout.timeout) ) } ; Respond with the idle timeout setting
{ action_respond_info( "The idle gcode is set to: \n {}".format(printer.configfile.settings.idle_timeout.gcode) ) } ; Respond with the idle gcode
## AM_I_PRINTING
## Respond with whether or not the printer is currently printing
[gcode_macro AM_I_PRINTING]
description: Respond with whether or not the printer is currently printing
gcode:
{% if printer.virtual_sdcard.is_active %} ; If the virtual SD card is active
{ action_respond_info( "The printer is printing" ) } ; Respond with "printing" status
{% else %}
{ action_respond_info( "The printer is not printing" ) } ; Respond with "not printing" status
{% endif %}
[gcode_macro WHERE_AM_I]
description: Respond with the current position of the toolhead
gcode:
# Define variables
{% set tool = printer.toolhead %}
{% set mr = printer.motion_report %}
{% set x = tool.position.x %}
{% set y = tool.position.y %}
{% set z = tool.position.z %}
{% set x_live = mr.live_position.x %}
{% set y_live = mr.live_position.y %}
{% set z_live = mr.live_position.z %}
# Check if the printer is homed
{% if "xyz" in tool.homed_axes %} ; If the printer is homed
# Output the current position
{ action_respond_info( "The toolhead is at: \n X: {} \n Y: {} \n Z: {}".format( x, y, z ) ) }
{ action_respond_info( "The live position is: \n X: {} \n Y: {} \n Z: {}".format( x_live, y_live, z_live ) ) }
{% else %} ; If the printer is not homed
{ action_respond_info( "The toolhead is not homed" ) } ; Respond with "not homed" status
{% endif %}
# Output the current position
[gcode_macro GET_SHAPERS]
description: Respond with the current shaper settings
gcode:
{% set config = printer.configfile.settings %} ; Make code cleaner
{% set is = config.input_shaper %} ; by defining these vars
# Output the shaper types and frequencies
{ action_respond_info( "X shaper: {} at {} Hz".format( is.shaper_type_x, is.shaper_freq_x ) ) }
{ action_respond_info( "Y shaper: {} at {} Hz".format( is.shaper_type_y, is.shaper_freq_y ) ) }