-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathvariable_setup.cfg
322 lines (287 loc) · 19.5 KB
/
variable_setup.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
### My variables copy from zellneralex setup
[delayed_gcode _INIT]
initial_duration: 1
gcode:
_USER_VARIABLE
_EXECUTE_AT_INIT
#CASELIGHT_STANDBY
#STATUS_READY
LED_STANDBY
#UPDATE_DELAYED_GCODE ID=led_sleep DURATION=7200 ; Set to turn off LEDs after 2 hours of inactivity
[gcode_macro _EXECUTE_AT_INIT]
description: Helper: Macros to run at Klipper boot
gcode:
{% set user = printer['gcode_macro _USER_VARIABLE'] %}
[gcode_macro _USER_VARIABLE]
description: Helper: Contains user defined printer variables
## catalog instantiations
variable_filament: {}
variable_homing: {}
variable_hw: {}
variable_park: {}
variable_peripheral: {}
variable_prime: {}
variable_print_start: {}
variable_probe: {}
variable_purge: {}
variable_respond: {}
variable_run: False
variable_speed: {}
variable_unload_sd: False
variable_z_hop: 0
gcode:
################################################################################
### User defines ###
################################################################################
##### Endstops #####
{% set user_z_endstop_xy = [142.0,260.0] %} # Z endstop position from safe_z_home/home_xy_position
{% set user_z_endstop_hop = 5.0 %} # Z hop for moves (e.g., homing) from safe_z_home/z_hop
{% set user_z_home_current = 0.3 %} # Reduced homing current for z from zellneralex setting
{% set user_home_accel = 1200 %} # Reduced ACCEL for homing from zellneralex setting
{% set user_bed_y_offset = 5 %} # Endstop offset to bed max y from zellneralex setting --where is this used?
##### User defined speeds (mm/sec) #####
{% set user_z_hop_speed = 15 %} # Default z hop speed from zellneralex setting
{% set user_retract_speed = 30 %} # Default retract/extrude speed from zellneralex setting
{% set user_travel_speed = 500 %} # Travel speed (e.g., park, dock, etc.) zellneralex setting (300), bumped up to 1/2 max capability
{% set user_probe_dock_speed = 50 %} # Dock speed for attach/dock from klicky_variables (default)
{% set user_filament_load_speed = 50 %} # Load/unload speed from zellneralex setting
{% set user_wipe_speed = 90 %} # Wipe move speed approximated from original mod macro (5000)
{% set user_prime_speed = 25 %} # Prime line speed from zellneralex setting
##### Klicky Probe #####
{% set user_probe_dock_pos = [36.0,260.0] %} # Position of the dock from klicky_variables/variable_docklocation_N
{% set user_probe_delta_x = 40 %} # X offset for position before dock from klicky_variables/variable_dockmove_x (is this right? double check)
{% set user_probe_delta_y = -30 %} # Y offset to move probe out of dock from zellneralex setting (I think it is klicky_variables/variable_attachmove_y)
{% set user_z_probe_hop = 15.5 %} # Z minimum height to avoid crash from zellneralex setting (should it be variable_safe_z = 25?)
# {% set user_z_probe_hop = 25.5 %} # Z minimum height to avoid crash from zellneralex setting (increased for UnKlicky)
##### Park Position #####
## Note these are used below in calculating the calc_park values.
{% set user_park_xy_delta = 25 %} # Distance for X or Y from the edge from zellneralex setting
{% set user_park_z_max_delta = 40 %} # Ensure to not hit cam in front from zellneralex setting (my camera won't interfere, I can reduce this value)
{% set user_park_z_min = 30 %} # Minimum Z distance from bed from zellneralex setting
{% set user_park_pause_z_delta = 2.0 %} # Distance to increase head while Pause/Cancel Print from zellneralex setting
{% set user_park_at_cancel = False %} # Park head at CANCEL_PRINT if not paused from zellneralex setting
##### Filament #####
{% set user_extruder_min_add = 30 %} # Temperature to add to min extruder temp from zellneralex setting
{% set user_load_distance = 65 %} # Load distance while loading filament from my measurements (50mm max for Klipper, need another 15mm, add in extrude)
{% set user_load_extrude = 35 %} # Extrude distance while loading filament from my measurements (Final 25mm)
{% set user_unload_distance = 75 %} # Unload distance while unloading filament from my own measurements
{% set user_retract_end = 18 %} # Retract distance at PRINT_END or CANCEL_PRINT reduced from 18mm to 10mm, from E3D suggestion for easy nozzle swaps (https://e3d-online.zendesk.com/hc/en-us/articles/4406857421213-Start-and-End-G-code-for-faster-nozzle-changes)
{% set user_retract_pause = 3 %} # Retract/extrude distance for PAUSE or RESUME from my own tuning measurements
##### Purge Bucket & Nozzle Brush ######
{% set user_brush_pos = 'right' %} # Left/right profile used from my own settings
{% set user_brush_x_middle = 189.5 %} # Midpoint of brush at right profile calc from nozzle_scrub/variable_brush_start+variable_brush_width [172+(35/2)]
{% set user_brush_x_width = 40.0 %} # Width of brush from nozzle_scrub/variable_brush_width
{% set user_brush_y_start = 260.0 %} # Start point at Y guesstimate from my bed size & his setting
{% set user_wipe_z = 4 %} # Z for wipe moves from nozzle_scrub/variable_brush_top (new cal)
# {% set user_wipe_z = 0 %} # Z for wipe moves from nozzle_scrub/variable_brush_top (new cal) (0 for UnKlicky)
{% set user_wipe_cnt = 4 %} # Number of complete wipes from nozzle_scrub/variable_wipe_qty
{% set user_z_purge = 7 %} # Z above purge bucket my setting (7 for Klicky)
# {% set user_z_purge = 0 %} # Z above purge bucket my setting (0 for UnKlicky)
##### PRINT_START/STOP ######
{% set user_print_start_bed_up = 10 %} # Bed temp raise for faster heat soak from zellneralex setting (do I want to use this?)
{% set user_print_start_ival = 1 %} # Wait time per call in sec from zellneralex setting (what for? analyze)
{% set user_print_start_extruder_time = 3 %} # Mins before soak end to start extruder heating from zellneralex setting (what for? analyze)
{% set user_print_start_bed_time = 3 %} # Mins before soak end to set bed target temp from zellneralex setting (what for? analyze)
{% set user_print_start_prime_mult = 2 %} # Multiplier for prime line height from zellneralex setting
{% set user_unload_sd = False %} # Unload SD card at PRINT_END or CANCEL_PRINT I set to false
##### Prime Line #####
{% set user_prime_start_xy = [245.0,30.0] %} # XY start coordinates of prime line my setting (start front right)
{% set user_prime_z = 0.28 %} # Default prime layer height from zellneralex setting
{% set user_prime_dir = 'Y+' %} # Direction of prime line [X+, X-, Y+, Y-] from zellneralex setting
{% set user_prime_spacing = 0.4 %} # Dist between line, move always positive from zellneralex setting
{% set user_prime_length = 220 %} # Length of prime line from zellneralex setting
{% set user_prime_seg = 11 %} # Segments the prime line is split into from zellneralex setting
{% set user_prime_extruder_per_seg = 2.0 %} # Amount of filament extruded per segment from zellneralex setting
##### Respond Defaults #####
{% set user_respond_set_z_current = 0 %} # Macro _SET_Z_CURRENT from zellneralex setting
{% set user_respond_set_acc = 0 %} # Macro _SET_ACC from zellneralex setting
{% set user_respond_probe_action = 1 %} # Macro _PROBE_ACTION from zellneralex setting
{% set user_respond_layer = 0 %} # Macro _LAYER from zellneralex setting
##### Peripheral ######
{% set user_filer_on = 0.5 %} # Filter on value from zellneralex setting (what for? analyze)
{% set user_filter_use_time = 80 %} # Nevermore change warning limit from zellneralex setting (what for? analyze)
{% set user_vent_on = 25 %} # Chamber fan on temperature (check vs case probe?) reset from zellneralex setting (15)
{% set user_fan_run_after_print = 30 %} # Mins to run filter & exhaust after print from zellneralex setting (what for? analyze)
# {% set user_caselight_on = 0.4 %} # Caselight on value from zellneralex setting (what for? analyze)
##### End of variable definitions #####
##### Get Printer Limits & Cfg Value #####
{% set min = printer['toolhead'].axis_minimum %}
{% set max = printer['toolhead'].axis_maximum %}
{% set cfg_endstop_z_offset = printer.configfile.settings.stepper_z_position_endstop|default(0.0)|float %}
##### Set up hardware dictionary (detect hardware) #####
## Note: much of this I think I can ignore/eliminate?
{% set hw_dic = {'display' : {'ena' : True if 'neopixel neo_display' in printer.configfile.settings
else False},
'chamber' : {'type': 'sensor' if 'temperature_sensor chamber_temp' in printer.configfile.settings
else 'fan' if 'temperature_fan chamber' in printer.configfile.settings
else 'none'},
# 'caselight' : {'ena' : True if 'neopixel caselight' in printer.configfile.settings
# else False},
'filter' : {'ena' : True if 'fan_generic nevermore' in printer.configfile.settings
else False},
'runout' : {'type': 'switch' if 'filament_switch_sensor runout' in printer.configfile.settings
else 'motion' if 'filament_motion_sensor runout' in printer.configfile.settings
else 'file' if 'save_variables' in printer and filament_loaded in printer.save_variables.variables
else 'none'},
# 'relay' : {'ena' : True if 'output_pin extruder_relay' in printer.configfile.settings and
# 'output_pin heater_bed_relay' in printer.configfile.settings
# else False},
'auto_z_offset' : {'type': 'z_calib+flexplate' if 'z_calibration' in printer and 'save_variables' in printer and 'plates' in printer.save_variables.variables
else 'z_calib' if 'z_calibration' in printer
else 'flexplate' if 'save_variables' in printer and 'plates' in printer.save_variables.variables
else 'none'},
# 'mag_probe' : {'ena' : True if printer['gcode_macro _MAG_PROBE'] is defined or 'dockable_probe' in printer
# else False},
# Change lookup to standard Klicky macro name--at least until I rewrite
'mag_probe' : {'ena' : True if printer['gcode_macro Attach_Probe'] is defined or 'dockable_probe' in printer
else False},
# 'endstop_temp' : {'ena' : True if 'temperature_sensor endstop' in printer.configfile.settings
# else False}
}
%}
# This gives an object model of:
# hw_dic.display.ena ## I think I can eliminate this? His front panel?
# hw_dic.chamber.type ## Reset to my defs. I have both sensor and fan
# hw_dic.caselight.ena ## Reset to my def for caselights
# hw_dic.filter.ena ## For exhaust fan and Nevermore, ignore until those are set up
# hw_dic.runout.type ## Ignore until I add a filament sensor
# hw_dic.relay.ena #### Safely ignore, I'm not adding fancy power relays
# hw_dic.auto_z_offset.type ## definitely use this, Klicky probe protoloft auto z
# hw_dic.mag_probe.ena ## Klicky probe, make sure definitions match
# hw_dic.endstop.temp #### I think I can ignore this. Not sure what he has going on
##### Load hw_dic object
{% set _dummy = hw_dic.chamber.update({'ena': True if hw_dic.chamber.type != 'none' else False}) %}
{% set _dummy = hw_dic.chamber.update({'fan': True if hw_dic.chamber.type == 'fan' else False}) %}
{% set _dummy = hw_dic.runout.update({'ena': True if hw_dic.runout.type != 'none' else False}) %}
{% set _dummy = hw_dic.runout.update({'sensor': True if hw_dic.runout.type == 'switch' or hw_dic.runout.type == 'motion' else False}) %}
{% set _dummy = hw_dic.auto_z_offset.update({'ena': True if hw_dic.auto_z_offset.type != 'none' else False}) %}
{% set _dummy = hw_dic.auto_z_offset.update({'auto': True if hw_dic.auto_z_offset.type == 'z_calib+flexplate' or
hw_dic.auto_z_offset.type == 'z_calib'
else False}) %}
{% set _dummy = hw_dic.auto_z_offset.update({'manu': True if hw_dic.auto_z_offset.type == 'z_calib+flexplate' or
hw_dic.auto_z_offset.type == 'z_calib'
else False}) %}
##### Calculate needed values #####
{% set bed = {'min' : {'x': min.x, 'y': min.y, 'z': 0},
'max': {'x': max.x, 'y': max.y - user_bed_y_offset, 'z': max.x}}
%}
{% set calc_center = {'x': (bed.max.x - bed.min.x) / 2,
'y': (bed.max.y - bed.min.y) / 2,
'z': (bed.max.z - bed.min.z) / 2}
%}
{% set calc_park = {'min': {'x': bed.min.x + user_park_xy_delta,
'y': bed.min.y + user_park_xy_delta,
'z': bed.min.z + user_park_z_min},
'max': {'x': bed.max.x - user_park_xy_delta,
'y': bed.max.y - user_park_xy_delta,
'z': bed.max.z - user_park_z_max_delta}}
%}
{% set calc_z_endstop_z = cfg_endstop_z_offset|round(0, 'ceil') + 1.0 if cfg_endstop_z_offset > 0 else 1.0 %}
{% set calc_z_hop = user_z_probe_hop if hw_dic.mag_probe.ena and user_z_probe_hop > user_z_endstop_hop
else user_z_endstop_hop %}
{% set calc_brush = {'start': user_brush_x_middle - user_brush_x_width / 2,
'end' : user_brush_x_middle + user_brush_x_width / 2}
%}
{% set calc_purge = {'x': (min.x + calc_brush.start) / 2 if user_brush_pos|lower == 'left'
else max.x - (max.x - calc_brush.end) / 2,
'y': max.y}
%}
{% set calc_wipe = {'start': {'x': calc_brush.start if user_brush_pos|lower == 'left'
else calc_brush.end,
'y': user_brush_y_start},
'end': {'x': calc_brush.end if user_brush_pos|lower == 'left'
else calc_brush.start,
'y': max.y}}
%}
##### Prepare dictionaries #####
# For homing operations
{% set homing_dic = {'z_endstop': {'x': user_z_endstop_xy[0], 'y': user_z_endstop_xy[1], 'z': calc_z_endstop_z, 'hop': user_z_endstop_hop},
'z_current': user_z_home_current,
'accel' : user_home_accel}
%}
# For nozzle_clean
{% set purge_dic = {'purge': {'x': calc_purge.x, 'y': calc_purge.y, 'z': user_z_purge},
'wipe' : {'start' : {'x': calc_wipe.start.x, 'y': calc_wipe.start.y, 'z': user_wipe_z},
'end' : {'x': calc_wipe.end.x, 'y': calc_wipe.end.y, 'z': user_wipe_z},
'offset': (calc_wipe.end.y - calc_wipe.start.y) / user_wipe_cnt,
'cnt' : user_wipe_cnt}}
%}
# For Klicky probe
{% set probe_dic = {'dock' : {'x': user_probe_dock_pos[0],
'y': user_probe_dock_pos[1] + user_probe_delta_y},
'store' : {'x': user_probe_dock_pos[0] + user_probe_delta_x,
'y': user_probe_dock_pos[1]}}
%}
# General machine move speeds
{% set speed_dic = {'z_hop' : (user_z_hop_speed * 60),
'retract' : (user_retract_speed * 60),
'travel' : (user_travel_speed * 60),
'dock' : (user_probe_dock_speed * 60),
'load' : (user_filament_load_speed * 60),
'wipe' : (user_wipe_speed * 60),
'prime' : (user_prime_speed * 60)}
%}
# Park positions
{% set park_dic = {'bed' : {'x': calc_center.x, 'y': calc_center.y, 'z': calc_park.min.z},
'center' : {'x': calc_center.x, 'y': calc_center.y, 'z': calc_center.z},
'frontlow' : {'x': calc_center.x, 'y': calc_park.min.y, 'z': calc_park.max.z},
'front' : {'x': calc_center.x, 'y': calc_park.min.y, 'z': calc_park.min.z},
'rear' : {'x': calc_park.min.x, 'y': calc_park.max.y, 'z': calc_park.max.z},
'pause' : {'x': calc_purge.x, 'y': calc_purge.y, 'z': user_park_pause_z_delta},
'park_at_cancel' : user_park_at_cancel}
%}
# Filament Loading, Unloading, and anti-drool retraction
{% set filament_dic = {'load_distance' : user_load_distance,
'load_extrude' : user_load_extrude,
'unload_distance' : user_unload_distance,
'retract' : {'end' : user_retract_end,
'pause' : user_retract_pause,
'cancel': user_retract_end - user_retract_pause}}
%}
# Prime line settings (PRINT_START)
{% set prime_dic = {'pos' : {'x': user_prime_start_xy[0], 'y': user_prime_start_xy[1], 'z': user_prime_z},
'dir' : user_prime_dir,
'spacing' : user_prime_spacing,
'length_per_seg' : user_prime_length / user_prime_seg,
'seg' : user_prime_seg,
'extrude_per_seg' : user_prime_extruder_per_seg}
%}
# PRINT_START settings
{% set print_start_dic = {'bed_up' : user_print_start_bed_up|float|round(1),
'ival' : user_print_start_ival|int,
'time' : {'extruder': (user_print_start_extruder_time * 60)|int,
'bed' : (user_print_start_bed_time * 60)|int},
'prime_mult' : user_print_start_prime_mult|float}
%}
# Respond settings (what is this actually for?)
{% set respond_dic = {'z_current' : user_respond_set_z_current,
'acc' : user_respond_set_acc,
'probe_action': user_respond_probe_action,
'layer' : user_respond_layer}
%}
# Peripherals setup. I can mostly ignore I think
{% set peripherals_dic = {'vent' : {'on_val' : user_vent_on,
'run_after_print' : ((user_fan_run_after_print *60) +5)}
}
%}
# {% set peripherals_dic = {'filter' : {'on_val' : user_filter_on,
# 'warning' : user_filter_use_time,
# 'run_after_print' : (user_fan_run_after_print * 60)},
# 'vent' : {'on_val' : user_vent_on,
# 'run_after_print' : ((user_fan_run_after_print * 60) + 5)}}
# %}
##### Store dictionaries in easy-to-reference variables
SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=hw VALUE="{hw_dic}"
SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=homing VALUE="{homing_dic}"
SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=z_hop VALUE={calc_z_hop}
SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=speed VALUE="{speed_dic}"
SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=probe VALUE="{probe_dic}"
SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=park VALUE="{park_dic}"
SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=filament VALUE="{filament_dic}"
SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=purge VALUE="{purge_dic}"
SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=print_start VALUE="{print_start_dic}"
SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=unload_sd VALUE={user_unload_sd}
SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=prime VALUE="{prime_dic}"
SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=respond VALUE="{respond_dic}"
SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=peripheral VALUE="{peripherals_dic}"
SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=run VALUE=True