Display aestethics: taller 7-segments, repositioned minus, mode and

icons
This commit is contained in:
2026-05-30 17:49:56 +02:00
parent 2a1902ccf1
commit c21f2a5c7b
+50 -13
View File
@@ -148,6 +148,44 @@ static const uint8_t BLE_BMP[32] = {
0b00000001, 0b10000000,
};
static const uint8_t HOLD_BMP[32] = {
0b01111111, 0b11111110,
0b11111111, 0b11111111,
0b11100011, 0b11000111,
0b11100011, 0b11000111,
0b11100011, 0b11000111,
0b11100011, 0b11000111,
0b11100011, 0b11000111,
0b11100000, 0b00000111,
0b11100000, 0b00000111,
0b11100011, 0b11000111,
0b11100011, 0b11000111,
0b11100011, 0b11000111,
0b11100011, 0b11000111,
0b11100011, 0b11000111,
0b11111111, 0b11111111,
0b01111111, 0b11111110,
};
static const uint8_t REL_BMP[32] = {
0b00000001, 0b00000000,
0b00000001, 0b00000000,
0b00000011, 0b10000000,
0b00000011, 0b10000000,
0b00000110, 0b11000000,
0b00000110, 0b11000000,
0b00001100, 0b01100000,
0b00001100, 0b01100000,
0b00011000, 0b00110000,
0b00011000, 0b00110000,
0b00110000, 0b00011000,
0b00110000, 0b00011000,
0b01100000, 0b00001100,
0b01100000, 0b00001100,
0b11111111, 0b11111110,
0b11111111, 0b11111110,
};
static const uint8_t DIODE_BMP[32] = {
0b00001000, 0b00011000,
0b00001100, 0b00011000,
@@ -387,11 +425,13 @@ class Meter {
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->draw_icon_(it, 218, 8, 16, 16, HOLD_BMP, status_active && this->hold() ? blue : inactive);
this->draw_icon_(it, 244, 8, 16, 16, REL_BMP, status_active && this->relative() ? Color(128, 128, 0) : inactive);
this->draw_icon_(it, 270, 8, 16, 16, DIODE_BMP, status_active && this->diode() ? magenta : inactive);
this->draw_icon_(it, 296, 8, 16, 16, BUZZ_BMP, status_active && this->continuity() ? orange : 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);
this->label_(it, font, 8, 104, "DC", status_active && this->dc() ? cyan : inactive);
this->label_(it, font, 8, 124, "AC", status_active && this->ac() ? magenta : inactive);
if (!this->connected) {
this->draw_digits_(it, "----", false, inactive);
@@ -414,14 +454,11 @@ class Meter {
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());
it.print(316, 141, font, yellow, esphome::display::TextAlign::BOTTOM_RIGHT, unit_line.c_str());
}
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, 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);
it.filled_rectangle(242, 212, 40, 24, this->write_available ? fg : inactive);
@@ -643,11 +680,11 @@ class Meter {
}
void draw_digits_(Display &it, const char *text, bool negative, Color color) {
if (negative) this->draw_segment_(it, 8, 88, 26, 9, true, color);
if (negative) this->draw_segment_(it, 8, 83, 26, 9, true, color);
constexpr int digit_x = 40;
constexpr int digit_y = 35;
constexpr int digit_w = 50;
constexpr int digit_h = 88;
constexpr int digit_h = 106;
constexpr int digit_distance = 64;
for (int i = 0; i < 4; i++) {
this->draw_seven_segment_(it, digit_x + i * digit_distance, digit_y, digit_w, digit_h, text[i], color);
@@ -656,9 +693,9 @@ class Meter {
void draw_decimal_points_(Display &it, Color color) {
uint8_t p = this->value_[REGPOINT];
if ((p & FLAGPOINT1) == FLAGPOINT1) it.filled_rectangle(95, 117, 8, 10, color);
if ((p & FLAGPOINT2) == FLAGPOINT2) it.filled_rectangle(159, 117, 8, 10, color);
if ((p & FLAGPOINT3) == FLAGPOINT3) it.filled_rectangle(223, 117, 8, 10, color);
if ((p & FLAGPOINT1) == FLAGPOINT1) it.filled_rectangle(95, 135, 8, 10, color);
if ((p & FLAGPOINT2) == FLAGPOINT2) it.filled_rectangle(159, 135, 8, 10, color);
if ((p & FLAGPOINT3) == FLAGPOINT3) it.filled_rectangle(223, 135, 8, 10, color);
}
void draw_segment_(Display &it, int x, int y, int w, int h, bool horizontal, Color color) {