mirror of
https://github.com/esphome/esphome.git
synced 2026-02-08 00:31:58 +00:00
[lvgl] Fix lambda return types for coord and font validators (#12113)
This commit is contained in:
@@ -40,7 +40,7 @@ from .helpers import (
|
||||
lv_fonts_used,
|
||||
requires_component,
|
||||
)
|
||||
from .types import lv_font_t, lv_gradient_t
|
||||
from .types import lv_gradient_t
|
||||
|
||||
opacity_consts = LvConstant("LV_OPA_", "TRANSP", "COVER")
|
||||
|
||||
@@ -498,7 +498,9 @@ class LvFont(LValidator):
|
||||
esphome_fonts_used.add(fontval)
|
||||
return requires_component("font")(fontval)
|
||||
|
||||
super().__init__(validator, lv_font_t)
|
||||
# Use font::Font* as return type for lambdas returning ESPHome fonts
|
||||
# The inline overloads in lvgl_esphome.h handle conversion to lv_font_t*
|
||||
super().__init__(validator, Font.operator("ptr"))
|
||||
|
||||
async def process(self, value, args=()):
|
||||
if is_lv_font(value):
|
||||
|
||||
@@ -6,7 +6,7 @@ from esphome.core import Lambda
|
||||
from ..defines import CONF_MAIN, call_lambda
|
||||
from ..lvcode import lv_add
|
||||
from ..schemas import point_schema
|
||||
from ..types import LvCompound, LvType
|
||||
from ..types import LvCompound, LvType, lv_coord_t
|
||||
from . import Widget, WidgetType
|
||||
|
||||
CONF_LINE = "line"
|
||||
@@ -23,9 +23,7 @@ LINE_SCHEMA = {
|
||||
|
||||
async def process_coord(coord):
|
||||
if isinstance(coord, Lambda):
|
||||
coord = call_lambda(
|
||||
await cg.process_lambda(coord, [], return_type="lv_coord_t")
|
||||
)
|
||||
coord = call_lambda(await cg.process_lambda(coord, [], return_type=lv_coord_t))
|
||||
if not coord.endswith("()"):
|
||||
coord = f"static_cast<lv_coord_t>({coord})"
|
||||
return cg.RawExpression(coord)
|
||||
|
||||
Reference in New Issue
Block a user