-
Notifications
You must be signed in to change notification settings - Fork 0
/
gcode_macro_ORIG.cfg
905 lines (839 loc) · 30.4 KB
/
gcode_macro_ORIG.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
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
# F001
# CreateDate: 2023/08/17
[gcode_macro PRINTER_PARAM]
variable_z_safe_pause: 0.0
variable_z_safe_g28: 3.0
variable_max_x_position: 220.0
variable_max_y_position: 220.0
variable_max_z_position: 250.0
variable_fans: 3
variable_auto_g29: 0
variable_fan0_min: 90
variable_fan1_min: 50
variable_fan2_min: 50
variable_fan2_speed: 0
variable_hotend_temp: 0
variable_e_min_current: 0.27
variable_z_coefficient: 0.9972
variable_z_pwl_offset: 0.43
gcode:
[gcode_macro STRUCTURE_PARAM]
variable_bed_length: 220.0
variable_bed_width: 220.0
variable_bed_hight: 250.0
gcode:
[gcode_macro AUTOTUNE_SHAPERS]
#variable_autotune_shapers: 'ei'
gcode:
[gcode_macro LOAD_MATERIAL_CLOSE_FAN2]
variable_fan2_value: 0
gcode:
SAVE_GCODE_STATE NAME=myMoveState
{% if printer['output_pin fan2'].value > 0.0 %}
SET_GCODE_VARIABLE MACRO=LOAD_MATERIAL_CLOSE_FAN2 VARIABLE=fan2_value VALUE={printer['output_pin fan2'].value}
M107 P2
{% endif %}
RESTORE_E_CURRENT
[gcode_macro LOAD_MATERIAL_RESTORE_FAN2]
gcode:
{% set fan2_value = printer['gcode_macro LOAD_MATERIAL_CLOSE_FAN2'].fan2_value|float %}
RESTORE_GCODE_STATE NAME=myMoveState
{% if fan2_value > 0.0 %}
{% set s_value = (fan2_value * 255 - printer["gcode_macro PRINTER_PARAM"].fan2_min) * 255 / (255 - printer["gcode_macro PRINTER_PARAM"].fan2_min) %}
M106 P2 S{s_value} G1
SET_GCODE_VARIABLE MACRO=LOAD_MATERIAL_CLOSE_FAN2 VARIABLE=fan2_value VALUE=0
{% endif %}
SET_E_MIN_CURRENT
[gcode_macro SET_E_MIN_CURRENT]
gcode:
{% set e_current = printer['gcode_macro PRINTER_PARAM'].e_min_current %}
M400
SET_TMC_CURRENT STEPPER=extruder CURRENT={e_current} HOLDCURRENT={e_current}
G4 P2000
[gcode_macro RESTORE_E_CURRENT]
gcode:
{% set e_current = printer.configfile.settings['tmc2209 extruder'].run_current %}
M400
SET_TMC_CURRENT STEPPER=extruder CURRENT={e_current} HOLDCURRENT={e_current}
G4 P2000
[gcode_macro LOAD_MATERIAL]
description: Carga filamento
gcode:
LOAD_MATERIAL_CLOSE_FAN2
M109 S{printer.custom_macro.default_extruder_temp}
G91
G1 E70 F180
LOAD_MATERIAL_RESTORE_FAN2
[gcode_macro LOAD_MATERIAL_FRIO]
description: Carga filamento y enfria extrusor
gcode:
LOAD_MATERIAL_CLOSE_FAN2
M109 S{printer.custom_macro.default_extruder_temp}
G91
G1 E70 F180
LOAD_MATERIAL_RESTORE_FAN2
M104 ;APAGA EXTRUSOR
[gcode_macro GUPPY_LOAD_MATERIAL]
description: GUPPY CARGA FILAMENTO
gcode:
{% set extruder_temp = params.EXTRUDER_TEMP|default(205)|int %}
{% set extrude_len = params.EXTRUDE_LEN|default(50)|int %}
LOAD_MATERIAL_CLOSE_FAN2
M109 S{extruder_temp}
G91
G1 E{extrude_len} F180
LOAD_MATERIAL_RESTORE_FAN2 # k1 stuff
[gcode_macro GUPPY_LOAD_MATERIAL_FRIO]
description: GUPPY CARGA FILAMENTO Y ENFRIA EXTRUSOR
gcode:
{% set extruder_temp = params.EXTRUDER_TEMP|default(205)|int %}
{% set extrude_len = params.EXTRUDE_LEN|default(50)|int %}
LOAD_MATERIAL_CLOSE_FAN2
M109 S{extruder_temp}
G91
G1 E{extrude_len} F180
LOAD_MATERIAL_RESTORE_FAN2 # k1 stuff
M104 ; APAGA EXTRUSOR
[gcode_macro QUIT_MATERIAL]
description: Retrae filamento
gcode:
SAVE_GCODE_STATE NAME=myMoveState
RESTORE_E_CURRENT
M109 S{printer.custom_macro.default_extruder_temp}
M83
G1 E50 F300
G1 E-15 F3000
G1 E-22.4700 F2400
G1 E-6.4200 F1200
G1 E-3.2100 F720
G1 E5.0000 F356
G1 E-5.0000 F384
G1 E5.0000 F412
G1 E-5.0000 F440
G1 E5.0000 F467
G1 E-5.0000 F495
G1 E5.0000 F523
G1 E-5.0000 F3000
G1 E-30 F1500
# G1 E-15 F3000
SET_E_MIN_CURRENT
RESTORE_GCODE_STATE NAME=myMoveState
[gcode_macro QUIT_MATERIAL_FRIO]
description: Retrae filamento y enfria extrusor
gcode:
SAVE_GCODE_STATE NAME=myMoveState
RESTORE_E_CURRENT
M109 S{printer.custom_macro.default_extruder_temp}
M83
G1 E50 F300
G1 E-15 F3000
G1 E-22.4700 F2400
G1 E-6.4200 F1200
G1 E-3.2100 F720
G1 E5.0000 F356
G1 E-5.0000 F384
G1 E5.0000 F412
G1 E-5.0000 F440
G1 E5.0000 F467
G1 E-5.0000 F495
G1 E5.0000 F523
G1 E-5.0000 F3000
G1 E-15 F1500
# G1 E-15 F3000
SET_E_MIN_CURRENT
RESTORE_GCODE_STATE NAME=myMoveState
M104 ; APAGA EXTRUSOR
[gcode_macro GUPPY_QUIT_MATERIAL]
description: guppy retrae filamento
gcode:
# {% set extruder_temp = params.EXTRUDER_TEMP|default(240)|int %}
SAVE_GCODE_STATE NAME=myMoveState
M109 S{printer.custom_macro.default_extruder_temp}
# M109 S{extruder_temp}
G91
G1 E20 F180
G1 E-30 F180
G1 E-50 F2000
RESTORE_GCODE_STATE NAME=myMoveState
[gcode_macro GUPPY_QUIT_MATERIAL_FRIO]
description: guppy retrae filamento y enfria
gcode:
# {% set extruder_temp = params.EXTRUDER_TEMP|default(240)|int %}
SAVE_GCODE_STATE NAME=myMoveState
M109 S{printer.custom_macro.default_extruder_temp}
# M109 S{extruder_temp}
G91
G1 E20 F180
G1 E-30 F180
G1 E-50 F2000
M104 ; APAGA EXTRUSOR
RESTORE_GCODE_STATE NAME=myMoveState
[gcode_macro Qmode]
variable_flag: 0
variable_accel: 0
variable_accel_to_decel: 0
variable_velocity: 0
variable_square_corner_velocity: 0
variable_pressure_advance:0.0
variable_fan0_value: 0.00
variable_fan1_value: 0.00
variable_fan2_value: 0.00
variable_speed_factor: 0
variable_max_accel: 3000
variable_max_accel_to_decel: 3000
gcode:
{% set printer_state = printer.print_stats.state %}
{% if printer['gcode_macro Qmode'].flag|int == 0 %}
{% if printer_state == "printing" or printer_state == "paused" %}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=accel VALUE={printer.toolhead.max_accel}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=accel_to_decel VALUE={printer.toolhead.max_accel_to_decel}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=velocity VALUE={printer.toolhead.max_velocity}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=square_corner_velocity VALUE={printer.toolhead.square_corner_velocity}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=pressure_advance VALUE={printer.extruder.pressure_advance}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=speed_factor VALUE={printer.gcode_move.speed_factor}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan0_value VALUE={printer['output_pin fan0'].value}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan1_value VALUE={printer['output_pin fan1'].value}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan2_value VALUE={printer['output_pin fan2'].value}
SET_TMC_FIELD STEPPER=stepper_x FIELD=en_spreadcycle VALUE=0
SET_TMC_FIELD STEPPER=stepper_y FIELD=en_spreadcycle VALUE=0
SET_TMC_CURRENT STEPPER=stepper_x CURRENT=0.9
SET_TMC_CURRENT STEPPER=stepper_y CURRENT=0.9
G4 P500
# Set Motion Parameters
SET_VELOCITY_LIMIT ACCEL=3000
SET_VELOCITY_LIMIT ACCEL_TO_DECEL=3000
SET_VELOCITY_LIMIT VELOCITY=160
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=5
SET_PRESSURE_ADVANCE ADVANCE=0.05
M220 S50
{% set tmp = printer['output_pin fan0'].value * 255 %}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan0_value VALUE={tmp}
{% if tmp - printer['gcode_macro PRINTER_PARAM'].fan0_min > (255 - printer['gcode_macro PRINTER_PARAM'].fan0_min) / 2 %}
{% set tmp = printer['gcode_macro PRINTER_PARAM'].fan0_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan0_min) / 2 %}
SET_PIN PIN=fan0 VALUE={tmp}
{% endif %}
{% set tmp = printer['output_pin fan1'].value * 255 %}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan1_value VALUE={printer['output_pin fan1'].value * 255}
{% if tmp - printer['gcode_macro PRINTER_PARAM'].fan1_min > (255 - printer['gcode_macro PRINTER_PARAM'].fan1_min) / 2 %}
{% set tmp = printer['gcode_macro PRINTER_PARAM'].fan1_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan1_min) / 2 %}
SET_PIN PIN=fan1 VALUE={tmp}
{% endif %}
{% set tmp = printer['output_pin fan2'].value * 255 %}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan2_value VALUE={printer['output_pin fan2'].value * 255}
{% if tmp - printer['gcode_macro PRINTER_PARAM'].fan2_min > (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) / 2 %}
{% set tmp = printer['gcode_macro PRINTER_PARAM'].fan2_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) / 2 %}
SET_PIN PIN=fan2 VALUE={tmp}
{% endif %}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=flag VALUE=1
SET_QMODE_FLAG FLAG=1
{% endif %}
{% endif %}
[gcode_macro Qmode_exit]
gcode:
{% set printer_state = printer.print_stats.state %}
{% if printer['gcode_macro Qmode'].flag|int == 1 %}
{% if printer_state == "printing" or printer_state == "paused" %}
SET_VELOCITY_LIMIT ACCEL={printer['gcode_macro Qmode'].accel}
SET_VELOCITY_LIMIT ACCEL_TO_DECEL={printer['gcode_macro Qmode'].accel_to_decel}
SET_VELOCITY_LIMIT VELOCITY={printer['gcode_macro Qmode'].velocity}
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={printer['gcode_macro Qmode'].square_corner_velocity}
SET_PRESSURE_ADVANCE ADVANCE={printer['gcode_macro Qmode'].pressure_advance}
M220 S{printer['gcode_macro Qmode'].speed_factor * 100}
{% set X_RUN_CUR = printer.configfile.settings['tmc2209 stepper_x'].run_current %}
{% set Y_RUN_CUR = printer.configfile.settings['tmc2209 stepper_y'].run_current %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={X_RUN_CUR}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={Y_RUN_CUR}
SET_TMC_FIELD STEPPER=stepper_x FIELD=en_spreadcycle VALUE=1
SET_TMC_FIELD STEPPER=stepper_y FIELD=en_spreadcycle VALUE=1
G4 P500
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=flag VALUE=0
SET_QMODE_FLAG FLAG=0
{% if printer['output_pin fan0'].value != 0 %}
{action_respond_info("fan0_value = %s" % printer['gcode_macro Qmode'].fan0_value)}
SET_PIN PIN=fan0 VALUE={printer['gcode_macro Qmode'].fan0_value}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan0_value VALUE=0
{% endif %}
{% if printer['output_pin fan1'].value != 0 %}
{action_respond_info("fan1_value = %s" % printer['gcode_macro Qmode'].fan1_value)}
SET_PIN PIN=fan1 VALUE={printer['gcode_macro Qmode'].fan1_value}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan1_value VALUE=0
{% endif %}
{% if printer['output_pin fan2'].value != 0 %}
{action_respond_info("fan2_value = %s" % printer['gcode_macro Qmode'].fan2_value)}
SET_PIN PIN=fan2 VALUE={printer['gcode_macro Qmode'].fan2_value}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan2_value VALUE=0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro M204]
rename_existing: M204.1
gcode:
# {% if printer['gcode_macro Qmode'].flag|int == 0 %}
{% set get_params = "" %}
{% set qmode_max_accel = printer['gcode_macro Qmode'].max_accel|string %}
{% if 'S' in params|upper %}
{% if printer['gcode_macro Qmode'].flag|int == 1 and params.S|float > qmode_max_accel|float %}
{% set get_params = (get_params + ' ' + 'S' + qmode_max_accel) %}
{% else %}
{% set get_params = (get_params + ' ' + 'S' + params.S) %}
{% endif %}
{% endif %}
{% if 'P' in params|upper %}
{% if printer['gcode_macro Qmode'].flag|int == 1 and params.P|float > qmode_max_accel|float %}
{% set get_params = (get_params + ' ' + 'P' + qmode_max_accel) %}
{% else %}
{% set get_params = (get_params + ' ' + 'P' + params.P) %}
{% endif %}
{% endif %}
{% if 'T' in params|upper %}
{% if printer['gcode_macro Qmode'].flag|int == 1 and params.T|float > qmode_max_accel|float %}
{% set get_params = (get_params + ' ' + 'T' + qmode_max_accel) %}
{% else %}
{% set get_params = (get_params + ' ' + 'T' + params.T) %}
{% endif %}
{% endif %}
M204.1 {get_params}
# {% endif %}
[gcode_macro M205]
gcode:
{% if 'X' in params %}
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={params.X}
{% elif 'Y' in params %}
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={params.Y}
{% endif %}
[gcode_macro M106]
description: Enciende fan de capa
variable_user_flag: 0
gcode:
{% if (params.U is defined and params.U|int == 1) or (params.U is not defined and printer["gcode_macro M106"].user_flag|int == 0) or (params.G is defined)%}
{% if (params.U is defined and params.U|int == 1) %}
SET_GCODE_VARIABLE MACRO=M106 VARIABLE=user_flag VALUE={params.U|int}
{% endif %}
{% set fans = printer["gcode_macro PRINTER_PARAM"].fans|int %}
{% set fan = 0 %}
{% set value = 0 %}
{% if params.P is defined %}
{% set tmp = params.P|int %}
{% if tmp < fans %}
{% set fan = tmp %}
{% endif %}
{% endif %}
{% if params.S is defined %}
{% set tmp = params.S|float %}
{% else %}
{% set tmp = 255 %}
{% endif %}
{% if tmp > 0 %}
{% if fan == 0 %}
{% set value = (255 - printer["gcode_macro PRINTER_PARAM"].fan0_min) / 255 * tmp %}
{% if printer['gcode_macro Qmode'].flag | int == 1 %}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan0_value VALUE={printer["gcode_macro PRINTER_PARAM"].fan0_min + value}
{% if value > (255 - printer['gcode_macro PRINTER_PARAM'].fan0_min) / 2 %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan0_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan0_min) / 2 %}
{% else %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan0_min + value %}
{% endif %}
{% else %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan0_min + value %}
{% endif %}
{% endif %}
{% if fan == 1 %}
{% set value = (255 - printer["gcode_macro PRINTER_PARAM"].fan1_min) / 255 * tmp %}
{% if printer['gcode_macro Qmode'].flag | int == 1 %}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan1_value VALUE={printer["gcode_macro PRINTER_PARAM"].fan1_min + value}
{% if value > (255 - printer['gcode_macro PRINTER_PARAM'].fan1_min) / 2 %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan1_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan1_min) / 2 %}
{% else %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan1_min + value %}
{% endif %}
{% else %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan1_min + value %}
{% endif %}
{% endif %}
{% if fan == 2 %}
{% set value = (255 - printer["gcode_macro PRINTER_PARAM"].fan2_min) / 255 * tmp %}
{% if printer['gcode_macro Qmode'].flag | int == 1 %}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan2_value VALUE={printer["gcode_macro PRINTER_PARAM"].fan2_min + value}
{% if value > (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) / 2 %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan2_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) / 2 %}
{% else %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan2_min + value %}
{% endif %}
{% else %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan2_min + value %}
{% endif %}
{% endif %}
{% endif %}
{% if value >= 255 %}
{% set value = 255 %}
{% endif %}
SET_PIN PIN=fan{fan} VALUE={value}
{% endif %}
[gcode_macro M107]
description: Apaga fan de capa
gcode:
{% set fans = printer["gcode_macro PRINTER_PARAM"].fans|int %}
{% if params.P is defined %}
{% if params.P|int < fans %}
SET_PIN PIN=fan{params.P|int} VALUE=0
{% else %}
SET_PIN PIN=fan0 VALUE=0
{% endif %}
{% else %}
SET_PIN PIN=fan0 VALUE=0
SET_PIN PIN=fan2 VALUE=0
{% endif %}
[gcode_macro M900]
gcode:
{% if 'K' in params %}
{% if 'E' in params %}
SET_PRESSURE_ADVANCE EXTRUDER={params.E} ADVANCE={params.K}
{% else %}
SET_PRESSURE_ADVANCE ADVANCE={params.K}
{% endif %}
{% endif %}
[delayed_gcode wait_temp]
# initial_duration: 2.
gcode:
{% set cur_temp = printer.extruder.temperature %}
{% if cur_temp|int < 40 %}
#{action_respond_info("end_temp!\n")}
WAIT_TEMP_END
{% else %}
#{action_respond_info("cur_temp = %s \n" % (cur_temp))}
UPDATE_DELAYED_GCODE ID=wait_temp DURATION=5
{% endif %}
[gcode_macro WAIT_TEMP_START]
gcode:
UPDATE_DELAYED_GCODE ID=wait_temp DURATION=1
#M106 P0 S255 G1
M106 P2 S127 G1
[gcode_macro WAIT_TEMP_END]
gcode:
UPDATE_DELAYED_GCODE ID=wait_temp DURATION=0
M106 P0 S0 G1
M106 P2 S0 G1
[gcode_macro PRINT_CALIBRATION]
# This part of the command is replaced by the application side without passing parameters
gcode:
CX_PRINT_LEVELING_CALIBRATION
[gcode_macro FIRST_FLOOR_PAUSE_POSITION]
gcode:
{% set extruder_temp = printer.custom_macro.g28_ext_temp %}
M104 S{extruder_temp}
{% set y_park = 5 %}
{% set x_park = 5 %}
G90
G1 Z2 F600
G1 X{x_park} Y{y_park} F6000
G1 Z0.2 F600
[gcode_macro ACCURATE_G28]
gcode:
{% if printer['gcode_macro START_PRINT'].z_sensorless|int == 1 %}
G4 P1000
STEPPER_Z_SENEORLESS
M400
G4 P500
SET_KINEMATIC_POSITION
{% set retract_z = printer.configfile.settings['prtouch_v2'].retract_z_dist %}
{% set retract_speed = printer.configfile.settings['prtouch_v2'].retract_z_speed %}
G91
G1 Z-{retract_z} F{retract_speed}
M400
G90
G4 P1000
{action_respond_info("STEPPER_Z_SENEORLESS \n")}
Z_SENSORLESS_CLEAR
{% endif %}
ACCURATE_HOME_Z
[gcode_macro Z_SENSORLESS_SET]
gcode:
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=z_sensorless VALUE=1
{action_respond_info("set z_sensorless")}
[gcode_macro Z_SENSORLESS_CLEAR]
gcode:
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=z_sensorless VALUE=0
{action_respond_info("clear z_sensorless")}
#[gcode_macro START_PRINT]
#variable_prepare: 0
#variable_z_sensorless: 0
#gcode:
# SET_GCODE_VARIABLE MACRO=M106 VARIABLE=user_flag VALUE=0
# WAIT_TEMP_END
# CLEAR_PAUSE
# SET_TEMPERATURE_FAN_TARGET temperature_fan=soc_fan target=5
# {% set g28_extruder_temp = printer.custom_macro.g28_ext_temp %}
# {% set bed_temp = printer.custom_macro.default_bed_temp %}
# {% set extruder_temp = printer.custom_macro.default_extruder_temp %}
# {% if 'BED_TEMP' in params|upper and (params.BED_TEMP|float) %}
# {% set bed_temp = params.BED_TEMP %}
# {% endif %}
# {% if 'EXTRUDER_TEMP' in params|upper and (params.EXTRUDER_TEMP|float) %}
# {% set extruder_temp = params.EXTRUDER_TEMP %}
# {% endif %}
# {% if printer['gcode_macro START_PRINT'].prepare|int == 0 %}
# {action_respond_info("not prepare.\n")}
# PRINT_PREPARE_CLEAR
# CX_ROUGH_G28 EXTRUDER_TEMP={extruder_temp} BED_TEMP={bed_temp}
# CX_NOZZLE_CLEAR
# Z_SENSORLESS_SET
# ACCURATE_G28
# {% else %}
# PRINT_PREPARE_CLEAR
# {% endif %}
# CX_PRINT_DRAW_ONE_LINE
[gcode_macro PRINT_PREPARED]
gcode:
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=prepare VALUE=1
{action_respond_info("print prepared")}
[gcode_macro PRINT_PREPARE_CLEAR]
gcode:
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=prepare VALUE=0
[gcode_macro END_PRINT_POINT_WITHOUT_LIFTING]
gcode:
{% if "xyz" in printer.toolhead.homed_axes %}
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
G91
{% if printer.extruder.can_extrude|lower == 'true' %}
G1 E-1.0 F180
G1 E-{E} F4000
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
G1 Z2.0 F600
G90
{% set y_park = printer.toolhead.axis_maximum.y/2 %}
{% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %}
G1 X{x_park} Y{y_park} F12000
{% else %}
{action_respond_info("end print xyz_axes is NULL\n")}
{% endif %}
[gcode_macro END_PRINT_POINT]
gcode:
{% if "xyz" in printer.toolhead.homed_axes %}
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
{% set max_z = printer["gcode_macro PRINTER_PARAM"].max_z_position|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% set z_safe = 0.0 %}
{% if act_z < (max_z ) %}
{% set z_safe = (max_z ) - act_z %}
{% elif act_z < max_z %}
{% set z_safe = 2.0 %}
{% endif %}
G91
{% if printer.extruder.can_extrude|lower == 'true' %}
G1 E-1.0 F180
G1 E-{E} F4000
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
G1 Z2.0 F1200
G90
{% set y_park = printer.toolhead.axis_maximum.y|float - 2.0 %}
{% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %}
G1 X{x_park} Y144 F6000
{% if z_safe > 2.0 %}
G91
{% set z_safe = z_safe - 2.0 %}
G1 Z{z_safe} F1200
G90
{% endif %}
{% else %}
{action_respond_info("end print xyz_axes is NULL\n")}
{% endif %}
[gcode_macro END_SELF_TEST_POINT]
gcode:
{% if "xyz" in printer.toolhead.homed_axes %}
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
{% set max_z = printer["gcode_macro PRINTER_PARAM"].max_z_position|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% set z_safe = 0.0 %}
{% if act_z < (max_z ) %}
{% set z_safe = (max_z ) - act_z %}
{% elif act_z < max_z %}
{% set z_safe = 2.0 %}
{% endif %}
G91
G1 Z2.0 F1200
G90
{% if z_safe > 2.0 %}
G91
{% set z_safe = z_safe - 2.0 %}
G1 Z{z_safe} F1200
G90
{% endif %}
{% else %}
{action_respond_info("end print xyz_axes is NULL\n")}
{% endif %}
[gcode_macro END_PRINT]
description: Finaliza impresión
gcode:
SET_GCODE_VARIABLE MACRO=M106 VARIABLE=user_flag VALUE=0
Qmode_exit
EXCLUDE_OBJECT_RESET
PRINT_PREPARE_CLEAR
M220 S100
SET_VELOCITY_LIMIT ACCEL=5000 ACCEL_TO_DECEL=2500
TURN_OFF_HEATERS
M107 P1
M107 P2
END_PRINT_POINT
WAIT_TEMP_START
M84
SET_TEMPERATURE_FAN_TARGET temperature_fan=soc_fan target=45
[gcode_macro END_SELF_TEST]
gcode:
Qmode_exit
EXCLUDE_OBJECT_RESET
PRINT_PREPARE_CLEAR
M220 S100
SET_VELOCITY_LIMIT ACCEL=5000 ACCEL_TO_DECEL=2500
TURN_OFF_HEATERS
M107 P1
M107 P2
END_SELF_TEST_POINT
WAIT_TEMP_START
M84
SET_TEMPERATURE_FAN_TARGET temperature_fan=soc_fan target=45
[gcode_macro FIRST_FLOOR_PAUSE]
description: Pause the first floor print
# change this if you need more or less extrusion
variable_extrude: 2.0
gcode:
##### read E from pause macro #####
{% set E = printer["gcode_macro FIRST_FLOOR_PAUSE"].extrude|float %}
##### set park positon for x and y #####
# default is your max posion from your printer.cfg
{% set y_park = 5 %}
{% set x_park = 5 %}
##### calculate save lift position #####
{% set max_z = printer["gcode_macro PRINTER_PARAM"].max_z_position|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% set z_safe = 0.0 %}
{% if act_z < (max_z - 2.0) %}
{% set z_safe = 2.0 %}
{% elif act_z < max_z %}
{% set z_safe = max_z - act_z %}
{% endif %}
##### end of definitions #####
SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=z_safe_pause VALUE={z_safe|float}
PAUSE_BASE
G91
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer.extruder.can_extrude|lower == 'true' %}
G1 E-1.0 F180
G1 E-{E} F4000
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
G1 Z{z_safe} F600
G90
G1 X{x_park} Y{y_park} F12000
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
# save fan2 value and turn off fan2
SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=fan2_speed VALUE={printer['output_pin fan2'].value}
{% set fspeed = printer['gcode_macro PRINTER_PARAM'].fan2_speed %}
{action_respond_info("fan2_value = %s \n" % (fspeed))}
# SET_PIN PIN=fan2 VALUE=0
M106 P2 S0 G1
SET_E_MIN_CURRENT
[gcode_macro FIRST_FLOOR_RESUME]
description: Resume the first floor print
gcode:
RESTORE_E_CURRENT
{% if printer['gcode_macro PRINTER_PARAM'].fan2_speed > 0 %}
# {% set fspeed = printer['gcode_macro PRINTER_PARAM'].fan2_speed %}
# {action_respond_info("fan2_value2 = %s \n" % (fspeed))}
# SET_PIN PIN=fan2 VALUE={(printer['gcode_macro PRINTER_PARAM'].fan2_speed * 255 + 0.5)|int}
{% set s_value = (printer['gcode_macro PRINTER_PARAM'].fan2_speed * 255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) * 255 / (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min)|float %}
M106 P2 S{s_value} G1
{% endif %}
##### read E from pause macro #####
{% set E = printer["gcode_macro FIRST_FLOOR_PAUSE"].extrude|float + 1.0 %}
#### get VELOCITY parameter if specified ####
{% if 'VELOCITY' in params|upper %}
{% set get_params = ('VELOCITY=' + params.VELOCITY) %}
{%else %}
{% set get_params = "" %}
{% endif %}
##### end of definitions #####
{% if printer.extruder.can_extrude|lower == 'true' %}
G91
G1 E{E} F2100
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
M400
RESUME_BASE {get_params}
[gcode_macro PAUSE]
description: Pausa impresión actual
rename_existing: PAUSE_BASE
# change this if you need more or less extrusion
variable_extrude: 2.0
gcode:
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
##### set park positon for x and y #####
# default is your max posion from your printer.cfg
{% set y_park = printer.toolhead.axis_maximum.y/2 %}
{% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %}
##### calculate save lift position #####
{% set max_z = printer["gcode_macro PRINTER_PARAM"].max_z_position|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% set z_safe = 0.0 %}
{% if act_z < 48.0 %}
{% set z_safe = 50.0 - act_z %}
{% elif act_z < (max_z - 2.0) %}
{% set z_safe = 2.0 %}
{% elif act_z < max_z %}
{% set z_safe = max_z - act_z %}
{% endif %}
{action_respond_info("z_safe = %s"% (z_safe))}
##### end of definitions #####
SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=z_safe_pause VALUE={z_safe|float}
PAUSE_BASE
G91
SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=hotend_temp VALUE={printer.extruder.target}
M104 S140
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer.extruder.can_extrude|lower == 'true' %}
G1 E-1.0 F180
G1 E-{E} F4000
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
G1 Z{z_safe} F600
M400
G90
G1 X{x_park} Y{y_park} F12000
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
# save fan2 value and turn off fan2
SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=fan2_speed VALUE={printer['output_pin fan2'].value}
{% set fspeed = printer['gcode_macro PRINTER_PARAM'].fan2_speed %}
{action_respond_info("fan2_value = %s \n" % (fspeed))}
# SET_PIN PIN=fan2 VALUE=0
M106 P2 S0 G1
SET_E_MIN_CURRENT
[gcode_macro INPUTSHAPER]
gcode:
SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=0
#SET_FILAMENT_SENSOR SENSOR=filament_sensor_2 ENABLE=0
SET_TEMPERATURE_FAN_TARGET temperature_fan=soc_fan target=5
G90
G28
{% set POSITION_X = printer.configfile.settings['stepper_x'].position_max/2 %}
{% set POSITION_Y = printer.configfile.settings['stepper_y'].position_max/2 %}
G1 X{POSITION_X} Y{POSITION_Y} F6000
G1 Z20 F1200
SHAPER_CALIBRATE
CXSAVE_CONFIG
SET_TEMPERATURE_FAN_TARGET temperature_fan=soc_fan target=45
SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=1
#SET_FILAMENT_SENSOR SENSOR=filament_sensor_2 ENABLE=1
[gcode_macro BEDPID]
description: PID de cama
gcode:
PID_CALIBRATE HEATER=heater_bed TARGET=100
SAVE_CONFIG
[gcode_macro TUNOFFINPUTSHAPER]
description: Apaga INPUT SHAPER
gcode:
SET_INPUT_SHAPER SHAPER_FREQ_X=0 SHAPER_FREQ_Y=0
#[gcode_macro RESUME]
#description: Resume the actual running print
#rename_existing: RESUME_BASE
#gcode:
# RESTORE_E_CURRENT
# {% if printer['gcode_macro PRINTER_PARAM'].hotend_temp|int != 0 %}
# {% if printer['gcode_macro PRINTER_PARAM'].hotend_temp|int > printer.extruder.temperature %}
# M109 S{printer['gcode_macro PRINTER_PARAM'].hotend_temp|int}
# {% else %}
# M104 S{printer['gcode_macro PRINTER_PARAM'].hotend_temp|int}
# {% endif %}
# SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=hotend_temp VALUE=0
# {% endif %}
# {% if printer['gcode_macro PRINTER_PARAM'].fan2_speed > 0 %}
# # {% set fspeed = printer['gcode_macro PRINTER_PARAM'].fan2_speed %}
# # {action_respond_info("fan2_value2 = %s \n" % (fspeed))}
# # SET_PIN PIN=fan2 VALUE={(printer['gcode_macro PRINTER_PARAM'].fan2_speed * 255 + 0.5)|int}
# {% set s_value = (printer['gcode_macro PRINTER_PARAM'].fan2_speed * 255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) * 255 / (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min)|float %}
# M106 P2 S{s_value} G1
# {% endif %}
# {% set z_resume_move = printer['gcode_macro PRINTER_PARAM'].z_safe_pause|int %}
# {% if z_resume_move > 2 %}
# {% set z_resume_move = z_resume_move - 2 %}
# G91
# G1 Z-{z_resume_move} F600
# M400
# {% endif %}
# {action_respond_info("z_resume_move = %s"% (z_resume_move))}
# ##### read E from pause macro #####
# {% set E = printer["gcode_macro PAUSE"].extrude|float + 1.0 %}
# #### get VELOCITY parameter if specified ####
# {% if 'VELOCITY' in params|upper %}
# {% set get_params = ('VELOCITY=' + params.VELOCITY) %}
# {%else %}
# {% set get_params = "" %}
# {% endif %}
# ##### end of definitions #####
# {% if printer.extruder.can_extrude|lower == 'true' %}
# G91
# G1 E{E} F2100
# G90
# {% else %}
# {action_respond_info("Extruder not hot enough")}
# {% endif %}
# M400
# RESUME_BASE {get_params}
[gcode_macro CANCEL_PRINT]
description: Cancela impresión actual
rename_existing: CANCEL_PRINT_BASE
gcode:
END_PRINT
CANCEL_PRINT_BASE
[gcode_macro G29]
gcode:
{% if 'PROBE_COUNT' in params|upper %}
{% set get_count = ('PROBE_COUNT' + params.PROBE_COUNT) %}
{%else %}
{% set get_count = "" %}
{% endif %}
{% set bed_temp = printer.custom_macro.default_bed_temp %}
{% set extruder_temp = printer.custom_macro.g28_ext_temp %}
{% set nozzle_clear_temp = printer.custom_macro.default_extruder_temp %}
{% if 'BED_TEMP' in params|upper %}
{% set bed_temp = params.BED_TEMP %}
{% endif %}
{% if 'EXTRUDER_TEMP' in params|upper %}
{% set nozzle_clear_temp = params.EXTRUDER_TEMP %}
{% endif %}
SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=0
#SET_FILAMENT_SENSOR SENSOR=filament_sensor_2 ENABLE=0
SET_TEMPERATURE_FAN_TARGET temperature_fan=soc_fan target=5
M109 S140
G28
BED_MESH_CLEAR
NOZZLE_CLEAR HOT_MIN_TEMP={extruder_temp} HOT_MAX_TEMP={nozzle_clear_temp} BED_MAX_TEMP={bed_temp}
M204 S5000
SET_VELOCITY_LIMIT ACCEL_TO_DECEL=5000
BED_MESH_CALIBRATE {get_count}
BED_MESH_OUTPUT
{% set y_park = printer.toolhead.axis_maximum.y/2 %}
{% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %}
G1 Z50 F3600
CXSAVE_CONFIG
TURN_OFF_HEATERS
SET_TEMPERATURE_FAN_TARGET temperature_fan=soc_fan target=45
SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=1
#SET_FILAMENT_SENSOR SENSOR=filament_sensor_2 ENABLE=1
# [gcode_macro G299]
# gcode:
# BED_MESH_CLEAR
# G28
# PRTOUCH_READY
# BED_MESH_CALIBRATE
# BED_MESH_OUTPUT