mirror of
https://github.com/randybb/esphome-configs.git
synced 2026-12-06 09:06:52 +01:00
m5core2: Unit LCD on its own LVGL instance
lvgl_unit (rotation 90 in LVGL) shows the clock, the last keyboard line and a battery bar; page actions name lvgl_main now that there are two instances.
This commit is contained in:
1 parent
2d3754bf79
commit
7cef9c674d
1 file changed
+200
-142
+200
-142
@@ -56,7 +56,7 @@ esphome:
|
|||||||
# the m5stack component sets these in the AXP2101 layout: 4.1 V, 360 mA, end at 10 %
|
# the m5stack component sets these in the AXP2101 layout: 4.1 V, 360 mA, end at 10 %
|
||||||
- lambda: id(pmu_axp)->writeRegister(0x33, 0x83);
|
- lambda: id(pmu_axp)->writeRegister(0x33, 0x83);
|
||||||
- bm8563.read_time:
|
- bm8563.read_time:
|
||||||
- lvgl.page.show: status_page
|
- lvgl.page.show: {id: status_page, lvgl_id: lvgl_main}
|
||||||
|
|
||||||
esp32:
|
esp32:
|
||||||
variant: esp32
|
variant: esp32
|
||||||
@@ -93,7 +93,7 @@ api:
|
|||||||
api.connected:
|
api.connected:
|
||||||
state_subscription_only: true
|
state_subscription_only: true
|
||||||
then:
|
then:
|
||||||
- lvgl.page.show: main_page
|
- lvgl.page.show: {id: main_page, lvgl_id: lvgl_main}
|
||||||
on_client_disconnected:
|
on_client_disconnected:
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
@@ -101,7 +101,7 @@ api:
|
|||||||
api.connected:
|
api.connected:
|
||||||
state_subscription_only: true
|
state_subscription_only: true
|
||||||
then:
|
then:
|
||||||
- lvgl.page.show: status_page
|
- lvgl.page.show: {id: status_page, lvgl_id: lvgl_main}
|
||||||
|
|
||||||
i2c:
|
i2c:
|
||||||
- id: i2c_main
|
- id: i2c_main
|
||||||
@@ -155,18 +155,9 @@ display:
|
|||||||
- platform: m5stack_st7789v2
|
- platform: m5stack_st7789v2
|
||||||
id: unit_lcd
|
id: unit_lcd
|
||||||
i2c_id: i2c_port_c
|
i2c_id: i2c_port_c
|
||||||
rotation: 90
|
|
||||||
brightness: 60%
|
brightness: 60%
|
||||||
update_interval: 2s
|
update_interval: 10s # only reconnects a lost unit, LVGL flushes drive the transfer
|
||||||
lambda: |-
|
auto_clear_enabled: false
|
||||||
it.fill(Color(0x10, 0x18, 0x30));
|
|
||||||
it.print(4, 4, id(font_title), Color(0xFF, 0xB3, 0x00), "${name}");
|
|
||||||
it.strftime(236, 4, id(font_title), Color::WHITE, TextAlign::TOP_RIGHT, "%H:%M", id(ha_time).now());
|
|
||||||
it.print(4, 44, id(font_status), Color(0x8C, 0x8C, 0x8C), "Last line:");
|
|
||||||
it.print(4, 64, id(font_status), Color::WHITE, id(keyboard_line).state.c_str());
|
|
||||||
it.printf(4, 131, id(font_status), id(battery_charging).state ? Color(0x4D, 0xD9, 0x66) : Color::WHITE,
|
|
||||||
TextAlign::BOTTOM_LEFT, "Battery %.2f V %.0f %%%s", id(battery_voltage).state,
|
|
||||||
id(battery_level).state, id(battery_charging).state ? " charging" : "");
|
|
||||||
|
|
||||||
touchscreen:
|
touchscreen:
|
||||||
- platform: ft63x6
|
- platform: ft63x6
|
||||||
@@ -202,7 +193,7 @@ binary_sensor:
|
|||||||
y_min: 240
|
y_min: 240
|
||||||
y_max: 300
|
y_max: 300
|
||||||
on_press:
|
on_press:
|
||||||
- lvgl.page.previous:
|
- lvgl.page.previous: {lvgl_id: lvgl_main}
|
||||||
- platform: touchscreen
|
- platform: touchscreen
|
||||||
id: button_b
|
id: button_b
|
||||||
use_raw: true
|
use_raw: true
|
||||||
@@ -211,7 +202,7 @@ binary_sensor:
|
|||||||
y_min: 240
|
y_min: 240
|
||||||
y_max: 300
|
y_max: 300
|
||||||
on_press:
|
on_press:
|
||||||
- lvgl.page.show: main_page
|
- lvgl.page.show: {id: main_page, lvgl_id: lvgl_main}
|
||||||
- platform: touchscreen
|
- platform: touchscreen
|
||||||
id: button_c
|
id: button_c
|
||||||
use_raw: true
|
use_raw: true
|
||||||
@@ -220,7 +211,7 @@ binary_sensor:
|
|||||||
y_min: 240
|
y_min: 240
|
||||||
y_max: 300
|
y_max: 300
|
||||||
on_press:
|
on_press:
|
||||||
- lvgl.page.next:
|
- lvgl.page.next: {lvgl_id: lvgl_main}
|
||||||
|
|
||||||
# AXP192 ADCs read directly, the m5stack component decodes them as an AXP2101
|
# AXP192 ADCs read directly, the m5stack component decodes them as an AXP2101
|
||||||
sensor:
|
sensor:
|
||||||
@@ -293,6 +284,9 @@ key_collector:
|
|||||||
- lvgl.label.update:
|
- lvgl.label.update:
|
||||||
id: last_line
|
id: last_line
|
||||||
text: !lambda return x;
|
text: !lambda return x;
|
||||||
|
- lvgl.label.update:
|
||||||
|
id: unit_last_line
|
||||||
|
text: !lambda return x;
|
||||||
- lvgl.textarea.update:
|
- lvgl.textarea.update:
|
||||||
id: input_text
|
id: input_text
|
||||||
text: ""
|
text: ""
|
||||||
@@ -396,6 +390,19 @@ interval:
|
|||||||
id(battery_charging).publish_state(r(0x01) & 0x40);
|
id(battery_charging).publish_state(r(0x01) & 0x40);
|
||||||
- interval: 1s
|
- interval: 1s
|
||||||
then:
|
then:
|
||||||
|
- lvgl.label.update:
|
||||||
|
id: unit_time
|
||||||
|
text: !lambda |-
|
||||||
|
auto now = id(ha_time).now();
|
||||||
|
return now.is_valid() ? now.strftime("%H:%M") : std::string("--:--");
|
||||||
|
- lvgl.bar.update:
|
||||||
|
id: unit_battery_bar
|
||||||
|
value: !lambda return id(battery_level).state;
|
||||||
|
- lvgl.label.update:
|
||||||
|
id: unit_battery
|
||||||
|
text: !lambda |-
|
||||||
|
return str_sprintf("%.2f V %.0f %%%s", id(battery_voltage).state, id(battery_level).state,
|
||||||
|
id(battery_charging).state ? " charging" : "");
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lvgl.page.is_showing: status_page
|
lvgl.page.is_showing: status_page
|
||||||
@@ -426,130 +433,181 @@ font:
|
|||||||
glyphsets: [GF_Latin_Kernel]
|
glyphsets: [GF_Latin_Kernel]
|
||||||
|
|
||||||
lvgl:
|
lvgl:
|
||||||
displays: display_tft
|
- id: lvgl_main
|
||||||
touchscreens: touch_lcd
|
displays: display_tft
|
||||||
buffer_size: 25%
|
touchscreens: touch_lcd
|
||||||
log_level: WARN
|
buffer_size: 25%
|
||||||
bg_color: 0x000000
|
log_level: WARN
|
||||||
text_color: 0xFFFFFF
|
bg_color: 0x000000
|
||||||
pages:
|
text_color: 0xFFFFFF
|
||||||
# 1: keyboard demo
|
pages:
|
||||||
- id: main_page
|
# 1: keyboard demo
|
||||||
widgets:
|
- id: main_page
|
||||||
- label:
|
widgets:
|
||||||
align: TOP_MID
|
- label:
|
||||||
y: 6
|
align: TOP_MID
|
||||||
text_font: font_title
|
y: 6
|
||||||
text: ${name}
|
text_font: font_title
|
||||||
- textarea:
|
text: ${name}
|
||||||
id: input_text
|
- textarea:
|
||||||
align: TOP_MID
|
id: input_text
|
||||||
y: 40
|
align: TOP_MID
|
||||||
width: 300
|
y: 40
|
||||||
height: 70
|
width: 300
|
||||||
text_font: font_status
|
height: 70
|
||||||
placeholder_text: Type on the keyboard...
|
text_font: font_status
|
||||||
- label:
|
placeholder_text: Type on the keyboard...
|
||||||
align: TOP_LEFT
|
- label:
|
||||||
x: 10
|
align: TOP_LEFT
|
||||||
y: 122
|
x: 10
|
||||||
text_font: font_status
|
y: 122
|
||||||
text: "Last line:"
|
text_font: font_status
|
||||||
- label:
|
text: "Last line:"
|
||||||
id: last_line
|
- label:
|
||||||
align: TOP_LEFT
|
id: last_line
|
||||||
x: 90
|
align: TOP_LEFT
|
||||||
y: 122
|
x: 90
|
||||||
width: 220
|
y: 122
|
||||||
long_mode: DOT
|
width: 220
|
||||||
text_font: font_status
|
long_mode: DOT
|
||||||
text: "-"
|
text_font: font_status
|
||||||
- slider:
|
text: "-"
|
||||||
id: demo_slider
|
- slider:
|
||||||
align: BOTTOM_LEFT
|
id: demo_slider
|
||||||
x: 20
|
align: BOTTOM_LEFT
|
||||||
y: -40
|
x: 20
|
||||||
width: 170
|
y: -40
|
||||||
on_value:
|
width: 170
|
||||||
- lvgl.arc.update:
|
on_value:
|
||||||
id: demo_arc
|
- lvgl.arc.update:
|
||||||
value: !lambda return x;
|
id: demo_arc
|
||||||
- arc:
|
value: !lambda return x;
|
||||||
id: demo_arc
|
- arc:
|
||||||
align: BOTTOM_RIGHT
|
id: demo_arc
|
||||||
x: -15
|
align: BOTTOM_RIGHT
|
||||||
y: -15
|
x: -15
|
||||||
width: 100
|
y: -15
|
||||||
height: 100
|
width: 100
|
||||||
adjustable: false
|
height: 100
|
||||||
|
adjustable: false
|
||||||
|
|
||||||
# 2: AXP192 diagnostics
|
# 2: AXP192 diagnostics
|
||||||
- id: axp_page
|
- id: axp_page
|
||||||
on_load:
|
on_load:
|
||||||
- script.execute: update_axp
|
- script.execute: update_axp
|
||||||
widgets:
|
widgets:
|
||||||
- label:
|
- label:
|
||||||
align: TOP_MID
|
align: TOP_MID
|
||||||
y: 6
|
y: 6
|
||||||
text_font: font_title
|
text_font: font_title
|
||||||
text: AXP192
|
text: AXP192
|
||||||
- label:
|
- label:
|
||||||
x: 16
|
x: 16
|
||||||
y: 44
|
y: 44
|
||||||
text_font: font_status
|
text_font: font_status
|
||||||
text_color: 0x8C8C8C
|
text_color: 0x8C8C8C
|
||||||
text: "Battery\nCurrent\nUSB (VBUS)\nM-Bus 5V (ACIN)\nAPS\nTemperature"
|
text: "Battery\nCurrent\nUSB (VBUS)\nM-Bus 5V (ACIN)\nAPS\nTemperature"
|
||||||
- label:
|
- label:
|
||||||
id: axp_values
|
id: axp_values
|
||||||
x: 170
|
x: 170
|
||||||
y: 44
|
y: 44
|
||||||
text_font: font_status
|
text_font: font_status
|
||||||
text: ""
|
text: ""
|
||||||
|
|
||||||
# 3: status (shown until Home Assistant connects)
|
# 3: status (shown until Home Assistant connects)
|
||||||
- id: status_page
|
- id: status_page
|
||||||
on_load:
|
on_load:
|
||||||
- script.execute: update_status
|
- script.execute: update_status
|
||||||
widgets:
|
widgets:
|
||||||
- image:
|
- image:
|
||||||
src: esphome_logo
|
src: esphome_logo
|
||||||
align: TOP_MID
|
align: TOP_MID
|
||||||
y: 8
|
y: 8
|
||||||
- label:
|
- label:
|
||||||
align: TOP_MID
|
align: TOP_MID
|
||||||
y: 96
|
y: 96
|
||||||
text_font: font_title
|
text_font: font_title
|
||||||
text: "${name}"
|
text: "${name}"
|
||||||
- obj:
|
- obj:
|
||||||
x: 16
|
x: 16
|
||||||
y: 132
|
y: 132
|
||||||
width: 288
|
width: 288
|
||||||
height: SIZE_CONTENT
|
height: SIZE_CONTENT
|
||||||
bg_opa: TRANSP
|
bg_opa: TRANSP
|
||||||
border_width: 0
|
border_width: 0
|
||||||
pad_all: 0
|
pad_all: 0
|
||||||
scrollbar_mode: "OFF"
|
scrollbar_mode: "OFF"
|
||||||
layout:
|
layout:
|
||||||
type: flex
|
type: flex
|
||||||
flex_flow: column
|
flex_flow: column
|
||||||
pad_row: 4
|
pad_row: 4
|
||||||
widgets:
|
widgets:
|
||||||
- label:
|
- label:
|
||||||
id: status_wifi
|
id: status_wifi
|
||||||
text_font: font_status
|
text_font: font_status
|
||||||
text: ""
|
text: ""
|
||||||
- label:
|
- label:
|
||||||
id: status_ips
|
id: status_ips
|
||||||
text_font: font_status
|
text_font: font_status
|
||||||
text_color: 0x8C8C8C
|
text_color: 0x8C8C8C
|
||||||
pad_left: 20
|
pad_left: 20
|
||||||
text: ""
|
text: ""
|
||||||
- label:
|
- label:
|
||||||
id: status_ha
|
id: status_ha
|
||||||
text_font: font_status
|
text_font: font_status
|
||||||
text: ""
|
text: ""
|
||||||
- label:
|
- label:
|
||||||
id: status_footer
|
id: status_footer
|
||||||
text_font: font_status
|
text_font: font_status
|
||||||
text_color: 0x8C8C8C
|
text_color: 0x8C8C8C
|
||||||
text: ""
|
text: ""
|
||||||
|
|
||||||
|
# Unit LCD on Port C, rotated by LVGL (the display can't rotate under LVGL)
|
||||||
|
- id: lvgl_unit
|
||||||
|
displays: unit_lcd
|
||||||
|
rotation: 90
|
||||||
|
buffer_size: 100%
|
||||||
|
bg_color: 0x101830
|
||||||
|
text_color: 0xFFFFFF
|
||||||
|
widgets:
|
||||||
|
- label:
|
||||||
|
x: 6
|
||||||
|
y: 4
|
||||||
|
text_font: font_title
|
||||||
|
text_color: 0xFFB300
|
||||||
|
text: ${name}
|
||||||
|
- label:
|
||||||
|
id: unit_time
|
||||||
|
align: TOP_RIGHT
|
||||||
|
x: -6
|
||||||
|
y: 4
|
||||||
|
text_font: font_title
|
||||||
|
text: "--:--"
|
||||||
|
- label:
|
||||||
|
x: 6
|
||||||
|
y: 44
|
||||||
|
text_font: font_status
|
||||||
|
text_color: 0x8C8C8C
|
||||||
|
text: "Last line:"
|
||||||
|
- label:
|
||||||
|
id: unit_last_line
|
||||||
|
x: 6
|
||||||
|
y: 64
|
||||||
|
width: 228
|
||||||
|
long_mode: DOT
|
||||||
|
text_font: font_status
|
||||||
|
text: "-"
|
||||||
|
- bar:
|
||||||
|
id: unit_battery_bar
|
||||||
|
x: 6
|
||||||
|
y: 94
|
||||||
|
width: 228
|
||||||
|
height: 10
|
||||||
|
min_value: 0
|
||||||
|
max_value: 100
|
||||||
|
- label:
|
||||||
|
id: unit_battery
|
||||||
|
x: 6
|
||||||
|
y: 110
|
||||||
|
text_font: font_status
|
||||||
|
text: ""
|
||||||
Reference in new issue
Block a user