Switch to using display's definition of COLOR_ON/COLOR_OFF + improve ESP_LOGCONFIG() output

This commit is contained in:
Michael Davidson 2023-12-29 18:39:38 +11:00
parent 6e51b4f479
commit b721262759
No known key found for this signature in database
GPG key ID: B8D1A99712B8B0EB
2 changed files with 9 additions and 5 deletions

View file

@ -14,6 +14,7 @@ static const int TEXT_ALIGN_Y_MASK =
void TextPanel::dump_config(int indent_depth, int additional_level_depth) { void TextPanel::dump_config(int indent_depth, int additional_level_depth) {
std::string text = this->text_.value(); std::string text = this->text_.value();
ESP_LOGCONFIG(TAG, "%*sText Align: %s", indent_depth, "", display::text_align_to_string(this->text_align_));
ESP_LOGCONFIG(TAG, "%*sText: %s", indent_depth, "", text.c_str()); ESP_LOGCONFIG(TAG, "%*sText: %s", indent_depth, "", text.c_str());
} }

View file

@ -7,10 +7,13 @@
#include "esphome/core/automation.h" #include "esphome/core/automation.h"
namespace esphome { namespace esphome {
namespace graphical_layout { namespace display {
const Color COLOR_ON(255, 255, 255, 255); extern const Color COLOR_ON;
const Color COLOR_OFF(0, 0, 0, 0); extern const Color COLOR_OFF;
} // namespace display
namespace graphical_layout {
/** The TextPanel is a UI item that renders a single line of text to a display */ /** The TextPanel is a UI item that renders a single line of text to a display */
class TextPanel : public LayoutItem { class TextPanel : public LayoutItem {
@ -29,8 +32,8 @@ class TextPanel : public LayoutItem {
TemplatableValue<std::string> text_{}; TemplatableValue<std::string> text_{};
display::BaseFont *font_{nullptr}; display::BaseFont *font_{nullptr};
display::TextAlign text_align_{display::TextAlign::TOP_LEFT}; display::TextAlign text_align_{display::TextAlign::TOP_LEFT};
Color foreground_color_{COLOR_ON}; Color foreground_color_{display::COLOR_ON};
Color background_color_{COLOR_OFF}; Color background_color_{display::COLOR_OFF};
}; };
} // namespace graphical_layout } // namespace graphical_layout