From f0cb74cc270273590fc74f82d7ec51a0831d6d6c Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Thu, 28 May 2026 13:40:46 +0200 Subject: [PATCH] Deactivate all indicator lights on meter disconnect. --- esphome/owon-b35t-m5stack-core2.h | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/esphome/owon-b35t-m5stack-core2.h b/esphome/owon-b35t-m5stack-core2.h index 3dd7ae5..a217f1d 100644 --- a/esphome/owon-b35t-m5stack-core2.h +++ b/esphome/owon-b35t-m5stack-core2.h @@ -375,16 +375,17 @@ class Meter { const Color orange(255, 165, 0); it.fill(bg); - this->draw_icon_(it, 12, 8, 16, 16, ACCU_BMP, this->low_battery ? red : green); + bool status_active = this->connected && this->has_reading; + this->draw_icon_(it, 12, 8, 16, 16, ACCU_BMP, status_active ? (this->low_battery ? red : green) : inactive); this->draw_icon_(it, 46, 8, 16, 16, BLE_BMP, this->connected ? blue : inactive); - this->label_(it, font, 86, 8, "AUTO", this->auto_range() ? fg : inactive); - this->label_(it, font, 138, 8, "MAX", this->max_mode() ? red : inactive); - this->label_(it, font, 178, 8, "MIN", this->min_mode() ? green : inactive); - this->label_(it, font, 218, 8, "HOLD", this->hold() ? blue : inactive); - this->label_(it, font, 270, 8, "REL", this->relative() ? Color(128, 128, 0) : inactive); + this->label_(it, font, 86, 8, "AUTO", status_active && this->auto_range() ? fg : inactive); + this->label_(it, font, 138, 8, "MAX", status_active && this->max_mode() ? red : inactive); + this->label_(it, font, 178, 8, "MIN", status_active && this->min_mode() ? green : inactive); + this->label_(it, font, 218, 8, "HOLD", status_active && this->hold() ? blue : inactive); + this->label_(it, font, 270, 8, "REL", status_active && this->relative() ? Color(128, 128, 0) : inactive); - this->label_(it, font, 8, 66, "DC", this->dc() ? cyan : inactive); - this->label_(it, font, 8, 102, "AC", this->ac() ? magenta : inactive); + this->label_(it, font, 8, 66, "DC", status_active && this->dc() ? cyan : inactive); + this->label_(it, font, 8, 102, "AC", status_active && this->ac() ? magenta : inactive); if (!this->connected) { this->draw_digits_(it, "----", false, inactive); @@ -405,13 +406,15 @@ class Meter { this->draw_decimal_points_(it, fg); } - std::string unit_line = std::string(this->scale()) + this->unit(); - it.print(270, 140, font, yellow, esphome::display::TextAlign::CENTER, unit_line.c_str()); + if (status_active) { + std::string unit_line = std::string(this->scale()) + this->unit(); + it.print(270, 140, font, yellow, esphome::display::TextAlign::CENTER, unit_line.c_str()); + } - bool bargraph_active = this->connected && this->has_reading && !this->overload; + bool bargraph_active = status_active && !this->overload; this->draw_bargraph_(it, bargraph_active ? this->digits_from_buffer_() : 0, bargraph_active); - this->draw_icon_(it, 300, 148, 16, 16, DIODE_BMP, this->diode() ? magenta : inactive); - this->draw_icon_(it, 300, 174, 16, 16, BUZZ_BMP, this->continuity() ? orange : inactive); + this->draw_icon_(it, 300, 148, 16, 16, DIODE_BMP, status_active && this->diode() ? magenta : inactive); + this->draw_icon_(it, 300, 174, 16, 16, BUZZ_BMP, status_active && this->continuity() ? orange : inactive); it.filled_rectangle(34, 212, 40, 24, this->write_available ? fg : inactive); it.filled_rectangle(108, 212, 100, 24, this->write_available ? fg : inactive);