-
Notifications
You must be signed in to change notification settings - Fork 4
/
filament.cfg
190 lines (167 loc) · 7.32 KB
/
filament.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
[gcode_macro SET_FILAMENT]
variable_filament_type: "PETG_SOVETOV"
variable_nozzle_diameter: 0.4
gcode:
{% if "NOZZLE" in params %}
{% set nozzle_diameter = params.NOZZLE|float %}
{% endif %}
{% if "TYPE" in params %}
{% set filament_type = params.TYPE|upper %}
{% endif %}
RESET_VELOCITY
RESET_PRESSURE_ADVANCE
M118 SET_FILAMENT {filament_type} NOZZLE {nozzle_diameter}
SET_GCODE_VARIABLE MACRO=SET_FILAMENT VARIABLE=nozzle_diameter VALUE={nozzle_diameter}
SET_GCODE_VARIABLE MACRO=SET_FILAMENT VARIABLE=filament_type VALUE='"{filament_type}"'
{% set filament = "filament_" + filament_type|lower + "_" + nozzle_diameter|string %}
{% set params = printer.save_variables.variables[filament] %}
{% if 'pressure_advance' in params %}
{% set filament_pa = params.pressure_advance %}
M118 PRESSURE_ADVANCE: {filament_pa}
SET_PRESSURE_ADVANCE ADVANCE={filament_pa}
{% else %}
M118 NOTICE: PRESSURE_ADVANCE config is missing!
{% endif %}
{% if 'smooth_time' in params %}
{% set filament_st = params.smooth_time %}
M118 SMOOTH_TIME: {filament_st}
SET_PRESSURE_ADVANCE SMOOTH_TIME={filament_st}
{% else %}
M118 NOTICE: SMOOTH_TIME config is missing!
{% endif %}
{% if 'retract_length' in params %}
{% set filament_rl = params.retract_length %}
M118 RETRACT_LENGTH: {filament_rl}
SET_RETRACTION RETRACT_LENGTH={filament_rl}
{% else %}
M118 NOTICE: RETRACT_LENGTH config is missing!
{% endif %}
{% if 'retract_speed' in params %}
{% set filament_rs = params.retract_speed %}
M118 RETRACT_SPEED: {filament_rs}
SET_RETRACTION RETRACT_SPEED={filament_rs}
{% else %}
M118 NOTICE: RETRACT_SPEED config is missing!
{% endif %}
{% if 'unretract_speed' in params %}
{% set filament_us = params.unretract_speed %}
M118 UNRETRACT_SPEED: {filament_us}
SET_RETRACTION UNRETRACT_SPEED={filament_us}
{% else %}
M118 NOTICE: UNRETRACT_SPEED config is missing!
{% endif %}
{% if 'diameter' in params %}
{% set filament_dia = params.diameter %}
M118 DIAMETER: {filament_dia}
SET_FILAMENT_DIAMETER DIAMETER={filament_dia}
{% else %}
M118 NOTICE: DIAMETER config is missing!
{% endif %}
[gcode_macro SAVE_FILAMENT_PARAMS]
gcode:
{% set cur_filament_type = printer["gcode_macro SET_FILAMENT"].filament_type %}
{% set filament_type = params.TYPE|default(cur_filament_type) %}
{% if filament_type == "cur_filament_type" %}
{% set filament_type = cur_filament_type %}
{% endif %}
{% set cur_nozzle_diameter = printer["gcode_macro SET_FILAMENT"].nozzle_diameter %}
{% set nozzle_diameter = params.NOZZLE|default(cur_nozzle_diameter)|float %}
{% if nozzle_diameter == "cur_nozzle_diameter" %}
{% set nozzle_diameter = cur_nozzle_diameter %}
{% endif %}
{% set nominal_diameter = printer["gcode_macro START_PRINT"].filament_diameter|float %}
{% set flow = printer.gcode_move.extrude_factor %}
{% set filament_diameter = (nominal_diameter**2 / flow) ** 0.5 %}
{% set filament_diameter = "%.2f"|format(filament_diameter)|float %}
M118 FILAMENT_TYPE: {filament_type}
M118 NOZZLE: {nozzle_diameter}
M118 PRESSURE_ADVANCE: {printer.extruder.pressure_advance}
M118 SMOOTH_TIME: {printer.extruder.smooth_time}
M118 RETRACT_LENGTH: {printer.firmware_retraction.retract_length}
M118 RETRACT_SPEED: {printer.firmware_retraction.retract_speed}
M118 UNRETRACT_SPEED: {printer.firmware_retraction.unretract_speed}
M118 DIAMETER: {filament_diameter}
{% set filament = "filament_" + filament_type|lower + "_" + nozzle_diameter|string %}
RESPOND PREFIX="SAVE_VARIABLE:" MSG="{filament}"
SAVE_VARIABLE VARIABLE="{filament}" VALUE="{{ 'pressure_advance': printer.extruder.pressure_advance, 'smooth_time': printer.extruder.smooth_time, 'retract_length': printer.firmware_retraction.retract_length, 'retract_speed': printer.firmware_retraction.retract_speed|int, 'unretract_speed': printer.firmware_retraction.unretract_speed|int, 'diameter': filament_diameter }}"
[gcode_macro GET_FILAMENT_PARAMS]
gcode:
{% set cur_filament_type = printer["gcode_macro SET_FILAMENT"].filament_type %}
{% set filament_type = params.TYPE|default(cur_filament_type) %}
{% if filament_type == "cur_filament_type" %}
{% set filament_type = cur_filament_type %}
{% endif %}
{% set cur_nozzle_diameter = printer["gcode_macro SET_FILAMENT"].nozzle_diameter %}
{% set nozzle_diameter = params.NOZZLE|default(cur_nozzle_diameter)|float %}
{% if nozzle_diameter == "cur_nozzle_diameter" %}
{% set nozzle_diameter = cur_nozzle_diameter %}
{% endif %}
{% set filament = "filament_" + filament_type|lower + "_" + nozzle_diameter|string %}
{% set params = printer.save_variables.variables[filament] %}
M118 {filament_type} PARAMS:
M118 nozzle_diameter: {nozzle_diameter}
{% set filament_pa = params.pressure_advance %}
M118 PRESSURE_ADVANCE: {filament_pa}
{% set filament_st = params.smooth_time %}
M118 SMOOTH_TIME: {filament_st}
{% set filament_rl = params.retract_length %}
M118 RETRACT_LENGTH: {filament_rl}
{% set rs_name = filament_prefix + "_rs" %}
{% set filament_rs = params.retract_speed %}
M118 RETRACT_SPEED: {filament_rs}
{% set filament_us = params.unretract_speed %}
M118 UNRETRACT_SPEED: {filament_us}
{% set filament_dia = params.diameter %}
M118 DIAMETER: {filament_dia}
[gcode_macro RESET_VELOCITY]
gcode:
{% set config_accel = printer.configfile.config.printer.max_accel|int %}
{% set config_decel = printer.configfile.config.printer.max_accel_to_decel|int %}
{% set config_velocity = printer.configfile.config.printer.max_velocity|int %}
SET_VELOCITY_LIMIT ACCEL={config_accel} ACCEL_TO_DECEL={config_decel} VELOCITY={config_velocity}
[gcode_macro RESET_PRESSURE_ADVANCE]
gcode:
{% set pa = printer.configfile.config.extruder.pressure_advance|float %}
{% set st = printer.configfile.config.extruder.pressure_advance_smooth_time|float %}
SET_PRESSURE_ADVANCE ADVANCE={pa} SMOOTH_TIME={st}
[gcode_macro FILAMENT_CHANGE]
gcode:
RESPOND PREFIX=tgalarm MSG="Filament change. Print paused!"
PAUSE
[gcode_macro FILAMENT_LOAD_RESUME]
gcode:
FILAMENT_LOAD
RESUME
[gcode_macro FILAMENT_UNLOAD_HEAT]
gcode:
{% set temp = params.TEMP|default(250) %}
PREHEAT HEATER=extruder TARGET={temp}
FILAMENT_UNLOAD
M104 S0
[gcode_macro FILAMENT_LOAD_HEAT]
gcode:
{% set temp = params.TEMP|default(250) %}
PREHEAT HEATER=extruder TARGET={temp}
FILAMENT_LOAD
M104 S0
[gcode_macro SET_FILAMENT_DIAMETER]
gcode:
{% set filament_diameter = params.DIAMETER|default(1.75)|float %}
{% set nominal_diameter = printer["gcode_macro START_PRINT"].filament_diameter|float %}
{% set ratio = "%.2f"|format(nominal_diameter**2 / filament_diameter**2 * 100) %}
M221 S{ratio}
[gcode_macro CALCULATE_DIAMETER]
gcode:
{% set nominal_diameter = printer["gcode_macro START_PRINT"].filament_diameter|float %}
{% set flow = printer.gcode_move.extrude_factor %}
{% set diameter = (nominal_diameter**2 / flow) ** 0.5 %}
{% set diameter = "%.2f"|format(diameter) %}
RESPOND MSG="DIAMETER: {diameter}"
[gcode_macro PREHEAT]
gcode:
{% set heater = params.HEATER|default(extruder) %}
{% set target = params.TARGET|default(250)|int %}
SET_HEATER_TEMPERATURE HEATER={heater} TARGET={target}
TEMPERATURE_WAIT SENSOR={heater} MINIMUM={params.MIN|default(target)} MAXIMUM={params.MAX|default(target+1)}
{% set klipperscreen_hack = params.MIN|default(250) %}
{% set klipperscreen_hack = params.TYPE|default(251) %}