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_btn_1.c (1016B)

      1 #include "../../lv_examples.h"
      2 #if LV_USE_BTN && LV_BUILD_EXAMPLES
      3 
      4 static void event_handler(lv_event_t * e)
      5 {
      6     lv_event_code_t code = lv_event_get_code(e);
      7 
      8     if(code == LV_EVENT_CLICKED) {
      9         LV_LOG_USER("Clicked");
     10     }
     11     else if(code == LV_EVENT_VALUE_CHANGED) {
     12         LV_LOG_USER("Toggled");
     13     }
     14 }
     15 
     16 void lv_example_btn_1(void)
     17 {
     18     lv_obj_t * label;
     19 
     20     lv_obj_t * btn1 = lv_btn_create(lv_scr_act());
     21     lv_obj_add_event_cb(btn1, event_handler, LV_EVENT_ALL, NULL);
     22     lv_obj_align(btn1, LV_ALIGN_CENTER, 0, -40);
     23 
     24     label = lv_label_create(btn1);
     25     lv_label_set_text(label, "Button");
     26     lv_obj_center(label);
     27 
     28     lv_obj_t * btn2 = lv_btn_create(lv_scr_act());
     29     lv_obj_add_event_cb(btn2, event_handler, LV_EVENT_ALL, NULL);
     30     lv_obj_align(btn2, LV_ALIGN_CENTER, 0, 40);
     31     lv_obj_add_flag(btn2, LV_OBJ_FLAG_CHECKABLE);
     32     lv_obj_set_height(btn2, LV_SIZE_CONTENT);
     33 
     34     label = lv_label_create(btn2);
     35     lv_label_set_text(label, "Toggle");
     36     lv_obj_center(label);
     37 }
     38 #endif