Remove dead values from HA and rendering code. Also increase font size.
This commit is contained in:
@@ -362,10 +362,10 @@ class Meter {
|
||||
}
|
||||
|
||||
void render(esphome::display::Display &it, esphome::display::BaseFont *font,
|
||||
int display_page = 0, bool atorch_running = false,
|
||||
esphome::display::BaseFont *value_font, int display_page = 0,
|
||||
bool atorch_connected = false,
|
||||
float atorch_voltage = NAN, float atorch_current = NAN, float atorch_power = NAN,
|
||||
float atorch_capacity = NAN, float atorch_energy = NAN, float atorch_temperature = NAN,
|
||||
const char *atorch_runtime = "--:--:--") {
|
||||
float atorch_capacity = NAN, float atorch_temperature = NAN) {
|
||||
const Color bg(0, 0, 0);
|
||||
const Color fg(210, 210, 210);
|
||||
// Chosen to map to a neutral dark gray in the RGB332 8-bit display palette.
|
||||
@@ -440,35 +440,32 @@ class Meter {
|
||||
char current_text[24];
|
||||
char power_text[24];
|
||||
char capacity_text[24];
|
||||
char energy_text[24];
|
||||
char temperature_text[24];
|
||||
this->format_metric_(voltage_text, sizeof(voltage_text), atorch_voltage, "V", 2);
|
||||
this->format_metric_(current_text, sizeof(current_text), atorch_current, "A", 3);
|
||||
this->format_metric_(power_text, sizeof(power_text), atorch_power, "W", 2);
|
||||
this->format_metric_(capacity_text, sizeof(capacity_text), atorch_capacity, "Ah", 3);
|
||||
this->format_metric_(energy_text, sizeof(energy_text), atorch_energy, "Wh", 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(230, 6, 80, 18, atorch_running ? green : inactive);
|
||||
it.print(270, 8, font, bg, esphome::display::TextAlign::TOP_CENTER, atorch_running ? "RUNNING" : "STOPPED");
|
||||
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, 10, 42, 145, 70, "VOLTAGE", voltage_text, cyan, panel, border);
|
||||
this->draw_metric_card_(it, font, 165, 42, 145, 70, "CURRENT", current_text, orange, panel, border);
|
||||
this->draw_metric_card_(it, font, 10, 122, 145, 70, "POWER", power_text, yellow, panel, border);
|
||||
this->draw_metric_card_(it, font, 165, 122, 145, 70, "TEMP", temperature_text, magenta, panel, border);
|
||||
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);
|
||||
|
||||
it.filled_rectangle(10, 202, 300, 30, panel_dim);
|
||||
it.filled_rectangle(10, 202, 300, 1, border);
|
||||
it.filled_rectangle(10, 231, 300, 1, border);
|
||||
it.filled_rectangle(10, 202, 1, 30, border);
|
||||
it.filled_rectangle(309, 202, 1, 30, border);
|
||||
it.print(24, 209, font, inactive, esphome::display::TextAlign::TOP_LEFT, "CAP");
|
||||
it.print(67, 209, font, white, esphome::display::TextAlign::TOP_LEFT, capacity_text);
|
||||
it.print(143, 209, font, inactive, esphome::display::TextAlign::TOP_LEFT, "ENERGY");
|
||||
it.print(206, 209, font, white, esphome::display::TextAlign::TOP_LEFT, energy_text);
|
||||
it.print(306, 209, font, green, esphome::display::TextAlign::TOP_RIGHT, atorch_runtime);
|
||||
it.filled_rectangle(10, 212, 300, 22, panel_dim);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -609,8 +606,9 @@ class Meter {
|
||||
snprintf(buffer, size, format, value, unit);
|
||||
}
|
||||
|
||||
void draw_metric_card_(Display &it, esphome::display::BaseFont *font, int x, int y, int w, int h,
|
||||
const char *title, const char *value, Color accent, Color fill, Color border) {
|
||||
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) {
|
||||
const Color bg(0, 0, 0);
|
||||
const Color fg(235, 235, 235);
|
||||
const Color inactive(90, 100, 110);
|
||||
@@ -619,8 +617,8 @@ class Meter {
|
||||
it.filled_rectangle(x, y + h - 1, w, 1, border);
|
||||
it.filled_rectangle(x, y, 1, h, border);
|
||||
it.filled_rectangle(x + w - 1, y, 1, h, border);
|
||||
it.print(x + 10, y + 10, font, inactive, esphome::display::TextAlign::TOP_LEFT, title);
|
||||
it.print(x + w / 2, y + 38, font, fg, esphome::display::TextAlign::CENTER, value);
|
||||
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.filled_rectangle(x + 10, y + h - 11, w - 20, 3, bg);
|
||||
it.filled_rectangle(x + 10, y + h - 11, w - 20, 1, accent);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user