-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathleds.cfg
175 lines (168 loc) · 4.5 KB
/
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
[include stealthburner_leds.cfg]
[gcode_macro _led_sequences]
variable_running: None
variable_current: 0
variable_caution: [
{
'logo': {},
'left': {},
'right': {'r': 1.0, 'g': 0.75},
'duration': 0.1,
},
{
'right': {},
'duration': 0.05,
},
{
'logo': {'r': 0.2, 'g': 0.15},
'right': {'r': 1.0, 'g': 0.75},
'duration': 0.1,
},
{
'logo': {'r': 0.3, 'g': 0.225},
'right': {},
'duration': 0.05,
},
{
'logo': {'r': 0.6, 'g': 0.45},
'right': {'r': 1.0, 'g': 0.75},
'duration': 0.1,
},
{
'right': {},
'duration': 0.05,
},
{
'left': {'r': 1.0, 'g': 0.75},
'duration': 0.1,
},
{
'logo': {'r': 0.3, 'g': 0.225},
'left': {},
'duration': 0.05,
},
{
'logo': {'r': 0.2, 'g': 0.15},
'left': {'r': 1.0, 'g': 0.75},
'duration': 0.1,
},
{
'logo': {},
'left': {},
'duration': 0.05,
},
{
'left': {'r': 1.0, 'g': 0.75},
'duration': 0.1,
},
{
'left': {},
'duration': 0.05,
},
]
variable_police: [
{
'logo': {},
'left': {},
'right': {'r': 1.0},
'duration': 0.1,
},
{
'right': {},
'duration': 0.05,
},
{
'logo': {'r': 0.2},
'right': {'r': 1.0},
'duration': 0.1,
},
{
'logo': {'r': 0.3},
'right': {},
'duration': 0.05,
},
{
'logo': {'r': 0.6},
'right': {'r': 1.0},
'duration': 0.1,
},
{
'right': {},
'duration': 0.05,
},
{
'left': {'b': 1.0},
'duration': 0.1,
},
{
'logo': {'r': 0.3},
'left': {},
'duration': 0.05,
},
{
'logo': {'r': 0.2},
'left': {'b': 1.0},
'duration': 0.1,
},
{
'logo': {},
'left': {},
'duration': 0.05,
},
{
'left': {'b': 1.0},
'duration': 0.1,
},
{
'left': {},
'duration': 0.05,
},
]
gcode:
[delayed_gcode _led_sequence]
gcode:
{% set running = printer["gcode_macro _led_sequences"].running %}
{% if running is not none %}
{% set cur = printer["gcode_macro _led_sequences"].current|int %}
{% set upd = printer["gcode_macro _led_sequences"][running][cur] %}
{% set logo_t = 0 %}
{% set left_t = 0 %}
{% set right_t = 0 %}
{% if (upd["right"] is defined) %}
{% set right_t = 1 %}
{% elif (upd["left"] is defined) %}
{% set left_t = 1 %}
{% elif (upd["logo"] is defined) %}
{% set logo_t = 1 %}
{% endif %}
{% if (upd["logo"] is defined) %}
set_led led="sb_leds" red={upd["logo"].r|default(0)} green={upd["logo"].g|default(0)} blue={upd["logo"].b|default(0)} white={upd["logo"].w|default(0)} index=1 transmit={logo_t}
{% endif %}
{% if (upd["left"] is defined) %}
set_led led="sb_leds" red={upd["left"].r|default(0)} green={upd["left"].g|default(0)} blue={upd["left"].b|default(0)} white={upd["left"].w|default(0)} index=2 transmit={left_t}
{% endif %}
{% if (upd["right"] is defined) %}
set_led led="sb_leds" red={upd["right"].r|default(0)} green={upd["right"].g|default(0)} blue={upd["right"].b|default(0)} white={upd["right"].w|default(0)} index=3 transmit={right_t}
{% endif %}
SET_GCODE_VARIABLE MACRO=_led_sequences VARIABLE=current VALUE={(cur + 1) % printer["gcode_macro _led_sequences"][running]|length}
UPDATE_DELAYED_GCODE ID=_led_sequence DURATION={upd["duration"]}
{% endif %}
[gcode_macro led_sequence]
gcode:
{% set seq = (params.VAR|string) %}
SET_GCODE_VARIABLE MACRO=_led_sequences VARIABLE=current VALUE=0
SET_GCODE_VARIABLE MACRO=_led_sequences VARIABLE=running VALUE='"{seq}"'
UPDATE_DELAYED_GCODE ID=_led_sequence DURATION=1
[gcode_macro police]
gcode:
led_sequence VAR=police
[gcode_macro caution]
gcode:
led_sequence VAR=caution
[gcode_macro stop_sequence]
gcode:
SET_GCODE_VARIABLE MACRO=_led_sequences VARIABLE=running VALUE=None
UPDATE_DELAYED_GCODE ID=_led_sequence DURATION=0
set_led led="sb_leds" red=0 green=0 blue=0 white=0 index=1 transmit=0
set_led led="sb_leds" red=0 green=0 blue=0 white=0 index=2 transmit=0
set_led led="sb_leds" red=0 green=0 blue=0 white=0 index=3 transmit=1