-
Notifications
You must be signed in to change notification settings - Fork 0
/
led_matrix.yaml
322 lines (298 loc) · 11.8 KB
/
led_matrix.yaml
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
---
# Sources:
# - https://github.com/Tenn0/ESPHome-RGB-Breathing-Light-Effect/tree/master
# - https://github.com/rnauber/ESPHomeMatrixLED
# - https://github.com/zhujisheng/audio-reactive-led-strip
# --> Forked: https://github.com/phdelodder/audio-reactive-led-strip
substitutions:
device: led_matrix
name: Led Matrix
update_interval: 10min
esphome:
name: ${device}
platform: ESP32
board: esp32doit-devkit-v1
includes:
- my_matrixled_display.h
- music_leds_esphome.h # Forked version
- includes/FFT.h
- includes/ExpFilter.h
- includes/VisualEffect.h
- includes/gaussian_filter1d.h
<<: !include common/common.yaml
<<: !include common/logger.yaml
<<: !include common/sensor.yaml
<<: !include common/binary_sensor.yaml
<<: !include common/switch.yaml
font:
- id: tinyfont
file: "DejaVuSans-Bold.ttf"
size: 9
glyphs: '♡Ωäöüß!"%()+,-_.:*=°?~#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz'
time:
- platform: sntp
id: rtc
timezone: Europe/Brussels
remote_receiver:
pin: GPIO26
# dump: all
light:
- platform: fastled_clockless
chipset: WS2812B
pin: GPIO25
num_leds: 256
rgb_order: GRB
name: "Matrix Led Speelkamer Light"
id: mylight
# color_correct: [40%, 40%, 40%]
effects:
- addressable_random_twinkle:
- addressable_fireworks:
- addressable_flicker:
- addressable_rainbow:
- addressable_color_wipe:
- addressable_lambda:
name: "My Simple Counter"
update_interval: 3000ms
lambda: |-
static int run = 0;
static auto matrixled = new MatrixLedDisplay();
matrixled->set_addr_light((light::AddressableLight *) &it);
matrixled->set_width(16);
matrixled->set_height(16);
matrixled->set_rotation(display::DISPLAY_ROTATION_270_DEGREES);
matrixled->clear();
matrixled->printf(matrixled->get_width()/2, matrixled->get_height()/2,
id(tinyfont), COLOR_ON, TextAlign::CENTER,
"%i", run % 10);
run++;
- addressable_lambda:
name: "My Text Diplay"
update_interval: 800ms
lambda: |-
static auto text=" 3 2 1 0 #ESPHOME♡♡♡♡Ω ";
static uint16_t byte_pos = 0;
char current_char[16];
static auto matrixled = new MatrixLedDisplay();
matrixled->set_addr_light((light::AddressableLight *) &it);
matrixled->set_width(16);
matrixled->set_height(16);
matrixled->set_rotation(display::DISPLAY_ROTATION_270_DEGREES);
//matrixled->set_fg_color(¤t_color);
matrixled->set_fg_color(light::ESPColor(0xff, 0xff, 0xff));
matrixled->set_bg_color(light::ESPColor(0x80, 0x00, 0x00));
matrixled->set_fg_color(light::ESPColor((byte_pos * 10) % 255 , 0xff, 0xff));
matrixled->clear();
byte_pos = get_next_char(text, id(tinyfont), byte_pos, current_char, sizeof(current_char));
ESP_LOGD("main", "Displaying \"%s\"", current_char);
matrixled->printf( matrixled->get_width()/2,
matrixled->get_height()/2, id(tinyfont), COLOR_ON, TextAlign::CENTER, current_char);
- addressable_lambda:
name: "Clock"
update_interval: 500ms
lambda: |-
static auto matrixled = new MatrixLedDisplay();
matrixled->set_addr_light((light::AddressableLight *) &it);
matrixled->set_width(16);
matrixled->set_height(16);
matrixled->set_rotation(display::DISPLAY_ROTATION_270_DEGREES);
matrixled->set_bg_color(light::ESPColor(0x80, 0x00, 0x00));
matrixled->clear();
float halfheight = (matrixled->get_height() - 0.1) / 2;
float halfwidth = (matrixled->get_width() - 0.1) / 2;
float theta;
int minutes = -1;
int hours = -1;
if ((id(rtc).now()).is_valid()){
minutes = id(rtc).now().minute;
hours = id(rtc).now().hour;
//fast forward...
//minutes = int(id(rtc).now().time * 20.) % 60;
//hours = int(id(rtc).now().time * 20. / 60.) % 12;
};
for (int i=0; i < 12; i++){
theta = i * 2 * 3.141 / 12.0;
if (i==0)
matrixled->set_fg_color(light::ESPColor(0x00, 0x00, 0xff));
else
matrixled->set_fg_color(light::ESPColor(0x00, 0xff, 0x00));
matrixled->draw_pixel_at(halfwidth - sin(-theta) * halfwidth, halfheight - cos(-theta) * halfheight, COLOR_ON);
}
if (minutes >= 0) {
matrixled->set_fg_color(light::ESPColor(0xff, 0xff, 0xff));
theta = minutes * 2 * 3.141 / 60.0;
matrixled->line(halfwidth, halfheight, halfwidth - sin(-theta) * halfwidth, halfheight - cos(-theta) * halfheight, COLOR_ON);
}
if (hours >= 0) {
matrixled->set_fg_color(light::ESPColor(0xff, 0x00, 0x00));
theta = (hours + 0.5)/ 12.0 * 2 * 3.141 ;
matrixled->line(halfwidth, halfheight, halfwidth - sin(-theta) * halfwidth * 0.7, halfheight - cos(-theta) * halfheight * 0.7, COLOR_ON);
}
- addressable_lambda:
name: "Digital Clock Marquee"
update_interval: 200ms
lambda: |-
static char text[16] = "??:??";
static uint16_t run = 0;
static int width;
static float charwidth = 10;
static int x_offset;
static int baseline;
static int height;
static auto matrixled = new MatrixLedDisplay();
matrixled->set_addr_light((light::AddressableLight *) &it);
matrixled->set_width(16);
matrixled->set_height(16);
matrixled->set_rotation(display::DISPLAY_ROTATION_270_DEGREES);
//matrixled->set_fg_color(current_color);
matrixled->set_fg_color(light::ESPColor(0xff, 0xff, 0xff, 0));
matrixled->set_bg_color(light::ESPColor(0xff, 0x00, 0x00, 0));
matrixled->clear();
if (((run % 32) == 0) && (id(rtc).now()).is_valid()){
id(rtc).now().strftime(text, sizeof(text), "%M %H:%M %H");
id(tinyfont)->measure(text, &width, &x_offset, &baseline, &height); charwidth = float(width) / strlen(text);
ESP_LOGD("main", "Displaying \"%s\"", text);
};
matrixled->printf(matrixled->get_width()/2 + 3 * charwidth - run % int(6 * charwidth), matrixled->get_height()/2, id(tinyfont), COLOR_ON, TextAlign::CENTER, text);
run++;
- addressable_lambda:
name: Scroll with Music
update_interval: 0s
lambda: |-
music_leds.ShowFrame(MODE_SCROLL, &it);
- addressable_lambda:
name: Energy with Music
update_interval: 0s
lambda: |-
music_leds.ShowFrame(MODE_ENERGY, &it);
- addressable_lambda:
name: Spectrum with Music
update_interval: 0s
lambda: |-
music_leds.ShowFrame(MODE_SPECTRUM, &it);
- lambda:
name: RGB Breathing
update_interval: 0.04s
lambda: |-
static int state = 0;
static int color = 1;
auto call = id(mylight).turn_on();
call.set_transition_length(0);
if (color == 1){
call.set_rgb(1.0, 0.0, 0.0);
} else if (color == 2) {
call.set_rgb(1.0, 0.5, 0.0);
} else if (color == 3) {
call.set_rgb(1.0, 1.0, 0.0);
} else if (color == 4) {
call.set_rgb(0.5, 1.0, 0.0);
} else if (color == 5) {
call.set_rgb(0.0, 1.0, 0.0);
} else if (color == 6) {
call.set_rgb(0.0, 1.0, 0.5);
} else if (color == 6) {
call.set_rgb(0.0, 1.0, 1.0);
} else if (color == 7) {
call.set_rgb(0.0, 0.5, 1.0);
} else if (color == 8) {
call.set_rgb(0.0, 0.0, 1.0);
} else if (color == 9) {
call.set_rgb(0.5, 0.0, 1.0);
} else if (color == 10) {
call.set_rgb(1.0, 0.0, 1.0);
} else if (color == 11) {
call.set_rgb(1.0, 0.0, 0.5);
}
if (state == 0)
{
call.set_brightness(0.001);
} else if (state == 1) {
call.set_brightness(0.05);
} else if (state == 2) {
call.set_brightness(0.1);
} else if (state == 3) {
call.set_brightness(0.15);
} else if (state == 4) {
call.set_brightness(0.2);
} else if (state == 5) {
call.set_brightness(0.25);
} else if (state == 6) {
call.set_brightness(0.3);
} else if (state == 7) {
call.set_brightness(0.35);
} else if (state == 8) {
call.set_brightness(0.4);
} else if (state == 9) {
call.set_brightness(0.45);
} else if (state == 10) {
call.set_brightness(0.5);
} else if (state == 11) {
call.set_brightness(0.55);
} else if (state == 12) {
call.set_brightness(0.6);
} else if (state == 13) {
call.set_brightness(0.65);
} else if (state == 14) {
call.set_brightness(0.7);
} else if (state == 15) {
call.set_brightness(0.75);
} else if (state == 16) {
call.set_brightness(0.8);
} else if (state == 17) {
call.set_brightness(0.85);
} else if (state == 18) {
call.set_brightness(0.9);
} else if (state == 19) {
call.set_brightness(0.95);
} else if (state == 20) {
call.set_brightness(1);
} else if (state == 21) {
call.set_brightness(0.95);
} else if (state == 22) {
call.set_brightness(0.9);
} else if (state == 23) {
call.set_brightness(0.85);
} else if (state == 24) {
call.set_brightness(0.8);
} else if (state == 25) {
call.set_brightness(0.75);
} else if (state == 26) {
call.set_brightness(0.7);
} else if (state == 27) {
call.set_brightness(0.65);
} else if (state == 28) {
call.set_brightness(0.6);
} else if (state == 29) {
call.set_brightness(0.55);
} else if (state == 30) {
call.set_brightness(0.5);
} else if (state == 31) {
call.set_brightness(0.45);
} else if (state == 32) {
call.set_brightness(0.4);
} else if (state == 33) {
call.set_brightness(0.35);
} else if (state == 34) {
call.set_brightness(0.3);
} else if (state == 35) {
call.set_brightness(0.25);
} else if (state == 36) {
call.set_brightness(0.2);
} else if (state == 37) {
call.set_brightness(0.15);
} else if (state == 38) {
call.set_brightness(0.1);
} else if (state == 39) {
call.set_brightness(0.05);
} else if (state == 40) {
call.set_brightness(0.001);
}
call.perform();
state ++;
if (state == 41){
state = 0;
color++;
}
if (color == 12)
color = 1;
display: