-
Notifications
You must be signed in to change notification settings - Fork 0
/
esp32-2424s012-lvgl-powermeter-test.yaml
327 lines (302 loc) · 8.78 KB
/
esp32-2424s012-lvgl-powermeter-test.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
esphome:
name: esp32-2424s012-lvgl-powermeter-test
friendly_name: esp32-2424s012-lvgl-powermeter-test
esp32:
board: esp32-c3-devkitm-1
framework:
type: arduino
logger:
level: DEBUG
#hardware_uart: USB_SERIAL_JTAG
# Enable Home Assistant API
api:
encryption:
key:
ota:
password:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
captive_portal:
external_components:
- source:
type: git
url: https://github.com/clydebarrow/esphome
ref: fd15094c0860df23d532881df36cfd16c7da1091 #previous commit - wont be needed in the future
components: [ lvgl ]
globals:
- id: time_counter
type: int
initial_value: '0'
number:
- platform: template
initial_value: 0
id: counting_number
internal: True
min_value: -10
max_value: 10
step: 1
optimistic: True
sensor:
- platform: wifi_signal
# name: "WiFi Signal Sensor"
internal: True
id: wifi_signal_sensor
update_interval: 1s
- platform: uptime
id: uptime_counter
update_interval: 1s
accuracy_decimals: 0
on_raw_value:
then:
- light.turn_on:
id: back_light
brightness: 50%
- number.increment:
id: counting_number
cycle: True
- script.execute: update_display
spi:
clk_pin: GPIO6
mosi_pin: GPIO7
output:
- platform: ledc
pin:
number: GPIO3
id: backlight_output
light:
- platform: monochromatic
output: backlight_output
name: LCD Backlight
id: back_light
restore_mode: ALWAYS_ON
#default_transition_length: 0s
display:
- platform: ili9xxx
id: lcd_display
model: gc9a01a
data_rate: 80MHz
cs_pin: GPIO10
dc_pin: GPIO2
dimensions:
width: 240
height: 240
update_interval: never
auto_clear_enabled: false
#time:
# - platform: homeassistant
# id: time_comp
script:
- id: update_display
then:
- lvgl.indicator.line.update:
id: power_meter_input
value: !lambda return id(counting_number).state;
- lvgl.label.update:
id: battery_kw
text: !lambda |-
static char buf[8];
snprintf(buf, sizeof(buf), "%.1fkW", id(counting_number).state);
return buf;
- lvgl.label.update:
id: battery_status
text_color: 0xFF0000
#text: "charging"
text: "discharging"
- lvgl.label.update:
id: battery_soc
text: !lambda |-
static char buf[8];
snprintf(buf, sizeof(buf), "%.1f%%", id(counting_number).state);
return buf;
- lvgl.label.update:
id: solar_kw
text: !lambda |-
static char buf[8];
snprintf(buf, sizeof(buf), "%.1fkW", id(counting_number).state);
return buf;
- lvgl.img.update:
id: img_solar_power
src: solar_power_icon
img_recolor: 0xFFF000 #mixes this color with the base image
#img_recolor_opa: 100% #opacity defaults to 0% = must set this for recolor to take effect
#bg_color: 0xFFFFFF
i2c:
sda: 4
scl: 5
#scan: true
id: i2c_touch
touchscreen:
platform: cst816
id: my_touchscreen
interrupt_pin: 0
reset_pin: 1
on_touch:
then:
lvgl.page.next:
image:
- file: mdi:sun-wireless-outline
#"solar-power-invert.png"
# mdi:solar-power
# mdi:battery-charging-outline
# mdi:battery-arrow-up-outline
# mdi:battery-arrow-down-outline
id: solar_power_icon
resize: 50x50
- file: mdi:battery-arrow-down-outline
id: home_battery_icon
resize: 30x30
lvgl:
touchscreens: my_touchscreen
log_level: INFO
color_depth: 16
bg_color: 0
border_width: 0
outline_width: 0
shadow_width: 0
text_font: unscii_16
align: center
style_definitions:
- id: meter_style
text_font: unscii_8
#state_default: null
- id: font_style
text_font: MONTSERRAT_24
#text_font: unscii_16
align: center
text_color: 0xFFFFFF
#bg_opa: cover
bg_opa: TRANSP
bg_color: 0
radius: 4
pad_all: 2
page_wrap: true
pages:
- id: main_page
widgets:
- obj: # Meter
height: 240 # needed to be explicitily defined for my round display to not have weird corder line overlappting gauge
width: 240
#bg_opa: TRANSP
bg_color: 0
border_width: 0
outline_width: 0
shadow_width: 0
pad_all: 4
align: center
#scrollbar_mode: "off"
widgets:
- meter: # Gradient color arc
height: 100%
width: 100%
border_width: 0
outline_width: 0
align: center
bg_color: 0
styles: meter_style
#bg_opa: TRANSP
scales:
angle_range: 180 # sets the total angle to 180 = starts mid left and ends mid right
range_to: 10
range_from: -10
ticks:
count: 0
indicators:
- line:
id: power_meter_input
width: 8
color: 0xFFFFFF
r_mod: 12 #sets line length by this much difference from the scale default radius
value: 50
- img:
id: power_meter_input_img
- arc:
color: 0xFF3000
r_mod: 10 #radius difference from the scale default radius
width: 20
start_value: -10
end_value: 0
- arc:
color: 0x00FF00
r_mod: 10 #radius difference from the scale default radius
width: 20
start_value: 0
end_value: 10
#- canvas:
- arc: # black arc to erase middle part of meter indicator line
height: 170
width: 170
align: center
arc_color: 0x000000 # background color
arc_width: 150
start_angle: 0
end_angle: 360
indicator:
arc_width: 150
arc_color: 0x000000
- label: # gauge lower and higher range indicators
styles: font_style
text_font: MONTSERRAT_18 # override font size
y: 8 #negative = higher
x: -99
text: "-10"
- label:
styles: font_style
text_font: MONTSERRAT_18 # override font size
y: 8 #negative = higher
x: 99
text: "+10"
- label:
styles: font_style
id: battery_status
y: -35 #negative = higher
- label:
styles: font_style
id: battery_kw
y: -60
- label:
styles: font_style
text_font: MONTSERRAT_40 # override font size
id: battery_soc
y: 0
- label:
styles: font_style
id: solar_kw
text_color: 0xFFFF00
y: 90
#- img:
# src: home_battery_icon
#id: img_solar_power
#align: center
#img_recolor: 0xFFFFFF
#img_recolor_opa: 100% #opacity defaults to 0% = must set this for recolor to take effect
#bg_color: 0xFFFFFF
#y: -35
#x: -60
- img:
src: solar_power_icon
id: img_solar_power
align: center
img_recolor: 0xFFFF00
img_recolor_opa: 100% #opacity defaults to 0% = must set this for recolor to take effect
#bg_color: 0xFFFFFF
y: 50
#x: -60
- id: page1
height: 240 # needed to be explicitily defined for my round display to not have weird corder line overlappting gauge
width: 240
#bg_opa: TRANSP
bg_color: 0
border_width: 0
outline_width: 0
shadow_width: 0
pad_all: 4
align: center
#scrollbar_mode: "off"
widgets:
- label:
styles: font_style
text_font: MONTSERRAT_18 # override font size
y: 0 #negative = higher
x: 0
text: "Settings Page"