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_calendar_1.c (1599B)

      1 #include "../../lv_examples.h"
      2 #if LV_USE_CALENDAR && 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     lv_obj_t * obj = lv_event_get_current_target(e);
      8 
      9     if(code == LV_EVENT_VALUE_CHANGED) {
     10         lv_calendar_date_t date;
     11         if(lv_calendar_get_pressed_date(obj, &date)) {
     12             LV_LOG_USER("Clicked date: %02d.%02d.%d", date.day, date.month, date.year);
     13         }
     14     }
     15 }
     16 
     17 void lv_example_calendar_1(void)
     18 {
     19     lv_obj_t  * calendar = lv_calendar_create(lv_scr_act());
     20     lv_obj_set_size(calendar, 185, 185);
     21     lv_obj_align(calendar, LV_ALIGN_CENTER, 0, 27);
     22     lv_obj_add_event_cb(calendar, event_handler, LV_EVENT_ALL, NULL);
     23 
     24     lv_calendar_set_today_date(calendar, 2021, 02, 23);
     25     lv_calendar_set_showed_date(calendar, 2021, 02);
     26 
     27     /*Highlight a few days*/
     28     static lv_calendar_date_t highlighted_days[3];       /*Only its pointer will be saved so should be static*/
     29     highlighted_days[0].year = 2021;
     30     highlighted_days[0].month = 02;
     31     highlighted_days[0].day = 6;
     32 
     33     highlighted_days[1].year = 2021;
     34     highlighted_days[1].month = 02;
     35     highlighted_days[1].day = 11;
     36 
     37     highlighted_days[2].year = 2022;
     38     highlighted_days[2].month = 02;
     39     highlighted_days[2].day = 22;
     40 
     41     lv_calendar_set_highlighted_dates(calendar, highlighted_days, 3);
     42 
     43 #if LV_USE_CALENDAR_HEADER_DROPDOWN
     44     lv_calendar_header_dropdown_create(calendar);
     45 #elif LV_USE_CALENDAR_HEADER_ARROW
     46     lv_calendar_header_arrow_create(calendar);
     47 #endif
     48     lv_calendar_set_showed_date(calendar, 2021, 10);
     49 }
     50 
     51 #endif