initial commit

This commit is contained in:
Carter Essen committed 2026-11-09 17:35:03 -05:00
commit cff2a21efc
550 files changed
+154887

No files matched your search

@@ -0,0 +1,160 @@
/**
* @file lv_calendar.h
*
*/
#ifndef LV_CALENDAR_H
#define LV_CALENDAR_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../buttonmatrix/lv_buttonmatrix.h"
#if LV_USE_CALENDAR
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**
* Represents a date on the calendar object (platform-agnostic).
*/
typedef struct {
uint16_t year;
int8_t month; /**< 1..12 */
int8_t day; /**< 1..31 */
} lv_calendar_date_t;
LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_calendar_class;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a calendar widget
* @param parent pointer to an object, it will be the parent of the new calendar
* @return pointer the created calendar
*/
lv_obj_t * lv_calendar_create(lv_obj_t * parent);
/*======================
* Add/remove functions
*=====================*/
/*=====================
* Setter functions
*====================*/
/**
* Set the today's date
* @param obj pointer to a calendar object
* @param year today's year
* @param month today's month [1..12]
* @param day today's day [1..31]
*/
void lv_calendar_set_today_date(lv_obj_t * obj, uint32_t year, uint32_t month, uint32_t day);
/**
* Set the currently showed
* @param obj pointer to a calendar object
* @param year today's year
* @param month today's month [1..12]
*/
void lv_calendar_set_showed_date(lv_obj_t * obj, uint32_t year, uint32_t month);
/**
* Set the highlighted dates
* @param obj pointer to a calendar object
* @param highlighted pointer to an `lv_calendar_date_t` array containing the dates.
* Only the pointer will be saved so this variable can't be local which will be destroyed later.
* @param date_num number of dates in the array
*/
void lv_calendar_set_highlighted_dates(lv_obj_t * obj, lv_calendar_date_t highlighted[], size_t date_num);
/**
* Set the name of the days
* @param obj pointer to a calendar object
* @param day_names pointer to an array with the names.
* E.g. `const char * days[7] = {"Sun", "Mon", ...}`
* Only the pointer will be saved so this variable can't be local which will be destroyed later.
*/
void lv_calendar_set_day_names(lv_obj_t * obj, const char ** day_names);
/*=====================
* Getter functions
*====================*/
/**
* Get the button matrix object of the calendar.
* It shows the dates and day names.
* @param obj pointer to a calendar object
* @return pointer to a the button matrix
*/
lv_obj_t * lv_calendar_get_btnmatrix(const lv_obj_t * obj);
/**
* Get the today's date
* @param calendar pointer to a calendar object
* @return return pointer to an `lv_calendar_date_t` variable containing the date of today.
*/
const lv_calendar_date_t * lv_calendar_get_today_date(const lv_obj_t * calendar);
/**
* Get the currently showed
* @param calendar pointer to a calendar object
* @return pointer to an `lv_calendar_date_t` variable containing the date is being shown.
*/
const lv_calendar_date_t * lv_calendar_get_showed_date(const lv_obj_t * calendar);
/**
* Get the highlighted dates
* @param calendar pointer to a calendar object
* @return pointer to an `lv_calendar_date_t` array containing the dates.
*/
lv_calendar_date_t * lv_calendar_get_highlighted_dates(const lv_obj_t * calendar);
/**
* Get the number of the highlighted dates
* @param calendar pointer to a calendar object
* @return number of highlighted days
*/
size_t lv_calendar_get_highlighted_dates_num(const lv_obj_t * calendar);
/**
* Get the currently pressed day
* @param calendar pointer to a calendar object
* @param date store the pressed date here
* @return LV_RESULT_OK: there is a valid pressed date
* LV_RESULT_INVALID: there is no pressed data
*/
lv_result_t lv_calendar_get_pressed_date(const lv_obj_t * calendar, lv_calendar_date_t * date);
/*=====================
* Other functions
*====================*/
/**********************
* MACROS
**********************/
#include "lv_calendar_header_arrow.h"
#include "lv_calendar_header_dropdown.h"
#include "lv_calendar_chinese.h"
#endif /*LV_USE_CALENDAR*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_CALENDAR_H*/
@@ -0,0 +1,68 @@
/**
* @file lv_calendar_chinese.h
*
*/
#ifndef LV_CALENDAR_CHINESE_H
#define LV_CALENDAR_CHINESE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../core/lv_obj.h"
#include "lv_calendar.h"
#if LV_USE_CALENDAR && LV_USE_CALENDAR_CHINESE
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef struct {
lv_calendar_date_t today;
bool leep_month;
} lv_calendar_chinese_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Enable the chinese calendar.
* @param obj pointer to a calendar object.
* @param en true: enable chinese calendar; false: disable
*/
void lv_calendar_set_chinese_mode(lv_obj_t * obj, bool en);
/**
* Get the name of the day
* @param gregorian to obtain the gregorian time for the name
* @return return the name of the day
*/
const char * lv_calendar_get_day_name(lv_calendar_date_t * gregorian);
/**
* Get the chinese time of the gregorian time (reference: https://www.cnblogs.com/liyang31tg/p/4123171.html)
* @param gregorian_time need to convert to chinese time in gregorian time
* @param chinese_time the chinese time convert from gregorian time
*/
void lv_calendar_gregorian_to_chinese(lv_calendar_date_t * gregorian_time, lv_calendar_chinese_t * chinese_time);
/**********************
* MACROS
**********************/
#endif /*LV_USE_CALENDAR_CHINESE*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_CALENDAR_CHINESE_H*/
@@ -0,0 +1,53 @@
/**
* @file lv_calendar_chinese_private.h
*
*/
#ifndef LV_CALENDAR_CHINESE_PRIVATE_H
#define LV_CALENDAR_CHINESE_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_calendar_chinese.h"
#if LV_USE_CALENDAR && LV_USE_CALENDAR_CHINESE
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* TYPEDEFS
**********************/
struct lv_calendar_chinese_t {
lv_calendar_date_t today;
bool leep_month;
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#endif /* LV_USE_CALENDAR && LV_USE_CALENDAR_CHINESE */
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_CALENDAR_CHINESE_PRIVATE_H*/
@@ -0,0 +1,49 @@
/**
* @file lv_calendar_header_arrow.h
*
*/
#ifndef LV_CALENDAR_HEADER_ARROW_H
#define LV_CALENDAR_HEADER_ARROW_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../core/lv_obj.h"
#if LV_USE_CALENDAR && LV_USE_CALENDAR_HEADER_ARROW
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_calendar_header_arrow_class;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a calendar header with drop-drowns to select the year and month
* @param parent pointer to a calendar object.
* @return the created header
*/
lv_obj_t * lv_calendar_header_arrow_create(lv_obj_t * parent);
/**********************
* MACROS
**********************/
#endif /*LV_USE_CALENDAR_HEADER_ARROW*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_CALENDAR_HEADER_ARROW_H*/
@@ -0,0 +1,62 @@
/**
* @file lv_calendar_header_dropdown.h
*
*/
#ifndef LV_CALENDAR_HEADER_DROPDOWN_H
#define LV_CALENDAR_HEADER_DROPDOWN_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../core/lv_obj.h"
#if LV_USE_CALENDAR && LV_USE_CALENDAR_HEADER_DROPDOWN
#if LV_USE_DROPDOWN == 0
#error "LV_USE_DROPDOWN needs to be enabled"
#endif
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_calendar_header_dropdown_class;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a calendar header with drop-drowns to select the year and month
* @param parent pointer to a calendar object.
* @return the created header
*/
lv_obj_t * lv_calendar_header_dropdown_create(lv_obj_t * parent);
/**
* Sets a custom calendar year list
* @param parent pointer to a calendar object
* @param years_list pointer to an const char array with the years list, see lv_dropdown set_options for more information.
* E.g. `const char * years = "2023\n2022\n2021\n2020\n2019"
* Only the pointer will be saved so this variable can't be local which will be destroyed later.
*/
void lv_calendar_header_dropdown_set_year_list(lv_obj_t * parent, const char * years_list);
/**********************
* MACROS
**********************/
#endif /*LV_USE_CALENDAR_HEADER_ARROW*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_CALENDAR_HEADER_DROPDOWN_H*/
@@ -0,0 +1,70 @@
/**
* @file lv_calendar_private.h
*
*/
#ifndef LV_CALENDAR_PRIVATE_H
#define LV_CALENDAR_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../core/lv_obj_private.h"
#include "lv_calendar.h"
#if LV_USE_CALENDAR
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/** Data of calendar */
struct _lv_calendar_t {
lv_obj_t obj;
/* New data for this type */
lv_obj_t * btnm;
lv_calendar_date_t today; /**< Date of today */
lv_calendar_date_t showed_date; /**< Currently visible month (day is ignored) */
lv_calendar_date_t * highlighted_dates; /**< Apply different style on these days (pointer to user-defined array) */
size_t highlighted_dates_num; /**< Number of elements in `highlighted_days` */
const char * map[8 * 7];
#ifdef LV_USE_CALENDAR_CHINESE
bool use_chinese_calendar;
/** 7 * 6: A week has 7 days, and the calendar displays 6 weeks in total.
* 20: Including the number of dates, line breaks, names for each day,
* and reserving several spaces for addresses. */
char nums [7 * 6][20];
#else
/** 7 * 6: A week has 7 days, and the calendar displays 6 weeks in total.
* 6: Including the number of dates, and reserving several spaces for
* addresses.*/
char nums [7 * 6][4];
#endif
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#endif /* LV_USE_CALENDAR */
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_CALENDAR_PRIVATE_H*/