1
0
mirror of https://github.com/esphome/esphome.git synced 2025-01-18 12:05:41 +00:00

[lvgl] fix bg_image_src (#8005)

Co-authored-by: clydeps <U5yx99dok9>
This commit is contained in:
Clyde Stubbs 2025-01-13 05:42:03 +11:00 committed by GitHub
parent 4530e4d60f
commit 8a98b69a57
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 1 deletions

View File

@ -59,6 +59,16 @@ inline void lv_img_set_src(lv_obj_t *obj, esphome::image::Image *image) {
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());
}
inline void lv_obj_set_style_bg_img_src(lv_obj_t *obj, esphome::image::Image *image, lv_style_selector_t selector) {
lv_obj_set_style_bg_img_src(obj, image->get_lv_img_dsc(), selector);
}
#ifdef USE_LVGL_METER
inline lv_meter_indicator_t *lv_meter_add_needle_img(lv_obj_t *obj, lv_meter_scale_t *scale, esphome::image::Image *src,
lv_coord_t pivot_x, lv_coord_t pivot_y) {
return lv_meter_add_needle_img(obj, scale, src->get_lv_img_dsc(), pivot_x, pivot_y);
}
#endif // USE_LVGL_METER
#endif // USE_LVGL_IMAGE
#ifdef USE_LVGL_ANIMIMG
inline void lv_animimg_set_src(lv_obj_t *img, std::vector<image::Image *> images) {

View File

@ -27,7 +27,7 @@ from ..defines import (
CONF_START_VALUE,
CONF_TICKS,
)
from ..helpers import add_lv_use
from ..helpers import add_lv_use, lvgl_components_required
from ..lv_validation import (
angle,
get_end_value,
@ -182,6 +182,7 @@ class MeterType(WidgetType):
async def to_code(self, w: Widget, config):
"""For a meter object, create and set parameters"""
lvgl_components_required.add(CONF_METER)
var = w.obj
for scale_conf in config.get(CONF_SCALES, ()):
rotation = 90 + (360 - scale_conf[CONF_ANGLE_RANGE]) / 2

View File

@ -49,6 +49,7 @@
#define USE_LVGL_IMAGE
#define USE_LVGL_KEY_LISTENER
#define USE_LVGL_KEYBOARD
#define USE_LVGL_METER
#define USE_LVGL_ROLLER
#define USE_LVGL_ROTARY_ENCODER
#define USE_LVGL_TOUCHSCREEN

View File

@ -132,6 +132,7 @@ lvgl:
pages:
- id: page1
bg_image_src: cat_image
on_load:
- logger.log: page loaded
- lvgl.widget.focus: