merge master
This commit is contained in:
@@ -123,6 +123,18 @@ void lv_init(void)
|
|||||||
LV_LOG_INFO("lv_init ready");
|
LV_LOG_INFO("lv_init ready");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LV_ENABLE_GC || !LV_MEM_CUSTOM
|
||||||
|
void lv_deinit(void)
|
||||||
|
{
|
||||||
|
lv_gc_clear_roots();
|
||||||
|
lv_log_register_print_cb(NULL);
|
||||||
|
lv_disp_set_default(NULL);
|
||||||
|
lv_mem_deinit();
|
||||||
|
lv_initialized = false;
|
||||||
|
LV_LOG_INFO("lv_deinit done");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*--------------------
|
/*--------------------
|
||||||
* Create and delete
|
* Create and delete
|
||||||
*-------------------*/
|
*-------------------*/
|
||||||
|
|||||||
@@ -280,6 +280,15 @@ typedef struct _lv_hit_test_info_t
|
|||||||
*/
|
*/
|
||||||
void lv_init(void);
|
void lv_init(void);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deinit the 'lv' library
|
||||||
|
* Currently only implemented when not using custorm allocators, or GC is enabled.
|
||||||
|
*/
|
||||||
|
#if LV_ENABLE_GC || !LV_MEM_CUSTOM
|
||||||
|
void lv_deinit(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*--------------------
|
/*--------------------
|
||||||
* Create and delete
|
* Create and delete
|
||||||
*-------------------*/
|
*-------------------*/
|
||||||
|
|||||||
@@ -73,7 +73,9 @@ void lv_refr_init(void)
|
|||||||
*/
|
*/
|
||||||
void lv_refr_now(lv_disp_t * disp)
|
void lv_refr_now(lv_disp_t * disp)
|
||||||
{
|
{
|
||||||
|
#if LV_USE_ANIMATION
|
||||||
lv_anim_refr_now();
|
lv_anim_refr_now();
|
||||||
|
#endif
|
||||||
|
|
||||||
if(disp) {
|
if(disp) {
|
||||||
lv_disp_refr_task(disp->refr_task);
|
lv_disp_refr_task(disp->refr_task);
|
||||||
|
|||||||
@@ -8,6 +8,11 @@
|
|||||||
*********************/
|
*********************/
|
||||||
|
|
||||||
#include "lv_gc.h"
|
#include "lv_gc.h"
|
||||||
|
#include "string.h"
|
||||||
|
|
||||||
|
#if defined(LV_GC_INCLUDE)
|
||||||
|
#include LV_GC_INCLUDE
|
||||||
|
#endif /* LV_ENABLE_GC */
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
@@ -35,6 +40,12 @@ LV_ROOTS
|
|||||||
* GLOBAL FUNCTIONS
|
* GLOBAL FUNCTIONS
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
|
void lv_gc_clear_roots(void)
|
||||||
|
{
|
||||||
|
#define LV_CLEAR_ROOT(root_type, root_name) memset(&LV_GC_ROOT(root_name), 0, sizeof(LV_GC_ROOT(root_name)));
|
||||||
|
LV_ITERATE_ROOTS(LV_CLEAR_ROOT)
|
||||||
|
}
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* STATIC FUNCTIONS
|
* STATIC FUNCTIONS
|
||||||
**********************/
|
**********************/
|
||||||
|
|||||||
@@ -31,21 +31,22 @@ extern "C" {
|
|||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
|
|
||||||
#define LV_GC_ROOTS(prefix) \
|
|
||||||
prefix lv_ll_t _lv_task_ll; /*Linked list to store the lv_tasks*/ \
|
|
||||||
prefix lv_ll_t _lv_disp_ll; /*Linked list of screens*/ \
|
|
||||||
prefix lv_ll_t _lv_indev_ll; /*Linked list of screens*/ \
|
|
||||||
prefix lv_ll_t _lv_drv_ll; \
|
|
||||||
prefix lv_ll_t _lv_file_ll; \
|
|
||||||
prefix lv_ll_t _lv_anim_ll; \
|
|
||||||
prefix lv_ll_t _lv_group_ll; \
|
|
||||||
prefix lv_ll_t _lv_img_defoder_ll; \
|
|
||||||
prefix lv_img_cache_entry_t * _lv_img_cache_array; \
|
|
||||||
prefix void * _lv_task_act; \
|
|
||||||
prefix lv_mem_buf_t _lv_mem_buf[LV_MEM_BUF_MAX_NUM]; \
|
|
||||||
|
|
||||||
#define LV_NO_PREFIX
|
#define LV_ITERATE_ROOTS(f) \
|
||||||
#define LV_ROOTS LV_GC_ROOTS(LV_NO_PREFIX)
|
f(lv_ll_t, _lv_task_ll) /*Linked list to store the lv_tasks*/ \
|
||||||
|
f(lv_ll_t, _lv_disp_ll) /*Linked list of screens*/ \
|
||||||
|
f(lv_ll_t, _lv_indev_ll) /*Linked list of screens*/ \
|
||||||
|
f(lv_ll_t, _lv_drv_ll) \
|
||||||
|
f(lv_ll_t, _lv_file_ll) \
|
||||||
|
f(lv_ll_t, _lv_anim_ll) \
|
||||||
|
f(lv_ll_t, _lv_group_ll) \
|
||||||
|
f(lv_ll_t, _lv_img_defoder_ll) \
|
||||||
|
f(lv_img_cache_entry_t*, _lv_img_cache_array) \
|
||||||
|
f(void*, _lv_task_act) \
|
||||||
|
f(lv_mem_buf_t, _lv_mem_buf[LV_MEM_BUF_MAX_NUM]) \
|
||||||
|
|
||||||
|
#define LV_DEFINE_ROOT(root_type, root_name) root_type root_name;
|
||||||
|
#define LV_ROOTS LV_ITERATE_ROOTS(LV_DEFINE_ROOT)
|
||||||
|
|
||||||
#if LV_ENABLE_GC == 1
|
#if LV_ENABLE_GC == 1
|
||||||
#if LV_MEM_CUSTOM != 1
|
#if LV_MEM_CUSTOM != 1
|
||||||
@@ -53,7 +54,8 @@ extern "C" {
|
|||||||
#endif /* LV_MEM_CUSTOM */
|
#endif /* LV_MEM_CUSTOM */
|
||||||
#else /* LV_ENABLE_GC */
|
#else /* LV_ENABLE_GC */
|
||||||
#define LV_GC_ROOT(x) x
|
#define LV_GC_ROOT(x) x
|
||||||
LV_GC_ROOTS(extern)
|
#define LV_EXTERN_ROOT(root_type, root_name) extern root_type root_name;
|
||||||
|
LV_ITERATE_ROOTS(LV_EXTERN_ROOT)
|
||||||
#endif /* LV_ENABLE_GC */
|
#endif /* LV_ENABLE_GC */
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
@@ -64,6 +66,8 @@ LV_GC_ROOTS(extern)
|
|||||||
* GLOBAL PROTOTYPES
|
* GLOBAL PROTOTYPES
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
|
void lv_gc_clear_roots(void);
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* MACROS
|
* MACROS
|
||||||
**********************/
|
**********************/
|
||||||
|
|||||||
@@ -103,6 +103,21 @@ void lv_mem_init(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clean up the memory buffer which frees all the allocated memories.
|
||||||
|
* @note It work only if `LV_MEM_CUSTOM == 0`
|
||||||
|
*/
|
||||||
|
void lv_mem_deinit(void)
|
||||||
|
{
|
||||||
|
#if LV_MEM_CUSTOM == 0
|
||||||
|
memset(work_mem, 0x00, (LV_MEM_SIZE / sizeof(MEM_UNIT)) * sizeof(MEM_UNIT));
|
||||||
|
lv_mem_ent_t * full = (lv_mem_ent_t *)work_mem;
|
||||||
|
full->header.s.used = 0;
|
||||||
|
/*The total mem size id reduced by the first header and the close patterns */
|
||||||
|
full->header.s.d_size = LV_MEM_SIZE - sizeof(lv_mem_header_t);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate a memory dynamically
|
* Allocate a memory dynamically
|
||||||
* @param size size of the memory to allocate in bytes
|
* @param size size of the memory to allocate in bytes
|
||||||
|
|||||||
@@ -65,6 +65,12 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
void lv_mem_init(void);
|
void lv_mem_init(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clean up the memory buffer which frees all the allocated memories.
|
||||||
|
* @note It work only if `LV_MEM_CUSTOM == 0`
|
||||||
|
*/
|
||||||
|
void lv_mem_deinit(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate a memory dynamically
|
* Allocate a memory dynamically
|
||||||
* @param size size of the memory to allocate in bytes
|
* @param size size of the memory to allocate in bytes
|
||||||
|
|||||||
@@ -182,6 +182,13 @@ lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * img_src, const char * t
|
|||||||
{
|
{
|
||||||
LV_ASSERT_OBJ(list, LV_OBJX_NAME);
|
LV_ASSERT_OBJ(list, LV_OBJX_NAME);
|
||||||
|
|
||||||
|
lv_obj_t * last_btn = lv_list_get_prev_btn(list, NULL);
|
||||||
|
|
||||||
|
/*The coordinates may changed due to autofit so revert them at the end*/
|
||||||
|
lv_coord_t pos_x_ori = lv_obj_get_x(list);
|
||||||
|
lv_coord_t pos_y_ori = lv_obj_get_y(list);
|
||||||
|
|
||||||
|
|
||||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||||
ext->size++;
|
ext->size++;
|
||||||
/*Create a list element with the image an the text*/
|
/*Create a list element with the image an the text*/
|
||||||
@@ -200,7 +207,22 @@ lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * img_src, const char * t
|
|||||||
|
|
||||||
lv_page_glue_obj(liste, true);
|
lv_page_glue_obj(liste, true);
|
||||||
lv_btn_set_layout(liste, LV_LAYOUT_ROW_M);
|
lv_btn_set_layout(liste, LV_LAYOUT_ROW_M);
|
||||||
|
|
||||||
|
lv_layout_t list_layout = lv_list_get_layout(list);
|
||||||
|
bool layout_ver = false;
|
||||||
|
if(list_layout == LV_LAYOUT_COL_M || list_layout == LV_LAYOUT_COL_L || list_layout == LV_LAYOUT_COL_R) {
|
||||||
|
layout_ver = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(layout_ver) {
|
||||||
lv_btn_set_fit2(liste, LV_FIT_FLOOD, LV_FIT_TIGHT);
|
lv_btn_set_fit2(liste, LV_FIT_FLOOD, LV_FIT_TIGHT);
|
||||||
|
} else {
|
||||||
|
lv_coord_t w = last_btn ? lv_obj_get_width(last_btn) : (LV_DPI * 3) / 2;
|
||||||
|
lv_btn_set_fit2(liste, LV_FIT_NONE, LV_FIT_TIGHT);
|
||||||
|
lv_obj_set_width(liste, w);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
lv_obj_set_protect(liste, LV_PROTECT_PRESS_LOST);
|
lv_obj_set_protect(liste, LV_PROTECT_PRESS_LOST);
|
||||||
lv_obj_set_signal_cb(liste, lv_list_btn_signal);
|
lv_obj_set_signal_cb(liste, lv_list_btn_signal);
|
||||||
|
|
||||||
@@ -236,6 +258,8 @@ lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * img_src, const char * t
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
lv_obj_set_pos(list, pos_x_ori, pos_y_ori);
|
||||||
|
|
||||||
return liste;
|
return liste;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,16 +426,23 @@ void lv_list_set_style(lv_obj_t * list, lv_list_style_t type, const lv_style_t *
|
|||||||
while(btn != NULL) {
|
while(btn != NULL) {
|
||||||
/*If a column layout set the buttons' width to list width*/
|
/*If a column layout set the buttons' width to list width*/
|
||||||
if(layout == LV_LAYOUT_COL_M || layout == LV_LAYOUT_COL_L || layout == LV_LAYOUT_COL_R) {
|
if(layout == LV_LAYOUT_COL_M || layout == LV_LAYOUT_COL_L || layout == LV_LAYOUT_COL_R) {
|
||||||
lv_btn_set_fit2(list, LV_FIT_FLOOD, LV_FIT_TIGHT);
|
lv_btn_set_fit2(btn, LV_FIT_FLOOD, LV_FIT_TIGHT);
|
||||||
}
|
}
|
||||||
/*If a row layout set the buttons' width according to the content*/
|
/*If a row layout set the buttons' width according to the content*/
|
||||||
else if (layout == LV_LAYOUT_ROW_M || layout == LV_LAYOUT_ROW_T || layout == LV_LAYOUT_ROW_B) {
|
else if (layout == LV_LAYOUT_ROW_M || layout == LV_LAYOUT_ROW_T || layout == LV_LAYOUT_ROW_B) {
|
||||||
lv_btn_set_fit(list, LV_FIT_TIGHT);
|
lv_btn_set_fit(btn, LV_FIT_TIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
btn = lv_list_get_prev_btn(list, btn);
|
btn = lv_list_get_prev_btn(list, btn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(layout == LV_LAYOUT_COL_M || layout == LV_LAYOUT_COL_L || layout == LV_LAYOUT_COL_R) {
|
||||||
|
lv_page_set_scrl_fit2(list, LV_FIT_FLOOD, LV_FIT_TIGHT);
|
||||||
|
} else if (layout == LV_LAYOUT_ROW_M || layout == LV_LAYOUT_ROW_T || layout == LV_LAYOUT_ROW_B) {
|
||||||
|
lv_page_set_scrl_fit2(list, LV_FIT_TIGHT, LV_FIT_TIGHT);
|
||||||
|
lv_cont_set_fit2(list, LV_FIT_NONE, LV_FIT_TIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
lv_page_set_scrl_layout(list, layout);
|
lv_page_set_scrl_layout(list, layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -153,8 +153,9 @@ void lv_roller_set_options(lv_obj_t * roller, const char * options, lv_roller_mo
|
|||||||
|
|
||||||
/* Make sure the roller's height and the scrollable's height is refreshed.
|
/* Make sure the roller's height and the scrollable's height is refreshed.
|
||||||
* They are refreshed in `LV_SIGNAL_COORD_CHG` but if the new options has the same width
|
* They are refreshed in `LV_SIGNAL_COORD_CHG` but if the new options has the same width
|
||||||
* that signal won't be called. (It called because LV_FIT_TIGHT hor fit)*/
|
* that signal won't be called. (It's called because of LV_FIT_TIGHT hor fit)*/
|
||||||
refr_height(roller);
|
refr_height(roller);
|
||||||
|
refr_position(roller, LV_ANIM_OFF);
|
||||||
} else {
|
} else {
|
||||||
ext->mode = LV_ROLLER_MODE_INIFINITE;
|
ext->mode = LV_ROLLER_MODE_INIFINITE;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user