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_switch_1.py (813B)

      1 def event_handler(e):
      2     code = e.get_code()
      3     obj = e.get_target()
      4     if code == lv.EVENT.VALUE_CHANGED:
      5         if obj.has_state(lv.STATE.CHECKED):
      6             print("State: on")
      7         else:
      8             print("State: off")
      9 
     10 
     11 lv.scr_act().set_flex_flow(lv.FLEX_FLOW.COLUMN)
     12 lv.scr_act().set_flex_align(lv.FLEX_ALIGN.CENTER, lv.FLEX_ALIGN.CENTER, lv.FLEX_ALIGN.CENTER)
     13 
     14 sw = lv.switch(lv.scr_act())
     15 sw.add_event_cb(event_handler,lv.EVENT.ALL, None)
     16 
     17 sw = lv.switch(lv.scr_act())
     18 sw.add_state(lv.STATE.CHECKED)
     19 sw.add_event_cb(event_handler, lv.EVENT.ALL, None)
     20 
     21 sw = lv.switch(lv.scr_act())
     22 sw.add_state(lv.STATE.DISABLED)
     23 sw.add_event_cb(event_handler, lv.EVENT.ALL, None)
     24 
     25 sw = lv.switch(lv.scr_act())
     26 sw.add_state(lv.STATE.CHECKED | lv.STATE.DISABLED)
     27 sw.add_event_cb(event_handler, lv.EVENT.ALL, None)
     28