1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-04 04:12:23 +01:00

[mipi] Refactor constants and functions (#9853)

This commit is contained in:
Clyde Stubbs
2025-07-24 11:27:05 +10:00
committed by GitHub
parent f9534fbd5d
commit 3960e2bae7
19 changed files with 488 additions and 421 deletions

View File

@@ -2,7 +2,7 @@ import logging
from esphome.automation import build_automation, register_action, validate_automation
import esphome.codegen as cg
from esphome.components.const import CONF_DRAW_ROUNDING
from esphome.components.const import CONF_COLOR_DEPTH, CONF_DRAW_ROUNDING
from esphome.components.display import Display
import esphome.config_validation as cv
from esphome.const import (
@@ -186,7 +186,7 @@ def multi_conf_validate(configs: list[dict]):
for config in configs[1:]:
for item in (
df.CONF_LOG_LEVEL,
df.CONF_COLOR_DEPTH,
CONF_COLOR_DEPTH,
df.CONF_BYTE_ORDER,
df.CONF_TRANSPARENCY_KEY,
):
@@ -275,11 +275,11 @@ async def to_code(configs):
"LVGL_LOG_LEVEL",
cg.RawExpression(f"ESPHOME_LOG_LEVEL_{config_0[df.CONF_LOG_LEVEL]}"),
)
add_define("LV_COLOR_DEPTH", config_0[df.CONF_COLOR_DEPTH])
add_define("LV_COLOR_DEPTH", config_0[CONF_COLOR_DEPTH])
for font in helpers.lv_fonts_used:
add_define(f"LV_FONT_{font.upper()}")
if config_0[df.CONF_COLOR_DEPTH] == 16:
if config_0[CONF_COLOR_DEPTH] == 16:
add_define(
"LV_COLOR_16_SWAP",
"1" if config_0[df.CONF_BYTE_ORDER] == "big_endian" else "0",
@@ -416,7 +416,7 @@ LVGL_SCHEMA = cv.All(
{
cv.GenerateID(CONF_ID): cv.declare_id(LvglComponent),
cv.GenerateID(df.CONF_DISPLAYS): display_schema,
cv.Optional(df.CONF_COLOR_DEPTH, default=16): cv.one_of(16),
cv.Optional(CONF_COLOR_DEPTH, default=16): cv.one_of(16),
cv.Optional(
df.CONF_DEFAULT_FONT, default="montserrat_14"
): lvalid.lv_font,

View File

@@ -418,7 +418,6 @@ CONF_BUTTONS = "buttons"
CONF_BYTE_ORDER = "byte_order"
CONF_CHANGE_RATE = "change_rate"
CONF_CLOSE_BUTTON = "close_button"
CONF_COLOR_DEPTH = "color_depth"
CONF_CONTROL = "control"
CONF_DEFAULT_FONT = "default_font"
CONF_DEFAULT_GROUP = "default_group"