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_calendar.h (4685B)

      1 /**
      2  * @file lv_calendar.h
      3  *
      4  */
      5 
      6 #ifndef LV_CALENDAR_H
      7 #define LV_CALENDAR_H
      8 
      9 #ifdef __cplusplus
     10 extern "C" {
     11 #endif
     12 
     13 /*********************
     14  *      INCLUDES
     15  *********************/
     16 #include "../../../widgets/lv_btnmatrix.h"
     17 
     18 #if LV_USE_CALENDAR
     19 
     20 /*********************
     21  *      DEFINES
     22  *********************/
     23 
     24 /**********************
     25  *      TYPEDEFS
     26  **********************/
     27 
     28 /**
     29  * Represents a date on the calendar object (platform-agnostic).
     30  */
     31 typedef struct {
     32     uint16_t year;
     33     int8_t month;  /** 1..12*/
     34     int8_t day;    /** 1..31*/
     35 } lv_calendar_date_t;
     36 
     37 /*Data of calendar*/
     38 typedef struct {
     39     lv_obj_t obj;
     40     lv_obj_t * btnm;
     41     /*New data for this type*/
     42     lv_calendar_date_t today;               /*Date of today*/
     43     lv_calendar_date_t showed_date;         /*Currently visible month (day is ignored)*/
     44     lv_calendar_date_t *
     45     highlighted_dates; /*Apply different style on these days (pointer to an array defined by the user)*/
     46     uint16_t highlighted_dates_num;          /*Number of elements in `highlighted_days`*/
     47     const char * map[8 * 7];
     48     char nums [7 * 6][4];
     49 } lv_calendar_t;
     50 
     51 extern const lv_obj_class_t lv_calendar_class;
     52 
     53 /**********************
     54  * GLOBAL PROTOTYPES
     55  **********************/
     56 
     57 lv_obj_t * lv_calendar_create(lv_obj_t * parent);
     58 
     59 /*======================
     60  * Add/remove functions
     61  *=====================*/
     62 
     63 /*=====================
     64  * Setter functions
     65  *====================*/
     66 
     67 /**
     68  * Set the today's date
     69  * @param obj  pointer to a calendar object
     70  * @param year      today's year
     71  * @param month     today's month [1..12]
     72  * @param day       today's day [1..31]
     73  */
     74 void lv_calendar_set_today_date(lv_obj_t * obj, uint32_t year, uint32_t month, uint32_t day);
     75 
     76 /**
     77  * Set the currently showed
     78  * @param obj           pointer to a calendar object
     79  * @param year          today's year
     80  * @param month         today's month [1..12]
     81  */
     82 void lv_calendar_set_showed_date(lv_obj_t * obj, uint32_t year, uint32_t month);
     83 
     84 /**
     85  * Set the highlighted dates
     86  * @param obj           pointer to a calendar object
     87  * @param highlighted   pointer to an `lv_calendar_date_t` array containing the dates.
     88  *                      Only the pointer will be saved so this variable can't be local which will be destroyed later.
     89  * @param date_num number of dates in the array
     90  */
     91 void lv_calendar_set_highlighted_dates(lv_obj_t * obj, lv_calendar_date_t highlighted[], uint16_t date_num);
     92 
     93 /**
     94  * Set the name of the days
     95  * @param obj           pointer to a calendar object
     96  * @param day_names     pointer to an array with the names.
     97  *                      E.g. `const char * days[7] = {"Sun", "Mon", ...}`
     98  *                      Only the pointer will be saved so this variable can't be local which will be destroyed later.
     99  */
    100 void lv_calendar_set_day_names(lv_obj_t * obj, const char ** day_names);
    101 
    102 /*=====================
    103  * Getter functions
    104  *====================*/
    105 
    106 /**
    107  * Get the button matrix object of the calendar.
    108  * It shows the dates and day names.
    109  * @param obj   pointer to a calendar object
    110  * @return      pointer to a the button matrix
    111  */
    112 lv_obj_t * lv_calendar_get_btnmatrix(const lv_obj_t * obj);
    113 
    114 /**
    115  * Get the today's date
    116  * @param calendar pointer to a calendar object
    117  * @return return pointer to an `lv_calendar_date_t` variable containing the date of today.
    118  */
    119 const lv_calendar_date_t * lv_calendar_get_today_date(const lv_obj_t * calendar);
    120 
    121 /**
    122  * Get the currently showed
    123  * @param calendar pointer to a calendar object
    124  * @return pointer to an `lv_calendar_date_t` variable containing the date is being shown.
    125  */
    126 const lv_calendar_date_t * lv_calendar_get_showed_date(const lv_obj_t * calendar);
    127 
    128 /**
    129  * Get the highlighted dates
    130  * @param calendar pointer to a calendar object
    131  * @return pointer to an `lv_calendar_date_t` array containing the dates.
    132  */
    133 lv_calendar_date_t * lv_calendar_get_highlighted_dates(const lv_obj_t * calendar);
    134 
    135 /**
    136  * Get the number of the highlighted dates
    137  * @param calendar pointer to a calendar object
    138  * @return number of highlighted days
    139  */
    140 uint16_t lv_calendar_get_highlighted_dates_num(const lv_obj_t * calendar);
    141 
    142 /**
    143  * Get the currently pressed day
    144  * @param calendar pointer to a calendar object
    145  * @param date store the pressed date here
    146  * @return LV_RES_OK: there is a valid pressed date; LV_RES_INV: there is no pressed data
    147  */
    148 lv_res_t lv_calendar_get_pressed_date(const lv_obj_t * calendar, lv_calendar_date_t * date);
    149 
    150 /*=====================
    151  * Other functions
    152  *====================*/
    153 
    154 /**********************
    155  *      MACROS
    156  **********************/
    157 
    158 #endif  /*LV_USE_CALENDAR*/
    159 
    160 #ifdef __cplusplus
    161 } /*extern "C"*/
    162 #endif
    163 
    164 #endif /*LV_CALENDAR_H*/