From 816cc35861abe94aa516d03cfc1078c8271205cc Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Thu, 28 May 2026 22:49:32 +0200 Subject: [PATCH] Implement dc-load inactivity display --- .../{lab-ble-proxy-owon.h => lab-ble-proxy.h} | 37 ++++++++++++------- esphome/lab-ble-proxy.yaml | 12 +++++- 2 files changed, 35 insertions(+), 14 deletions(-) rename esphome/{lab-ble-proxy-owon.h => lab-ble-proxy.h} (94%) diff --git a/esphome/lab-ble-proxy-owon.h b/esphome/lab-ble-proxy.h similarity index 94% rename from esphome/lab-ble-proxy-owon.h rename to esphome/lab-ble-proxy.h index ad36bca..29e0460 100644 --- a/esphome/lab-ble-proxy-owon.h +++ b/esphome/lab-ble-proxy.h @@ -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); } diff --git a/esphome/lab-ble-proxy.yaml b/esphome/lab-ble-proxy.yaml index 5833167..40939f4 100644 --- a/esphome/lab-ble-proxy.yaml +++ b/esphome/lab-ble-proxy.yaml @@ -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: