forked from viesturz/klipper-toolchanger
-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
toolchanger-leds.cfg
305 lines (272 loc) · 12.3 KB
/
toolchanger-leds.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
# Macros for setting the status leds on the toolhead (or for any neopixel-type leds).
#
# You will need to configure a neopixel (or other addressable led, such as dotstar). See
# https://www.klipper3d.org/Config_Reference.html#neopixel for configuration details.
#####################################
# INSTRUCTIONS #
#####################################
# How to use all this stuff:
#
# 1. Copy this .cfg file into your Klipper config directory and then add [include toolchanger_leds.cfg]
# to the top of your printer.cfg in order to register the LEDs and macros with Klipper.
# 2. Define your LEDs by editing [neopixel Tn_leds] where n is the tool number in each tool config, example below
#
# Note: RGB and RGBW are different and must be defined explicitly. RGB and RGBW are also not able to
# be mix-and-matched in the same chain. A separate data line would be needed for proper functioning.
#
# RGBW LEDs will have a visible yellow-ish phosphor section to the chip. If your LEDs do not have
# this yellow portion, you have RGB LEDs.
#
# 3. Save your config and restart Klipper.
#
# Note: We set RED and BLUE to 1.0 to make it easier for users and supporters to detect
# misconfigurations or miswiring. The default color format is for Neopixels with a dedicated
# white LED. On startup, all LEDs should light up.
#
# If you get random colors across your LEDs, change the color_order to GRB and restart. Then
# omit the W for each suggested color_order in the next paragraph.
#
# If you get MAGENTA, your color order is correct. If you get CYAN, you need to use RGBW. If
# you get YELLOW, you need to use BRGW (note that BRG is only supported in the latest Klipper
# version).
#
# 4. Once you have confirmed that the LEDs are set up correctly, you must now decide where you want
# these macros called up...which means adding them to your existing gcode macros. NOTHING will happen
# unless you add the STATUS_????? macros to your existing gcode macros.
#
# Example: add STATUS_LEVELING to the beginning of your QGL gcode macro, and then add STATUS_READY
# to the end of it to set the logo LED and nozzle LEDs back to the `ready` state.
#
# Example: add STATUS_CLEANING to the beginning of your nozzle-cleaning macro, and then STATUS_READY
# to the end of it to return the LEDs back to `ready` state.
#
# 5. Feel free to change colors of each macro, create new ones if you have a need to. The macros provided below
# are just an example of what is possible. If you want to try some more complex animations, you will most
# likely have to use WLED with Moonraker and a small micro-controller
#
#####################################
# END INSTRUCTRUCTIONS #
#####################################
#[neopixel T0_leds]
#pin: sb2040-1:gpio12
# The pin connected to the neopixel. This parameter must be provided.
#chain_count: 3
# The number of Neopixel chips that are "daisy chained" to the
# provided pin. The default is 1 (which indicates only a single
# Neopixel is connected to the pin).
#color_order: GRBW
# Set the pixel order required by the LED hardware. Options are GRB,
# RGB, GRBW, or RGBW. The default is GRB.
#initial_RED: 1.0
#initial_GREEN: 0.0
#initial_BLUE: 1.0
#initial_WHITE: 0.0
# Sets the initial LED color of the Neopixel. Each value should be
# between 0.0 and 1.0. The WHITE option is only available on RGBW
# LEDs. The default for each color is 0.#
# Most configuration for the macros can be done by modifying the variables in the _toolchanger_led_vars macro
# at the start of this file.
##########
# MACROS #
##########
# The following status macros are available (these go inside of your macros):
#
# STATUS_READY
# STATUS_OFF
# STATUS_BUSY
# STATUS_HEATING
# STATUS_LEVELING
# STATUS_HOMING
# STATUS_CLEANING
# STATUS_MESHING
# STATUS_CALIBRATING_Z
#
# With additional macros for basic control:
#
# SET_NOZZLE_LEDS_ON
# SET_LOGO_LEDS_OFF
# SET_NOZZLE_LEDS_OFF
#
# Contributed by Voron discord users wile.e, Tetsunosuke, and etherwalker
[gcode_macro _toolchanger_led_vars]
# User settings for the StealthBurner status leds. You can change the status colors and led
# configurations for the logo and nozzle here.
variable_colors: {
'logo': { # Colors for logo states
'busy': {'r': 0.4, 'g': 0.0, 'b': 0.0, 'w': 0.0},
'cleaning': {'r': 0.0, 'g': 0.02, 'b': 0.5, 'w': 0.0},
'calibrating_z': {'r': 0.8, 'g': 0., 'b': 0.35, 'w': 0.0},
'heating': {'r': 0.3, 'g': 0.18, 'b': 0.0, 'w': 0.0},
'homing': {'r': 0.0, 'g': 0.6, 'b': 0.2, 'w': 0.0},
'leveling': {'r': 0.5, 'g': 0.1, 'b': 0.4, 'w': 0.0},
'meshing': {'r': 0.2, 'g': 1.0, 'b': 0.0, 'w': 0.0},
'off': {'r': 0.0, 'g': 0.0, 'b': 0.0, 'w': 0.0},
'printing': {'r': 1.0, 'g': 0.0, 'b': 0.0, 'w': 0.0},
'standby': {'r': 0.01, 'g': 0.01, 'b': 0.01, 'w': 0.1},
},
'nozzle': { # Colors for nozzle states
'heating': {'r': 0.8, 'g': 0.35, 'b': 0.0, 'w':0.0},
'off': {'r': 0.0, 'g': 0.0, 'b': 0.0, 'w': 0.0},
'on': {'r': 0.8, 'g': 0.8, 'b': 0.8, 'w':1.0},
'standby': {'r': 0.6, 'g': 0.0, 'b': 0.0, 'w':0.0},
},
'thermal': {
'hot': {'r': 1.0, 'g': 0.0, 'b': 0.0, 'w': 0.0},
'cold': {'r': 0.3, 'g': 0.0, 'b': 0.3, 'w': 0.0}
}
}
gcode:
# This section is required. Do Not Delete.
[gcode_macro _set_toolchanger_leds]
gcode:
{% set red = params.RED|default(0)|float %}
{% set green = params.GREEN|default(0)|float %}
{% set blue = params.BLUE|default(0)|float %}
{% set white = params.WHITE|default(0)|float %}
{% set led = params.LED|string %}
{% set idx = (params.IDX|string).split(',') %}
{% set transmit_last = params.TRANSMIT|default(1) %}
{% for led_index in idx %}
{% set transmit=transmit_last if loop.last else 0 %}
set_led led={led} red={red} green={green} blue={blue} white={white} index={led_index} transmit={transmit}
{% endfor %}
[gcode_macro _set_toolchanger_leds_by_name]
gcode:
{% set tn = params.T|default(printer.toolchanger.tool_number)|int %}
{% if tn < 0 %}
{% set tn = 0 %}
{% endif %}
{% set leds_name = params.LEDS %}
{% set color_name = params.COLOR %}
{% set color = printer["gcode_macro _toolchanger_led_vars"].colors[leds_name][color_name] %}
{% set led = printer["gcode_macro _T" + tn|string + "_vars"][leds_name + "_led_name"] %}
{% set idx = printer["gcode_macro _T" + tn|string + "_vars"][leds_name + "_idx"] %}
{% set transmit = params.TRANSMIT|default(1) %}
_set_toolchanger_leds led={led} red={color.r} green={color.g} blue={color.b} white={color.w} idx="{idx}" transmit={transmit}
[gcode_macro _set_logo_leds]
gcode:
{% set tn = params.T|default(printer.toolchanger.tool_number)|int %}
{% if tn < 0 %}
{% set tn = 0 %}
{% endif %}
{% set red = params.RED|default(0)|float %}
{% set green = params.GREEN|default(0)|float %}
{% set blue = params.BLUE|default(0)|float %}
{% set white = params.WHITE|default(0)|float %}
{% set led = printer["gcode_macro _T" + tn|string + "_vars"].logo_led_name %}
{% set idx = printer["gcode_macro _T" + tn|string + "_vars"].logo_idx %}
{% set transmit=params.TRANSMIT|default(1) %}
_set_toolchanger_leds led={led} red={red} green={green} blue={blue} white={white} idx="{idx}" transmit={transmit}
[gcode_macro _set_nozzle_leds]
gcode:
{% set tn = params.T|default(printer.toolchanger.tool_number)|int %}
{% if tn < 0 %}
{% set tn = 0 %}
{% endif %}
{% set red = params.RED|default(0)|float %}
{% set green = params.GREEN|default(0)|float %}
{% set blue = params.BLUE|default(0)|float %}
{% set white = params.WHITE|default(0)|float %}
{% set led = printer["gcode_macro _T" + tn|string + "_vars"].nozzle_led_name %}
{% set idx = printer["gcode_macro _T" + tn|string + "_vars"].nozzle_idx %}
{% set transmit=params.TRANSMIT|default(1) %}
_set_toolchanger_leds led={led} red={red} green={green} blue={blue} white={white} idx="{idx}" transmit={transmit}
[gcode_macro set_logo_leds_off]
gcode:
{% set tn = params.T|default(printer.toolchanger.tool_number)|int %}
{% set transmit=params.TRANSMIT|default(1) %}
_set_logo_leds T={tn} red=0 blue=0 green=0 white=0 transmit={transmit}
[gcode_macro set_nozzle_leds_on]
gcode:
{% set tn = params.T|default(printer.toolchanger.tool_number)|int %}
{% set transmit=params.TRANSMIT|default(1) %}
_set_toolchanger_leds_by_name T={tn} leds="nozzle" color="on" transmit={transmit}
[gcode_macro set_nozzle_leds_off]
gcode:
{% set tn = params.T|default(printer.toolchanger.tool_number)|int %}
{% set transmit=params.TRANSMIT|default(1) %}
_set_toolchanger_leds_by_name T={tn} leds="nozzle" color="off" transmit={transmit}
[gcode_macro status_off]
gcode:
{% set tn = params.T|default(printer.toolchanger.tool_number)|int %}
set_logo_leds_off T={tn} transmit=0
set_nozzle_leds_off T={tn}
[gcode_macro status_ready]
gcode:
{% set tn = params.T|default(printer.toolchanger.tool_number)|int %}
_set_toolchanger_leds_by_name T={tn} leds="logo" color="standby" transmit=0
_set_toolchanger_leds_by_name T={tn} leds="nozzle" color="standby" transmit=1
[gcode_macro status_busy]
gcode:
{% set tn = params.T|default(printer.toolchanger.tool_number)|int %}
_set_toolchanger_leds_by_name T={tn} leds="logo" color="busy" transmit=0
set_nozzle_leds_on T={tn}
[gcode_macro status_heating]
gcode:
{% set tn = params.T|default(printer.toolchanger.tool_number)|int %}
_set_toolchanger_leds_by_name T={tn} leds="logo" color="heating" transmit=0
_set_toolchanger_leds_by_name T={tn} leds="nozzle" color="heating" transmit=1
[gcode_macro status_leveling]
gcode:
{% set tn = params.T|default(printer.toolchanger.tool_number)|int %}
_set_toolchanger_leds_by_name T={tn} leds="logo" color="leveling" transmit=0
set_nozzle_leds_on T={tn}
[gcode_macro status_homing]
gcode:
{% set tn = params.T|default(printer.toolchanger.tool_number)|int %}
_set_toolchanger_leds_by_name T={tn} leds="logo" color="homing" transmit=0
set_nozzle_leds_on T={tn}
[gcode_macro status_cleaning]
gcode:
{% set tn = params.T|default(printer.toolchanger.tool_number)|int %}
_set_toolchanger_leds_by_name T={tn} leds="logo" color="cleaning" transmit=0
set_nozzle_leds_on T={tn}
[gcode_macro status_meshing]
gcode:
{% set tn = params.T|default(printer.toolchanger.tool_number)|int %}
_set_toolchanger_leds_by_name T={tn} leds="logo" color="meshing" transmit=0
set_nozzle_leds_on T={tn}
[gcode_macro status_calibrating_z]
gcode:
{% set tn = params.T|default(printer.toolchanger.tool_number)|int %}
_set_toolchanger_leds_by_name T={tn} leds="logo" color="calibrating_z" transmit=0
set_nozzle_leds_on T={tn}
[gcode_macro status_printing]
gcode:
{% set tn = params.T|default(printer.toolchanger.tool_number)|int %}
_set_toolchanger_leds_by_name T={tn} leds="logo" color="printing" transmit=0
set_nozzle_leds_on T={tn}
[gcode_macro M109]
rename_existing: M109.99
description: [T<index>] [S<temperature>]
Set tool temperature and wait.
T= Tool number, optional. If this parameter is not provided, the current tool is used.
S= Target temperature
gcode:
{% if params.T is defined %}
{% set newparameters = " T="~params.T %}
{% if params.S|float > 0 %}
STATUS_HEATING {newparameters}
{% endif %}
{% endif %}
M109.99 {rawparams}
{% if newparameters is defined %}
STATUS_READY {newparameters}
{% endif %}
[gcode_macro TEMPERATURE_WAIT]
rename_existing: LEDS_TEMPERATURE_WAIT
gcode:
{% if params.HEATER is defined %}
{% for toolname in printer.toolchanger.tool_names %}
{% if printer[toolname]['extruder'] == params.HEATER %}
{% set newparameters = " T="~printer[toolname]['tool_number'] %}
{% if params.TARGET|float > 0 %}
STATUS_HEATING {newparameters}
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
LEDS_TEMPERATURE_WAIT {rawparams}
{% if newparameters is defined %}
STATUS_READY {newparameters}
{% endif %}