Skip to content

Commit

Permalink
[lvgl] Bugfixes (esphome#7896)
Browse files Browse the repository at this point in the history
  • Loading branch information
clydebarrow authored Dec 3, 2024
1 parent dc5942a commit c95887a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion esphome/components/lvgl/defines.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def literal(arg):
def call_lambda(lamb: LambdaExpression):
expr = lamb.content.strip()
if expr.startswith("return") and expr.endswith(";"):
return expr[7:][:-1]
return expr[6:][:-1].strip()
return f"{lamb}()"


Expand Down
3 changes: 3 additions & 0 deletions esphome/components/lvgl/lvgl_esphome.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ static const display::ColorBitness LV_BITNESS = display::ColorBitness::COLOR_BIT
inline void lv_img_set_src(lv_obj_t *obj, esphome::image::Image *image) {
lv_img_set_src(obj, image->get_lv_img_dsc());
}
inline void lv_disp_set_bg_image(lv_disp_t *disp, esphome::image::Image *image) {
lv_disp_set_bg_image(disp, image->get_lv_img_dsc());
}
#endif // USE_LVGL_IMAGE
#ifdef USE_LVGL_ANIMIMG
inline void lv_animimg_set_src(lv_obj_t *img, std::vector<image::Image *> images) {
Expand Down
6 changes: 6 additions & 0 deletions esphome/components/lvgl/widgets/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ def cv_point_list(value):
cv.GenerateID(CONF_POINT_LIST_ID): cv.declare_id(lv_point_t),
}

LINE_MODIFY_SCHEMA = {
cv.Optional(CONF_POINTS): cv_point_list,
cv.GenerateID(CONF_POINT_LIST_ID): cv.declare_id(lv_point_t),
}


class LineType(WidgetType):
def __init__(self):
Expand All @@ -43,6 +48,7 @@ def __init__(self):
LvType("lv_line_t"),
(CONF_MAIN,),
LINE_SCHEMA,
modify_schema=LINE_MODIFY_SCHEMA,
)

async def to_code(self, w: Widget, config):
Expand Down
4 changes: 2 additions & 2 deletions tests/components/lvgl/lvgl-package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ lvgl:
id: button_button
width: 20%
height: 10%
transform_angle: !lambda return 180*100;
transform_angle: !lambda return(180*100);
arc_width: !lambda return 4;
border_width: !lambda return 6;
shadow_ofs_x: !lambda return 6;
Expand Down Expand Up @@ -581,7 +581,7 @@ lvgl:
- 180, 60
- 240, 10
on_click:
- lvgl.widget.update:
- lvgl.line.update:
id: lv_line_id
line_color: 0xFFFF
- lvgl.page.next:
Expand Down

0 comments on commit c95887a

Please sign in to comment.