2 Commits

+16 -13
View File
@@ -375,16 +375,17 @@ class Meter {
const Color orange(255, 165, 0); const Color orange(255, 165, 0);
it.fill(bg); 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->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, 86, 8, "AUTO", status_active && this->auto_range() ? fg : inactive);
this->label_(it, font, 138, 8, "MAX", this->max_mode() ? red : inactive); this->label_(it, font, 138, 8, "MAX", status_active && this->max_mode() ? red : inactive);
this->label_(it, font, 178, 8, "MIN", this->min_mode() ? green : inactive); this->label_(it, font, 178, 8, "MIN", status_active && this->min_mode() ? green : inactive);
this->label_(it, font, 218, 8, "HOLD", this->hold() ? blue : inactive); this->label_(it, font, 218, 8, "HOLD", status_active && this->hold() ? blue : inactive);
this->label_(it, font, 270, 8, "REL", this->relative() ? Color(128, 128, 0) : 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, 66, "DC", status_active && this->dc() ? cyan : inactive);
this->label_(it, font, 8, 102, "AC", this->ac() ? magenta : inactive); this->label_(it, font, 8, 102, "AC", status_active && this->ac() ? magenta : inactive);
if (!this->connected) { if (!this->connected) {
this->draw_digits_(it, "----", false, inactive); this->draw_digits_(it, "----", false, inactive);
@@ -405,13 +406,15 @@ class Meter {
this->draw_decimal_points_(it, fg); this->draw_decimal_points_(it, fg);
} }
if (status_active) {
std::string unit_line = std::string(this->scale()) + this->unit(); std::string unit_line = std::string(this->scale()) + this->unit();
it.print(270, 140, font, yellow, esphome::display::TextAlign::CENTER, unit_line.c_str()); 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_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, 148, 16, 16, DIODE_BMP, status_active && this->diode() ? magenta : inactive);
this->draw_icon_(it, 300, 174, 16, 16, BUZZ_BMP, this->continuity() ? orange : 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(34, 212, 40, 24, this->write_available ? fg : inactive);
it.filled_rectangle(108, 212, 100, 24, this->write_available ? fg : inactive); it.filled_rectangle(108, 212, 100, 24, this->write_available ? fg : inactive);
@@ -574,12 +577,12 @@ class Meter {
void draw_segment_(Display &it, int x, int y, int w, int h, bool horizontal, Color color) { void draw_segment_(Display &it, int x, int y, int w, int h, bool horizontal, Color color) {
if (horizontal) { if (horizontal) {
int cap = h / 2; int cap = h / 2;
it.filled_rectangle(x + cap, y, w - 2 * cap, h, color); it.filled_rectangle(x + cap, y, w - 2 * cap, h +1, color);
it.filled_triangle(x, y + cap, x + cap, y, x + cap, y + h, color); it.filled_triangle(x, y + cap, x + cap, y, x + cap, y + h, color);
it.filled_triangle(x + w, y + cap, x + w - cap, y, x + w - cap, y + h, color); it.filled_triangle(x + w, y + cap, x + w - cap, y, x + w - cap, y + h, color);
} else { } else {
int cap = w / 2; int cap = w / 2;
it.filled_rectangle(x, y + cap, w, h - 2 * cap, color); it.filled_rectangle(x, y + cap, w +1, h - 2 * cap, color);
it.filled_triangle(x + cap, y, x, y + cap, x + w, y + cap, color); it.filled_triangle(x + cap, y, x, y + cap, x + w, y + cap, color);
it.filled_triangle(x + cap, y + h, x, y + h - cap, x + w, y + h - cap, color); it.filled_triangle(x + cap, y + h, x, y + h - cap, x + w, y + h - cap, color);
} }