1#
2# get an icon
3#
4def get_icon(filename,xres,yres):
5    try:
6        sdl_filename = "../../assets/" + filename + "_" + str(xres) + "x" + str(yres) + "_argb8888.fnt"
7        print("file name: ", sdl_filename)
8        with open(sdl_filename,'rb') as f:
9            icon_data = f.read()
10    except:
11        print("Could not find image file: " + filename)
12        return None
13
14    icon_dsc = lv.img_dsc_t(
15        {
16            "header": {"always_zero": 0, "w": xres, "h": yres, "cf": lv.img.CF.TRUE_COLOR_ALPHA},
17            "data": icon_data,
18            "data_size": len(icon_data),
19        }
20    )
21    return icon_dsc
22
23#
24# Bar with stripe pattern and ranged value
25#
26
27img_skew_strip_dsc = get_icon("img_skew_strip",80,20)
28style_indic = lv.style_t()
29
30style_indic.init()
31style_indic.set_bg_img_src(img_skew_strip_dsc)
32style_indic.set_bg_img_tiled(True)
33style_indic.set_bg_img_opa(lv.OPA._30)
34
35bar = lv.bar(lv.scr_act())
36bar.add_style(style_indic, lv.PART.INDICATOR)
37
38bar.set_size(260, 20)
39bar.center()
40bar.set_mode(lv.bar.MODE.RANGE)
41bar.set_value(90, lv.ANIM.OFF)
42bar.set_start_value(20, lv.ANIM.OFF)
43
44
45
46