forked from landonr/homeThing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tdisplayremote.yaml
executable file
·291 lines (278 loc) · 6.19 KB
/
tdisplayremote.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
esphome:
name: lilygo_display
platform: ESP32
board: featheresp32
includes:
- esphomeRemote/MenuGlobals.h
- esphomeRemote/MenuTitle.h
- esphomeRemote/FriendlyNameEntity.h
- esphomeRemote/TextHelpers.h
- esphomeRemote/esphomeRemotePlayer.h
- esphomeRemote/esphomeRemoteService.h
- esphomeRemote/esphomeRemoteLight.h
- esphomeRemote/esphomeRemoteSwitch.h
- esphomeRemote/esphomeRemoteSensor.h
- esphomeRemote/DisplayUpdateInterface.h
- esphomeRemote/esphomeRemote.h
- esphomeRemote/esphomeRemoteRotary.h
substitutions:
boot_name: '"TDisplay Remote <3"'
friendly_name: "TDisplay Remote"
wifi_ssid: !secret wifi_ssid
wifi_password: !secret wifi_password
wifi_fallback_password: !secret wifi_fallback_password
large_font_size: "24"
medium_font_size: "15"
small_font_size: "14"
icon_size: "18"
icon_size_large: "19"
header_height: "16"
margin_size: "4"
scroll_bar_width: "6"
bottom_bar_margin: "1"
now_playing_max_lines: "5"
draw_now_playing_menu: "false"
draw_battery_level: "true"
draw_volume_level: "false"
draw_shuffle_disabled: "false"
draw_header_time: "true"
color_accent_primary_red: 0%
color_accent_primary_green: 45%
color_accent_primary_blue: 68%
display_timeout: "16"
sleep_after: "7200"
menu_rollover_on: "false"
sync_active_player: "true"
dark_mode: "true"
<<: !include esphomeRemote/sharedRemoteConfig.yaml
sensor:
## Rotary
- platform: rotary_encoder
filters:
- throttle: 0.01s
name: "Rotary Encoder"
internal: true
pin_a:
number: 12
mode:
input: true
pullup: true
pin_b:
number: 13
mode:
input: true
pullup: true
id: rotary
on_clockwise:
- lambda: |-
buttonPressWakeUpDisplay();
buttonPressNext();
on_anticlockwise:
- lambda: |-
buttonPressWakeUpDisplay();
buttonPressPrevious();
## Needed to debounce screen updates for rotary. 17ms is close to 60fps for st7789v
- platform: template
id: display_update_tick
filters:
- debounce: 17ms
on_value :
then:
- lambda: |-
displayUpdateDebounced();
## Battery
- platform: adc
pin: 34
attenuation: 11db
name: "vccadc"
update_interval: 250ms
id: vcc_adc
internal: true
on_value:
then:
lambda: |-
if (id(vcc_adc).state > 2.23) {
if (charging == false) {
charging = true;
}
} else {
if (charging == true) {
charging = false;
}
}
id(vcc_adc_avg).publish_state(id(vcc_adc).state);
- platform: template
id: vcc_adc_avg
filters:
- sliding_window_moving_average:
window_size: 4
send_every: 4
on_value :
then:
- sensor.template.publish:
id: batteryVoltage
state: !lambda 'return id(vcc_adc).state;'
- platform: template
name: batteryVoltage
id: batteryVoltage
internal: true
unit_of_measurement: 'V'
on_value :
then:
- sensor.template.publish:
id: batteryPercent
state: !lambda 'return (id(batteryVoltage).state * 118) - 162;'
- platform: template
name: Battery Percent
id: batteryPercent
unit_of_measurement: '%'
on_value_range:
below: 5
then:
lambda: |-
ESP_LOGE("SLEEP", "Low Power Supply %.3fV! Sleeping to protect battery", id(batteryPercent).state);
id(sleep_toggle).turn_on();
binary_sensor:
- platform: gpio
pin:
number: GPIO0
inverted: true
mode:
input: true
pullup: true
name: "T-Display Button Input 0"
id: tdisplay_button_input_0
internal: true
on_press:
then:
- lambda: |-
buttonPressScreenLeft();
on_release:
then:
- lambda: |-
buttonReleaseScreenLeft();
- platform: gpio
pin:
number: GPIO35
inverted: true
name: "T-Display Button Input 1"
id: tdisplay_button_input_1
internal: true
on_press:
then:
- lambda: |-
buttonPressScreenRight();
## Rotary buttons
- platform: gpio
internal: true
pin:
number: 21
inverted: true
mode:
input: true
pullup: true
id: sw5
on_press:
then:
- lambda: |-
buttonPressLeft();
- platform: gpio
internal: true
pin:
number: 22
inverted: true
mode:
input: true
pullup: true
id: sw4
on_press:
then:
- lambda: |-
buttonPressUp();
- platform: gpio
internal: true
pin:
number: 17
inverted: true
mode:
input: true
pullup: true
id: sw3
on_press:
then:
- lambda: |-
buttonPressRight();
- platform: gpio
internal: true
pin:
number: 2
inverted: true
mode:
input: true
pullup: true
id: sw2
on_press:
then:
- lambda: |-
buttonPressDown();
- platform: gpio
internal: true
pin:
number: 15
inverted: true
mode:
input: true
pullup: true
id: sw1
on_press:
then:
- lambda: |-
buttonPressSelect();
switch:
- platform: template
name: Sleep Toggle
id: sleep_toggle
optimistic: true
on_turn_on:
then:
- deep_sleep.enter:
id: deep_sleep_1
- platform: gpio
pin:
number: 27
inverted: false
id: comb
internal: true
- platform: gpio
pin:
number: 26
inverted: false
id: coma
internal: true
- platform: gpio
pin: GPIO4
name: "Backlight"
id: backlight
internal: true
restore_mode: RESTORE_DEFAULT_ON
spi:
clk_pin: GPIO18
mosi_pin: GPIO19
display:
- platform: st7789v
model: TTGO_TDisplay_135x240
id: my_display
backlight_pin: GPIO4
cs_pin: GPIO5
dc_pin: GPIO16
reset_pin: GPIO23
rotation: 90
update_interval: 60s
lambda: |-
if (idleTime < 0) {
ESP_LOGD("drawing menu", "turning on");
id(backlight).turn_on();
idleTime = 0;
}
drawMenu();
return;