acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

lv_example_bar_4.py (1102B)

      1 #
      2 # get an icon
      3 #
      4 def 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 
     27 img_skew_strip_dsc = get_icon("img_skew_strip",80,20)
     28 style_indic = lv.style_t()
     29 
     30 style_indic.init()
     31 style_indic.set_bg_img_src(img_skew_strip_dsc)
     32 style_indic.set_bg_img_tiled(True)
     33 style_indic.set_bg_img_opa(lv.OPA._30)
     34 
     35 bar = lv.bar(lv.scr_act())
     36 bar.add_style(style_indic, lv.PART.INDICATOR)
     37 
     38 bar.set_size(260, 20)
     39 bar.center()
     40 bar.set_mode(lv.bar.MODE.RANGE)
     41 bar.set_value(90, lv.ANIM.OFF)
     42 bar.set_start_value(20, lv.ANIM.OFF)
     43 
     44 
     45