Implement dc-load inactivity display

This commit is contained in:
2026-05-28 22:49:32 +02:00
parent 058c186d63
commit 816cc35861
2 changed files with 35 additions and 14 deletions
@@ -431,10 +431,22 @@ class Meter {
} else {
// --- PAGE 2: Atorch DL24 DC load ---
it.fill(bg);
const Color panel(18, 24, 32);
const Color panel_active(18, 24, 32);
const Color panel_inactive(12, 12, 12);
const Color panel_dim(10, 14, 20);
const Color border(55, 70, 86);
const Color border_active(55, 70, 86);
const Color border_inactive(42, 42, 42);
const Color white(245, 245, 245);
const Color dim_value(110, 110, 110);
const Color dim_accent(65, 65, 65);
const Color panel = atorch_connected ? panel_active : panel_inactive;
const Color border = atorch_connected ? border_active : border_inactive;
const Color value_color = atorch_connected ? white : dim_value;
const Color voltage_color = atorch_connected ? cyan : dim_accent;
const Color current_color = atorch_connected ? orange : dim_accent;
const Color power_color = atorch_connected ? yellow : dim_accent;
const Color temp_color = atorch_connected ? magenta : dim_accent;
const Color header_color = atorch_connected ? cyan : dim_value;
char voltage_text[24];
char current_text[24];
@@ -447,25 +459,25 @@ class Meter {
this->format_metric_(capacity_text, sizeof(capacity_text), atorch_capacity, "Ah", 3);
this->format_metric_(temperature_text, sizeof(temperature_text), atorch_temperature, "°C", 1);
it.filled_rectangle(0, 0, 320, 30, panel_dim);
it.print(10, 7, font, cyan, esphome::display::TextAlign::TOP_LEFT, "ATORCH DL24");
it.filled_rectangle(0, 0, 320, 30, atorch_connected ? panel_dim : panel_inactive);
it.print(10, 7, font, header_color, esphome::display::TextAlign::TOP_LEFT, "ATORCH DL24");
if (atorch_connected) {
this->draw_icon_(it, 152, 7, 16, 16, BLE_BMP, blue);
}
it.print(310, 7, font, inactive, esphome::display::TextAlign::TOP_RIGHT, "DC LOAD");
this->draw_metric_card_(it, font, value_font, 10, 42, 145, 76, "VOLTAGE", voltage_text, cyan, panel, border);
this->draw_metric_card_(it, font, value_font, 165, 42, 145, 76, "CURRENT", current_text, orange, panel, border);
this->draw_metric_card_(it, font, value_font, 10, 128, 145, 76, "POWER", power_text, yellow, panel, border);
this->draw_metric_card_(it, font, value_font, 165, 128, 145, 76, "TEMP", temperature_text, magenta, panel, border);
this->draw_metric_card_(it, font, value_font, 10, 42, 145, 76, "VOLTAGE", voltage_text, voltage_color, panel, border, value_color);
this->draw_metric_card_(it, font, value_font, 165, 42, 145, 76, "CURRENT", current_text, current_color, panel, border, value_color);
this->draw_metric_card_(it, font, value_font, 10, 128, 145, 76, "POWER", power_text, power_color, panel, border, value_color);
this->draw_metric_card_(it, font, value_font, 165, 128, 145, 76, "TEMP", temperature_text, temp_color, panel, border, value_color);
it.filled_rectangle(10, 212, 300, 22, panel_dim);
it.filled_rectangle(10, 212, 300, 22, atorch_connected ? panel_dim : panel_inactive);
it.filled_rectangle(10, 212, 300, 1, border);
it.filled_rectangle(10, 233, 300, 1, border);
it.filled_rectangle(10, 212, 1, 22, border);
it.filled_rectangle(309, 212, 1, 22, border);
it.print(24, 216, font, inactive, esphome::display::TextAlign::TOP_LEFT, "CAPACITY");
it.print(306, 212, value_font, white, esphome::display::TextAlign::TOP_RIGHT, capacity_text);
it.print(306, 212, value_font, value_color, esphome::display::TextAlign::TOP_RIGHT, capacity_text);
}
}
@@ -608,9 +620,8 @@ class Meter {
void draw_metric_card_(Display &it, esphome::display::BaseFont *label_font, esphome::display::BaseFont *value_font,
int x, int y, int w, int h, const char *title, const char *value,
Color accent, Color fill, Color border) {
Color accent, Color fill, Color border, Color value_color) {
const Color bg(0, 0, 0);
const Color fg(235, 235, 235);
const Color inactive(90, 100, 110);
it.filled_rectangle(x, y, w, h, fill);
it.filled_rectangle(x, y, w, 2, accent);
@@ -618,7 +629,7 @@ class Meter {
it.filled_rectangle(x, y, 1, h, border);
it.filled_rectangle(x + w - 1, y, 1, h, border);
it.print(x + 10, y + 9, label_font, inactive, esphome::display::TextAlign::TOP_LEFT, title);
it.print(x + w / 2, y + 43, value_font, fg, esphome::display::TextAlign::CENTER, value);
it.print(x + w / 2, y + 43, value_font, value_color, esphome::display::TextAlign::CENTER, value);
it.filled_rectangle(x + 10, y + h - 11, w - 20, 3, bg);
it.filled_rectangle(x + 10, y + h - 11, w - 20, 1, accent);
}
+11 -1
View File
@@ -18,7 +18,7 @@ esphome:
comment: ${device_description}
min_version: 2024.6.0
includes:
- lab-ble-proxy-owon.h
- lab-ble-proxy.h
on_boot:
priority: 850
then:
@@ -105,10 +105,16 @@ ble_client:
then:
- lambda: |-
owon_meter.on_connect();
id(display_page) = 0;
id(lcd).update();
on_disconnect:
then:
- lambda: |-
owon_meter.on_disconnect();
if (id(display_page) == 0 && id(atorch_connected)) {
id(display_page) = 1;
}
id(lcd).update();
- mac_address: ${dl24_mac_address}
id: atorch_ble_client
@@ -116,11 +122,15 @@ ble_client:
then:
- lambda: |-
id(atorch_connected) = true;
id(display_page) = 1;
id(lcd).update();
on_disconnect:
then:
- lambda: |-
id(atorch_connected) = false;
if (id(display_page) == 1 && owon_meter.connected) {
id(display_page) = 0;
}
id(lcd).update();
atorch_dl24: