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
+75
-17
+75
-17
@@ -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,6 +433,7 @@ font:
|
|||||||
glyphsets: [GF_Latin_Kernel]
|
glyphsets: [GF_Latin_Kernel]
|
||||||
|
|
||||||
lvgl:
|
lvgl:
|
||||||
|
- id: lvgl_main
|
||||||
displays: display_tft
|
displays: display_tft
|
||||||
touchscreens: touch_lcd
|
touchscreens: touch_lcd
|
||||||
buffer_size: 25%
|
buffer_size: 25%
|
||||||
@@ -553,3 +561,53 @@ lvgl:
|
|||||||
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