diff --git a/esphome/components/graphical_display_menu/__init__.py b/esphome/components/graphical_display_menu/__init__.py index dc49358efd..d49c456d66 100644 --- a/esphome/components/graphical_display_menu/__init__.py +++ b/esphome/components/graphical_display_menu/__init__.py @@ -1,7 +1,12 @@ import esphome.codegen as cg import esphome.config_validation as cv from esphome.components import display, font, color -from esphome.const import CONF_ID, CONF_TRIGGER_ID +from esphome.const import ( + CONF_ID, + CONF_TRIGGER_ID, + CONF_FOREGROUND_COLOR, + CONF_BACKGROUND_COLOR, +) from esphome import automation, core from esphome.components.display_menu_base import ( @@ -13,8 +18,6 @@ from esphome.components.display_menu_base import ( CONF_DISPLAY = "display" CONF_FONT = "font" CONF_MENU_ITEM_VALUE = "menu_item_value" -CONF_FOREGROUND_COLOR = "foreground_color" -CONF_BACKGROUND_COLOR = "background_color" CONF_ON_REDRAW = "on_redraw" graphical_display_menu_ns = cg.esphome_ns.namespace("graphical_display_menu") diff --git a/esphome/components/graphical_layout/fixed_dimension_panel.cpp b/esphome/components/graphical_layout/fixed_dimension_panel.cpp index a52c449cb8..784bd377ef 100644 --- a/esphome/components/graphical_layout/fixed_dimension_panel.cpp +++ b/esphome/components/graphical_layout/fixed_dimension_panel.cpp @@ -10,9 +10,9 @@ namespace graphical_layout { static const char *const TAG = "fixeddimensionpanel"; void FixedDimensionPanel::dump_config(int indent_depth, int additional_level_depth) { - ESP_LOGCONFIG(TAG, "%*sWidth: %i (Will use display width: %s)", indent_depth, "", this->width_.value(), + ESP_LOGCONFIG(TAG, "%*sWidth: %i (Will use display width: %s)", indent_depth, "", this->width_.value(), YESNO(this->width_.value() < 1)); -+ ESP_LOGCONFIG(TAG, "%*sHeight: %i (Will use display height: %s)", indent_depth, "", this->height_.value(), + ESP_LOGCONFIG(TAG, "%*sHeight: %i (Will use display height: %s)", indent_depth, "", this->height_.value(), YESNO(this->height_.value() < 1)); this->child_->dump_config(indent_depth + additional_level_depth, additional_level_depth); } diff --git a/esphome/components/graphical_layout/layout_item.cpp b/esphome/components/graphical_layout/layout_item.cpp index e6a2f44e7a..7f65746979 100644 --- a/esphome/components/graphical_layout/layout_item.cpp +++ b/esphome/components/graphical_layout/layout_item.cpp @@ -70,7 +70,7 @@ const LogString *horizontal_child_align_to_string(HorizontalChildAlign align) { } } -const LogString *vertical_child_align_to_string(VerticalChildAlign align) { +const LogString *vertical_child_align_to_string(VerticalChildAlign align) { switch (align) { case VerticalChildAlign::TOP: return LOG_STR("TOP"); diff --git a/esphome/components/graphical_layout/text_panel.py b/esphome/components/graphical_layout/text_panel.py index 1f5b02aab1..9250a8c8e2 100644 --- a/esphome/components/graphical_layout/text_panel.py +++ b/esphome/components/graphical_layout/text_panel.py @@ -2,6 +2,7 @@ import esphome.codegen as cg import esphome.config_validation as cv from esphome.components import font, color from esphome.components.display import display_ns +# from esphome.const import CONF_FOREGROUND_COLOR, CONF_BACKGROUND_COLOR graphical_layout_ns = cg.esphome_ns.namespace("graphical_layout") TextPanel = graphical_layout_ns.class_("TextPanel") @@ -9,8 +10,6 @@ TextAlign = display_ns.enum("TextAlign", is_class=True) CONF_TEXT_PANEL = "text_panel" CONF_FONT = "font" -CONF_FOREGROUND_COLOR = "foreground_color" -CONF_BACKGROUND_COLOR = "background_color" CONF_TEXT = "text" CONF_TEXT_ALIGN = "text_align" diff --git a/esphome/components/graphical_layout/text_run_panel.cpp b/esphome/components/graphical_layout/text_run_panel.cpp index 41b19e9d7c..66b096daf3 100644 --- a/esphome/components/graphical_layout/text_run_panel.cpp +++ b/esphome/components/graphical_layout/text_run_panel.cpp @@ -48,7 +48,7 @@ void TextRunPanel::render_internal(display::Display *display, display::Rect boun calculated->run->background_color_); } display->print(calculated->bounds.x, calculated->bounds.y, calculated->run->font_, - calculated->run->foreground_color_, display::TextAlign::TOP_LEFT, calculated->text_.c_str() + calculated->run->foreground_color_, display::TextAlign::TOP_LEFT, calculated->text_.c_str()); } if (this->debug_outline_runs_) { @@ -232,8 +232,9 @@ void TextRunPanel::apply_alignment_to_layout(CalculatedLayout *calculated_layout switch (y_align) { case display::TextAlign::BOTTOM: { - y_adjustment = max_line_height - run->bounds.h; - ESP_LOGVV(TAG, "Will adjust line %i by %i y-pixels (%i vs %i)", i, y_adjustment, max_line_height, run->bounds.h); + y_adjustment = max_line_height - run->bounds.h; + ESP_LOGVV(TAG, "Will adjust line %i by %i y-pixels (%i vs %i)", i, y_adjustment, max_line_height, + run->bounds.h); break; } case display::TextAlign::CENTER_VERTICAL: { diff --git a/esphome/components/graphical_layout/text_run_panel.py b/esphome/components/graphical_layout/text_run_panel.py index 2cc11b781c..5b46b36812 100644 --- a/esphome/components/graphical_layout/text_run_panel.py +++ b/esphome/components/graphical_layout/text_run_panel.py @@ -2,7 +2,7 @@ import esphome.codegen as cg import esphome.config_validation as cv from esphome.components import font, color from esphome.components.display import display_ns -from esphome.const import CONF_ID +from esphome.const import CONF_ID#, CONF_FOREGROUND_COLOR, CONF_BACKGROUND_COLOR graphical_layout_ns = cg.esphome_ns.namespace("graphical_layout") TextRunPanel = graphical_layout_ns.class_("TextRunPanel") @@ -11,8 +11,6 @@ TextRun = graphical_layout_ns.class_("TextRun") CONF_TEXT_RUN_PANEL = "text_run_panel" CONF_FONT = "font" -CONF_FOREGROUND_COLOR = "foreground_color" -CONF_BACKGROUND_COLOR = "background_color" CONF_TEXT = "text" CONF_TEXT_ALIGN = "text_align" CONF_MAX_WIDTH = "max_width" @@ -20,7 +18,6 @@ CONF_MIN_WIDTH = "min_width" CONF_RUNS = "runs" CONF_DEBUG_OUTLINE_RUNS = "debug_outline_runs" - TEXT_ALIGN = { "TOP_LEFT": TextAlign.TOP_LEFT, "TOP_CENTER": TextAlign.TOP_CENTER, diff --git a/esphome/components/nextion/base_component.py b/esphome/components/nextion/base_component.py index 784da35371..1cc2b43588 100644 --- a/esphome/components/nextion/base_component.py +++ b/esphome/components/nextion/base_component.py @@ -4,6 +4,8 @@ import esphome.codegen as cg from esphome.components import color from esphome.const import ( CONF_VISIBLE, + CONF_FOREGROUND_COLOR, + CONF_BACKGROUND_COLOR, ) from . import CONF_NEXTION_ID from . import Nextion @@ -24,9 +26,7 @@ CONF_WAKE_UP_PAGE = "wake_up_page" CONF_START_UP_PAGE = "start_up_page" CONF_AUTO_WAKE_ON_TOUCH = "auto_wake_on_touch" CONF_WAVE_MAX_LENGTH = "wave_max_length" -CONF_BACKGROUND_COLOR = "background_color" CONF_BACKGROUND_PRESSED_COLOR = "background_pressed_color" -CONF_FOREGROUND_COLOR = "foreground_color" CONF_FOREGROUND_PRESSED_COLOR = "foreground_pressed_color" CONF_FONT_ID = "font_id" CONF_EXIT_REPARSE_ON_START = "exit_reparse_on_start" diff --git a/esphome/const.py b/esphome/const.py index 7e27254d76..d06667da0b 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -70,6 +70,7 @@ CONF_AWAY = "away" CONF_AWAY_COMMAND_TOPIC = "away_command_topic" CONF_AWAY_CONFIG = "away_config" CONF_AWAY_STATE_TOPIC = "away_state_topic" +CONF_BACKGROUND_COLOR = "background_color" CONF_BACKLIGHT_PIN = "backlight_pin" CONF_BASELINE = "baseline" CONF_BATTERY_LEVEL = "battery_level" @@ -288,6 +289,7 @@ CONF_FLOW = "flow" CONF_FLOW_CONTROL_PIN = "flow_control_pin" CONF_FOR = "for" CONF_FORCE_UPDATE = "force_update" +CONF_FOREGROUND_COLOR = "foreground_color" CONF_FORMALDEHYDE = "formaldehyde" CONF_FORMAT = "format" CONF_FORWARD_ACTIVE_ENERGY = "forward_active_energy"