-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
desk-display.yaml
157 lines (142 loc) · 4.43 KB
/
desk-display.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
---
substitutions:
name: desk-display
friendly_name: Desk Display
wifi_reboot_timeout: 15min
packages:
common: !include modules/common-32-idf.yaml
wifi: !include modules/common/wifi.yaml
api:
services:
- service: notify
variables:
message: string
type: int
then:
- text.set:
id: notification_text
value: !lambda return message;
- display.page.show: notification
- delay: 1s
- lambda: |-
int x_offset, baseline, width, height;
id(font_8bithud)->measure(id(notification_text).state.c_str(), &width,
&x_offset, &baseline, &height);
id(text_width) = width;
- repeat:
count: !lambda "return id(text_width) - 16;"
then:
- globals.set:
id: scroller_position
value: !lambda "return id(scroller_position) - 1;"
- delay: 100ms
- display.page.show: clock_page
- text.set:
id: notification_text
value: ""
- globals.set:
id: scroller_position
value: "0"
globals:
- id: scroller_position
type: int32_t
restore_value: false
initial_value: "0"
- id: text_width
type: uint32_t
restore_value: false
initial_value: "0"
light:
- platform: esp32_rmt_led_strip
chipset: WS2812
pin: GPIO13
num_leds: 256
rgb_order: GRB
rmt_channel: 3
max_refresh_rate: 10ms
name: None
id: matrix
color_correct: [50%, 50%, 50%]
default_transition_length: 0s
restore_mode: ALWAYS_ON
effects:
# - addressable_lambda:
# name: Rainbow Left
# lambda: |-
# ESPHSVColor hsv;
# hsv.value = 255;
# hsv.saturation = 240;
# uint16_t hue = (millis() * 10) % 0xFFFF;
# const uint16_t add = 0xFFFF / 32;
# for (size_t i=0; i < it.size(); i += 8) {
# hsv.hue = hue >> 8;
# it.range(i, i+8) = hsv;
# hue += add;
# }
# - addressable_lambda:
# name: Rainbow Right
# lambda: |-
# ESPHSVColor hsv;
# hsv.value = 255;
# hsv.saturation = 240;
# uint16_t hue = (millis() * 10) % 0xFFFF;
# const uint16_t add = 0xFFFF / 32;
# for (size_t i=it.size() - 8; i < it.size(); i += 8) {
# hsv.hue = hue >> 8;
# it.range(i, i+8) = hsv;
# hue += add;
# }
display:
- platform: addressable_light
id: display_entity
addressable_light_id: matrix
width: 32
height: 8
update_interval: 16ms
pixel_mapper: |-
if (x % 2 == 0) {
return (x * 8) + y;
}
return (x * 8) + (7 - y);
pages:
- id: clock_page
# yamllint disable rule:line-length
lambda: |-
auto light_color = id(matrix).current_values;
Color color(light_color.get_red() * 255, light_color.get_green() * 255,
light_color.get_blue() * 255);
it.strftime(15, 0, id(font_8bithud), color, TextAlign::RIGHT, "%H",
id(sntp_time).now());
it.print(15, 0, id(font_8bithud), color, ((millis()/1000)%2==0)?":":" ");
it.strftime(18, 0, id(font_8bithud), color, TextAlign::LEFT, "%M",
id(sntp_time).now());
# yamllint enable rule:line-length
- id: notification
lambda: |-
auto light_color = id(matrix).current_values;
Color color(light_color.get_red() * 255, light_color.get_green() * 255,
light_color.get_blue() * 255);
it.print(id(scroller_position), 0, id(font_8bithud),
color, id(notification_text).state.c_str());
font:
- id: font_8bithud
file: fonts/8-bit-hud2.ttf
size: 5
# yamllint disable-line rule:line-length
glyphs: '!"%()+,-_.:*=°?~#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz'
switch:
- platform: template
name: "Display On"
id: display_on
restore_mode: ALWAYS_ON
setup_priority: 100
lambda: return id(display_entity).get_enabled();
turn_on_action:
- lambda: id(display_entity).set_enabled(true);
turn_off_action:
- lambda: id(display_entity).set_enabled(false);
text:
- platform: template
id: notification_text
optimistic: true
mode: text