forked from mtw3d/mtw_klipper_config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
macros-led.cfg
209 lines (186 loc) · 8.47 KB
/
macros-led.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
##
# LED Macros for MTW Printers
#
# NOTE: DO NOT EDIT THESE MACROS!
# If you wish to change the behavior of any of these macros, copy the macro from here
# to the macros-custom.cfg file and make your changes there. That way you will not
# lose any changes you make if we offer an updated version of this file. That file is
# loaded after this one, so any macros defined there will override any of the same
# name defined here.
###
[gcode_macro LIGHTS]
gcode:
{% set NAME = params.NAME|default(PrimaryLEDs)|string %}
{% set R = params.R|default(0)|int %}
{% set G = params.G|default(0)|int %}
{% set B = params.B|default(0)|int %}
{% set I = params.I|default(0)|int %}
{% set T = params.T|default(1)|int %}
{% if I|int == 0 %}
SET_LED LED={NAME} RED={R|float / 255} GREEN={G|float / 255} BLUE={B|float / 255} TRANSMIT={T}
{% else %}
SET_LED LED={NAME} RED={R|float / 255} GREEN={G|float / 255} BLUE={B|float / 255} INDEX={I} TRANSMIT={T}
{% endif %}
[gcode_macro LIGHTS_ON]
gcode:
{% set NAME = params.NAME|default(PrimaryLEDs)|string %}
{% set BRIGHT = params.BRIGHT|default(100)|int %}
LIGHTS NAME={NAME} R={BRIGHT} G={BRIGHT} B={BRIGHT}
[gcode_macro LIGHTS_OFF]
gcode:
{% set NAME = params.NAME|default(PrimaryLEDs)|string %}
LIGHTS NAME={NAME} R=0 G=0 B=0
[gcode_macro LIGHTS_WARMING]
gcode:
{% set NAME = params.NAME|default(PrimaryLEDs)|string %}
LIGHTS NAME={NAME} R=255 G=165 B=0
[gcode_macro LIGHTS_HOT]
gcode:
{% set NAME = params.NAME|default(PrimaryLEDs)|string %}
LIGHTS NAME={NAME} R=255 G=0 B=0
[gcode_macro LIGHTS_ALERT]
gcode:
LIGHTS R=200 G=0 B=0
G4 P1000
LIGHTS R=0 G=200 B=0
G4 P1000
LIGHTS R=0 G=0 B=200
G4 P1000
LIGHTS_OFF
G4 P500
LIGHTS R=70 G=60 B=50
M400
[gcode_macro GANTRY_STROBE]
gcode:
{% set NAME = params.NAME|default(PrimaryLEDs)|string %}
{% set R = params.R|default(50)|int %}
{% set G = params.G|default(50)|int %}
{% set B = params.B|default(50)|int %}
{% set I = params.I|default(6)|int %} #8 on Create 2, 6 on the Create XL
{% set T = params.T|default(5)|int %}
{% set S = params.S|default(100)|int %}
{% for i in range(((T|int * 1000) / S|int)|int) %}
{% set direction = 1 %}
{% if (i / N|int)|int % 2 == 1 %}
{% set direction = -1 %}
{% endif %}
{% set index = (i % N|int) + 1 %}
{% for p in range(1, N|int + 1) %}
{% if p == N|int %}
{% set transmit = 1 %}
{% else %}
{% set transmit = 0 %}
{% endif %}
{% set curIndex = index %}
{% if direction == -1 %}
{% set curIndex = (N|int + 1) - index %}
{% endif %}
{% if curIndex == p %}
LIGHTS NAME={NAME} R={R} G={G} B={B} I={p} T={transmit}
{% else %}
{% set level = 1.0 - (0.33 * ((curIndex - p)|abs + 1)) %}
{% if level < 0 %}
{% set level = 0 %}
{% endif %}
LIGHTS NAME={NAME} R={R|int * level} G={G|int * level} B={B|int * level} I={p} T={transmit}
{% endif %}
{% endfor %}
G4 P{S}
{% if ((i * S|int) / 1000) % 4 == 3 %}
M105
{% endif %}
{% endfor %}
LIGHTS NAME={NAME} R=0 G=0 B=0 T=1
M400
[gcode_macro KIT]
gcode:
{% set T = params.T|default(5)|int %}
GANTRY_STROBE T={T} S=100 R=100 G=0 B=0
M400
# [gcode_macro M105]
# rename_existing: M105.1
# gcode:
# M105.1
# #if the extruder is off
# {% if printer.extruder1.target == 0 %}
# #Set the LED to red if the extruder is off but is still hot, otherwise
# # set the color to green
# {% if printer.extruder1.temperature > 60.0 %}
# {% set scaler = printer.extruder1.temperature|float / 200 %}
# {% if scaler > 1 %}
# {% set scaler=1 %}
# {% endif %}
# SET_LED LED=PrimaryLEDs RED={ scaler|float * 1 } GREEN=0 BLUE={ (1 - (scaler|float * 1)) } INDEX=1 transmit=0
# SET_LED LED=PrimaryLEDs RED={ scaler|float * 1 } GREEN=0 BLUE={ (1 - (scaler|float * 1)) } INDEX=2 transmit=0
# {% else %}
# SET_LED LED=PrimaryLEDs RED=0 GREEN=0 BLUE=1 INDEX=1 transmit=0
# SET_LED LED=PrimaryLEDs RED=0 GREEN=0 BLUE=1 INDEX=2 transmit=0
# {% endif %}
# {% else %}
# #if the extruder temp is at target temperature
# {% if printer.extruder1.temperature >= printer.extruder1.target - 4.0 %}
# SET_LED LED=PrimaryLEDs RED=1 GREEN=0 BLUE=0 INDEX=1 transmit=0
# SET_LED LED=PrimaryLEDs RED=1 GREEN=0 BLUE=0 INDEX=2 transmit=0
# #if the extruder is still heating
# {% else %}
# {% set scaler = printer.extruder1.temperature|float / printer.extruder1.target|float %}
# SET_LED LED=PrimaryLEDs RED={ scaler|float * 1 } GREEN=0 BLUE={ (1 - (scaler|float * 1)) } INDEX=1 transmit=0
# SET_LED LED=PrimaryLEDs RED={ scaler|float * 1 } GREEN=0 BLUE={ (1 - (scaler|float * 1)) } INDEX=2 transmit=0
# {% endif %}
# {% endif %}
# #if the extruder is off
# {% if printer.extruder.target == 0 %}
# #Set the LED to red if the extruder is off but is still hot, otherwise
# # set the color to green
# {% if printer.extruder.temperature > 60.0 %}
# {% set scaler = printer.extruder.temperature|float / 200 %}
# {% if scaler > 1 %}
# {% set scaler=1 %}
# {% endif %}
# SET_LED LED=PrimaryLEDs RED={ scaler|float * 1 } GREEN=0 BLUE={ (1 - (scaler|float * 1)) } INDEX=7 transmit=0
# SET_LED LED=PrimaryLEDs RED={ scaler|float * 1 } GREEN=0 BLUE={ (1 - (scaler|float * 1)) } INDEX=8 transmit=0
# {% else %}
# SET_LED LED=PrimaryLEDs RED=0 GREEN=0 BLUE=1 INDEX=7 transmit=0
# SET_LED LED=PrimaryLEDs RED=0 GREEN=0 BLUE=1 INDEX=8 transmit=0
# {% endif %}
# {% else %}
# #if the extruder temp is at target temperature
# {% if printer.extruder.temperature >= printer.extruder.target - 4.0 %}
# SET_LED LED=PrimaryLEDs RED=1 GREEN=0 BLUE=0 INDEX=7 transmit=0
# SET_LED LED=PrimaryLEDs RED=1 GREEN=0 BLUE=0 INDEX=8 transmit=0
# #if the extruder is still heating
# {% else %}
# {% set scaler = printer.extruder.temperature|float / printer.extruder.target|float %}
# SET_LED LED=PrimaryLEDs RED={ scaler|float * 1 } GREEN=0 BLUE={ (1 - (scaler|float * 1)) } INDEX=7 transmit=0
# SET_LED LED=PrimaryLEDs RED={ scaler|float * 1 } GREEN=0 BLUE={ (1 - (scaler|float * 1)) } INDEX=8 transmit=0
# {% endif %}
# {% endif %}
# #if the bed is off
# {% if printer.heater_bed.target == 0 %}
# #Set the LED to red if the extruder is off but is still hot, otherwise
# # set the color to green
# {% if printer.heater_bed.temperature > 30.0 %}
# {% set scaler = printer.heater_bed.temperature|float / 60 %}
# {% if scaler > 1 %}
# {% set scaler=1 %}
# {% endif %}
# SET_LED LED=PrimaryLEDs RED={ scaler|float * 1 } GREEN=0 BLUE={ (1 - (scaler|float * 1)) } INDEX=4 transmit=0
# SET_LED LED=PrimaryLEDs RED={ scaler|float * 1 } GREEN=0 BLUE={ (1 - (scaler|float * 1)) } INDEX=5 transmit=0
# {% else %}
# SET_LED LED=PrimaryLEDs RED=0 GREEN=0 BLUE=1 INDEX=4 transmit=0
# SET_LED LED=PrimaryLEDs RED=0 GREEN=0 BLUE=1 INDEX=5 transmit=0
# {% endif %}
# {% else %}
# #if the extruder temp is at target temperature
# {% if printer.heater_bed.temperature >= printer.heater_bed.target - 4.0 %}
# SET_LED LED=PrimaryLEDs RED=1 GREEN=0 BLUE=0 INDEX=4 transmit=0
# SET_LED LED=PrimaryLEDs RED=1 GREEN=0 BLUE=0 INDEX=5 transmit=0
# #if the extruder is still heating
# {% else %}
# {% set scaler = printer.heater_bed.temperature|float / printer.heater_bed.target|float %}
# SET_LED LED=PrimaryLEDs RED={ scaler|float * 1 } GREEN=0 BLUE={ (1 - (scaler|float * 1)) } INDEX=4 transmit=0
# SET_LED LED=PrimaryLEDs RED={ scaler|float * 1 } GREEN=0 BLUE={ (1 - (scaler|float * 1)) } INDEX=5 transmit=0
# {% endif %}
# {% endif %}
# SET_LED LED=PrimaryLEDs RED=0.2 GREEN=0 BLUE=0.4 INDEX=3 transmit=0
# SET_LED LED=PrimaryLEDs RED=0.2 GREEN=0 BLUE=0.4 INDEX=6 transmit=1