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_event_2.c (1339B)

      1 #include "../lv_examples.h"
      2 #if LV_BUILD_EXAMPLES && LV_USE_SWITCH
      3 
      4 static void event_cb(lv_event_t * e)
      5 {
      6     lv_event_code_t code = lv_event_get_code(e);
      7     lv_obj_t * label = lv_event_get_user_data(e);
      8 
      9     switch(code) {
     10         case LV_EVENT_PRESSED:
     11             lv_label_set_text(label, "The last button event:\nLV_EVENT_PRESSED");
     12             break;
     13         case LV_EVENT_CLICKED:
     14             lv_label_set_text(label, "The last button event:\nLV_EVENT_CLICKED");
     15             break;
     16         case LV_EVENT_LONG_PRESSED:
     17             lv_label_set_text(label, "The last button event:\nLV_EVENT_LONG_PRESSED");
     18             break;
     19         case LV_EVENT_LONG_PRESSED_REPEAT:
     20             lv_label_set_text(label, "The last button event:\nLV_EVENT_LONG_PRESSED_REPEAT");
     21             break;
     22         default:
     23             break;
     24     }
     25 }
     26 
     27 /**
     28  * Handle multiple events
     29  */
     30 void lv_example_event_2(void)
     31 {
     32     lv_obj_t * btn = lv_btn_create(lv_scr_act());
     33     lv_obj_set_size(btn, 100, 50);
     34     lv_obj_center(btn);
     35 
     36     lv_obj_t * btn_label = lv_label_create(btn);
     37     lv_label_set_text(btn_label, "Click me!");
     38     lv_obj_center(btn_label);
     39 
     40     lv_obj_t * info_label = lv_label_create(lv_scr_act());
     41     lv_label_set_text(info_label, "The last button event:\nNone");
     42 
     43     lv_obj_add_event_cb(btn, event_cb, LV_EVENT_ALL, info_label);
     44 }
     45 
     46 #endif