mirror of
https://github.com/esphome/esphome.git
synced 2026-05-28 13:37:24 +08:00
[core] Fix for missing arguments to shared_lambda (#12115)
This commit is contained in:
@@ -382,7 +382,7 @@ async def set_obj_properties(w: Widget, config):
|
|||||||
clrs = join_enums(flag_clr, "LV_OBJ_FLAG_")
|
clrs = join_enums(flag_clr, "LV_OBJ_FLAG_")
|
||||||
w.clear_flag(clrs)
|
w.clear_flag(clrs)
|
||||||
for key, value in lambs.items():
|
for key, value in lambs.items():
|
||||||
lamb = await cg.process_lambda(value, [], return_type=cg.bool_)
|
lamb = await cg.process_lambda(value, [], capture="=", return_type=cg.bool_)
|
||||||
flag = f"LV_OBJ_FLAG_{key.upper()}"
|
flag = f"LV_OBJ_FLAG_{key.upper()}"
|
||||||
with LvConditional(call_lambda(lamb)) as cond:
|
with LvConditional(call_lambda(lamb)) as cond:
|
||||||
w.add_flag(flag)
|
w.add_flag(flag)
|
||||||
@@ -407,7 +407,7 @@ async def set_obj_properties(w: Widget, config):
|
|||||||
clears = join_enums(clears, "LV_STATE_")
|
clears = join_enums(clears, "LV_STATE_")
|
||||||
w.clear_state(clears)
|
w.clear_state(clears)
|
||||||
for key, value in lambs.items():
|
for key, value in lambs.items():
|
||||||
lamb = await cg.process_lambda(value, [], return_type=cg.bool_)
|
lamb = await cg.process_lambda(value, [], capture="=", return_type=cg.bool_)
|
||||||
state = f"LV_STATE_{key.upper()}"
|
state = f"LV_STATE_{key.upper()}"
|
||||||
with LvConditional(call_lambda(lamb)) as cond:
|
with LvConditional(call_lambda(lamb)) as cond:
|
||||||
w.add_state(state)
|
w.add_state(state)
|
||||||
|
|||||||
@@ -659,7 +659,7 @@ async def get_variable_with_full_id(id_: ID) -> tuple[ID, "MockObj"]:
|
|||||||
async def process_lambda(
|
async def process_lambda(
|
||||||
value: Lambda,
|
value: Lambda,
|
||||||
parameters: TemplateArgsType,
|
parameters: TemplateArgsType,
|
||||||
capture: str = "=",
|
capture: str = "",
|
||||||
return_type: SafeExpType = None,
|
return_type: SafeExpType = None,
|
||||||
) -> LambdaExpression | None:
|
) -> LambdaExpression | None:
|
||||||
"""Process the given lambda value into a LambdaExpression.
|
"""Process the given lambda value into a LambdaExpression.
|
||||||
@@ -702,12 +702,6 @@ async def process_lambda(
|
|||||||
parts[i * 3 + 1] = var
|
parts[i * 3 + 1] = var
|
||||||
parts[i * 3 + 2] = ""
|
parts[i * 3 + 2] = ""
|
||||||
|
|
||||||
# All id() references are global variables in generated C++ code.
|
|
||||||
# Global variables should not be captured - they're accessible everywhere.
|
|
||||||
# Use empty capture instead of capture-by-value.
|
|
||||||
if capture == "=":
|
|
||||||
capture = ""
|
|
||||||
|
|
||||||
if isinstance(value, ESPHomeDataBase) and value.esp_range is not None:
|
if isinstance(value, ESPHomeDataBase) and value.esp_range is not None:
|
||||||
location = value.esp_range.start_mark
|
location = value.esp_range.start_mark
|
||||||
location.line += value.content_offset
|
location.line += value.content_offset
|
||||||
|
|||||||
@@ -16,6 +16,18 @@ binary_sensor:
|
|||||||
platform: template
|
platform: template
|
||||||
- id: left_sensor
|
- id: left_sensor
|
||||||
platform: template
|
platform: template
|
||||||
|
- platform: lvgl
|
||||||
|
id: button_checker
|
||||||
|
name: LVGL button
|
||||||
|
widget: button_button
|
||||||
|
on_state:
|
||||||
|
then:
|
||||||
|
- lvgl.checkbox.update:
|
||||||
|
id: checkbox_id
|
||||||
|
state:
|
||||||
|
checked: !lambda |-
|
||||||
|
auto y = x; // block inlining of one line return
|
||||||
|
return y;
|
||||||
|
|
||||||
lvgl:
|
lvgl:
|
||||||
log_level: debug
|
log_level: debug
|
||||||
|
|||||||
Reference in New Issue
Block a user