-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathzilloscope.yaml
executable file
·441 lines (403 loc) · 11.1 KB
/
zilloscope.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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
substitutions:
device: "zilloscope"
name: "Zilloscope"
esphome:
name: ${device}
build_path: build/${device}
platform: ESP32
board: esp32doit-devkit-v1
on_boot:
- priority: 1000
then:
- lambda: |-
fastled_base_fastledlightoutput->get_controller()->setDither(0);
id(notif_colorline_scroller).setup(32,1,4);
- switch.turn_on: zilloscope_control_display
- lambda: |-
id(zilloscope_main).on_boot();
on_shutdown:
then:
- lambda: |-
id(zilloscope_main).on_shutdown();
external_components:
- source:
type: local
path: components
components: [ zilloscope, color_line_scroller, text_scroller ]
wifi: !include "common/wifimulti.yaml"
logger:
api:
services:
#effect start
- service: start_effect
variables:
name: string
then:
- lambda: |-
id(zilloscope_main).service_effect_start(name);
#effect stop
- service: stop_effect
then:
- lambda: |-
id(zilloscope_main).service_effect_stop();
#effect next
- service: next_effect
then:
- lambda: |-
id(zilloscope_main).service_effect_next();
#effect previous
- service: previous_effect
then:
- lambda: |-
id(zilloscope_main).service_effect_prev();
#change mode
- service: mode
variables:
name: string
then:
- lambda: |-
id(zilloscope_main).service_mode(name);
- service: mode_next
then:
- lambda: |-
id(zilloscope_main).service_mode_next();
- service: mode_prev
then:
- lambda: |-
id(zilloscope_main).service_mode_prev();
#queue notification
- service: notify
variables:
type: int
text: string
then:
- lambda: |-
id(zilloscope_main).service_notify(type,text,-1);
ota:
binary_sensor:
- <<: !include "common/common_binary_sensors.yaml"
- platform: gpio
pin:
number: 33
mode: INPUT_PULLUP
name: bouton1
id: zilloscope_bouton_prev
on_press:
then:
- lambda: |-
id(zilloscope_main).service_mode_prev();
- platform: gpio
pin:
number: 32
mode: INPUT_PULLUP
name: bouton2
id: zilloscope_bouton_enter
- platform: gpio
pin:
number: 25
mode: INPUT_PULLUP
name: bouton3
id: zilloscope_bouton_next
on_press:
then:
- lambda: |-
id(zilloscope_main).service_mode_next();
switch:
- platform: template
id: zilloscope_control_display
name: ${name} Control Display
lambda: |-
return id(zilloscope_display).get_enabled();
turn_on_action:
- lambda: |-
id(zilloscope_display).set_enabled(true);
turn_off_action:
- lambda: |-
id(zilloscope_display).set_enabled(false);
sensor:
- <<: !include "common/common_sensors.yaml"
- platform: homeassistant
id: esphome_meteo_icon
entity_id: sensor.esphome_meteo_icon
- platform: homeassistant
id: esphome_meteo_current_temp
entity_id: sensor.esphome_meteo_current_temp
button:
- <<: !include "common/common_button.yaml"
- platform: template
name: ${name} Next Mode
on_press:
then:
- lambda: id(zilloscope_main).service_mode_next();
- platform: template
name: ${name} Previous Mode
on_press:
then:
- lambda: id(zilloscope_main).service_mode_prev();
- platform: template
name: ${name} Next Effect
on_press:
then:
- lambda: id(zilloscope_main).service_effect_next();
- platform: template
name: ${name} Previous Effect
on_press:
then:
- lambda: id(zilloscope_main).service_effect_prev();
time:
- platform: homeassistant
id: homeassistant_time
timezone: Europe/Paris
light:
- platform: fastled_clockless
chipset: WS2812B
pin: GPIO5
num_leds: 256
rgb_order: GRB
name: ${name} Led Matrix
id: zilloscope_matrix
color_correct: [50%, 50%, 50%]
default_transition_length : 0s
#gamma_correct: 0
restore_mode : ALWAYS_ON
effects:
- strobe:
name: presence
colors:
- state: True
brightness: 100%
red: 100%
green: 0%
blue: 100%
duration: 1000ms
- state: False
duration: 750ms
display:
- platform: addressable_light
id: zilloscope_display
addressable_light_id: zilloscope_matrix
width: 32
height: 8
update_interval: 16ms
lambda: |-
id(zilloscope_main).display_lambdacall(it);
pixel_mapper: |-
if (x % 2 == 0) {
return (x * 8) + y;
}
return (x * 8) + (7 - y);
font:
- id: tinyfont
file: "fonts/pixelmix.ttf"
size: 8
glyphs: '!"%()+,-_.:*=°?~#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz'
- id: font6px
file: "fonts/6px-Normal.ttf"
size: 8
glyphs: '!"%()+,-_.:*=°?~#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz'
- id: font_8bithud
file: "fonts/8-bit-hud.ttf"
size: 5
glyphs: '!"%()+,-_.:*=°?~#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz'
animation:
- file: "img/zilloscope/boot0.gif"
id: splash_animation
type: RGB24
- file: "img/zilloscope/boot1.gif"
id: boot_animation
type: RGB24
- file: "img/zilloscope/aliens/aliens.gif"
id: aliens
type: RGB24
- file: "img/zilloscope/meteo/sun1.gif"
id: meteo_sun
type: RGB24
- file: "img/zilloscope/meteo/rain1.gif"
id: meteo_rain
type: RGB24
- file: "img/zilloscope/meteo/cloud1.gif"
id: meteo_cloud
type: RGB24
- file: "img/zilloscope/meteo/fog1.gif"
id: meteo_fog
type: RGB24
color_line_scroller:
- id: notif_colorline_scroller
text_scroller:
- id: notif_text_scroller
zilloscope:
id: zilloscope_main
display_id: zilloscope_display
time_id: homeassistant_time
use_splash: true
default_mode: effects
#modes
modes:
#Renders time in red
- mode_time:
name: time1
render_lambda: |-
//it=display
//frame= frame counter
it.strftime(2, 0, id(font_8bithud), Color(0xFF0000), ((millis()/1000)%2==0)?"%H:%M":"%H.%M", id(homeassistant_time).now());
return false;
#Renders time in white
- mode_time:
name: time2
render_lambda: |-
//it=display
//frame= frame counter
it.strftime(2, 0, id(font_8bithud), Color(0xFFFFFF), ((millis()/1000)%2==0)?"%H:%M":"%H.%M", id(homeassistant_time).now());
return false;
#Generic mode where you can render what you want
- mode_lambda:
name: time3
render_lambda: |-
//it=display
//frame= frame counter
it.strftime(2, 0, id(font_8bithud), Color(0x0000FF), ((millis()/1000)%2==0)?"%H:%M":"%H.%M", id(homeassistant_time).now());
return false;
#Effects mode
- mode_effects:
name: effects
default_effect: fire
effects:
#custom effect (lambda)
- display_lambda:
name: aliens
lambda: |-
if(frame%6==0) {
id(aliens).next_frame();
}
it.image(1, -1, id(aliens));
- display_lambda:
name: boot
lambda: |-
//it=display
//frame= frame counter
//render same animation as the boot animation but you can code what you want instead
id(boot_animation).next_frame();
it.image(1, -1, id(boot_animation));
#effet integré 'feu'
- display_fire:
name: fire
width: 32
height: 8
#effet integré 'matrix'
- display_matrix:
name: matrix
width: 32
height: 8
#effet integré 'bubulles'
- display_bubbles:
name: bubulles
speed: 15
width: 32
height: 8
#background_color: 0x193291
min_bubble_size: 1
max_bubble_size: 16
- display_snow:
name: snow
snow_speed: 15
santa_speed: 15
reindeer_number: 3
width: 32
height: 8
min_snow_size: 1
max_snow_size: 6
background_color: 0x193291
#- display_tiled_puzzle:
# name: "puzzle"
# width: 32
# height: 8
# tile_size: 5
#Paint mode (wip)
#- mode_paint:
# name: paint
- mode_meteo:
name: meteo
render_lambda: |-
it.printf(32, 0, id(font_8bithud), Color(0x61d3e3), TextAlign::RIGHT, "%.0f ", (id(esphome_meteo_current_temp).state + 0.5));
auto icon = (uint8_t)id(esphome_meteo_icon).state;
Animation* anim = nullptr;
if(icon==2) {
anim=id(meteo_rain);
} else if(icon==5) {
anim=id(meteo_cloud);
} else if(icon==16) {
anim=id(meteo_fog);
} else {
anim=id(meteo_sun);
}
it.image(2, 0, anim);
it.rectangle(29,0,3,3,Color(0x61d3e3));
if(frame%7==0) {
anim->next_frame();
}
return true;
#render lambdas
#boot animation forever
render_boot: |-
//it=display
//frame= frame counter
id(boot_animation).next_frame();
id(zilloscope_display).image(0, 0, id(boot_animation));
return true;
#pause on frame 10 for 100 frames, then 110 for 100 frames. then end
render_splash: |-
//it=display
//frame= frame counter
if(frame==210) {
return false; //if returning false, it goes to on_ready component side
}
if(frame<=9 || frame==109) {
id(splash_animation).next_frame();
}
id(zilloscope_display).image(0, 0, id(splash_animation));
return true; //splash continue
#notifications
render_notification: |-
//it=display
//frame= frame counter
//text= notification text
//type= notification type
if(frame==0){
id(notif_text_scroller).setup(it,id(font6px),text,2,1,-1);
}
//Multicolor line scroller
id(notif_colorline_scroller).draw(it, 0, 7);
id(notif_colorline_scroller).scroll();
//Notification type
if(frame<((2*1000)/16)) {
//for first 2 seconds
if(type==-1) {
//todo: do something with notification's type
}
else {
it.print(16, 3, id(font_8bithud), Color(0x61d3e3), TextAlign::CENTER, "info");
}
return true;
}
//Text scroller
id(notif_text_scroller).draw(it, id(font6px),Color(0xFFFFFF));
if(frame%5==0) {
//scroll every 5 frame
if(id(notif_text_scroller).scroll()) {
id(zilloscope_main).end_notification();
return false;
}
}
return true;
#ota
render_ota: |-
//it=display
//frame= frame counter
it.print(0, 0, id(tinyfont), Color(0x0000FF), "OTA");
return false;
#shutdown
render_shutdown: |-
//it=display
//frame= frame counter
it.print(0, 0, id(tinyfont), Color(0xFF0000), "STOP");
return false;