debug: rework asserts

This commit is contained in:
Gabor Kiss-Vamosi
2019-09-24 23:14:17 +02:00
parent 366f958e1a
commit 5660181b81
45 changed files with 264 additions and 155 deletions

View File

@@ -11,6 +11,8 @@
/*********************
* DEFINES
*********************/
#define LV_DEBUG_STR_MAX_LENGTH (1024 * 8)
#define LV_DEBUG_STR_MAX_REPEAT 8
/**********************
* TYPEDEFS
@@ -19,7 +21,7 @@
/**********************
* STATIC PROTOTYPES
**********************/
static bool obj_valid_child(lv_obj_t * parent, lv_obj_t * obj_to_find);
static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_find);
/**********************
* STATIC VARIABLES
@@ -40,8 +42,10 @@ bool lv_debug_check_null(const void * p)
return false;
}
bool lv_debug_check_obj_type(lv_obj_t * obj, const char * obj_type)
bool lv_debug_check_obj_type(const lv_obj_t * obj, const char * obj_type)
{
if(obj_type[0] == '\0') return true;
lv_obj_type_t types;
lv_obj_get_type(obj, &types);
@@ -53,7 +57,7 @@ bool lv_debug_check_obj_type(lv_obj_t * obj, const char * obj_type)
return false;
}
bool lv_debug_check_obj_valid(lv_obj_t * obj)
bool lv_debug_check_obj_valid(const lv_obj_t * obj)
{
lv_disp_t * disp = lv_disp_get_next(NULL);
while(disp) {
@@ -71,10 +75,42 @@ bool lv_debug_check_obj_valid(lv_obj_t * obj)
return false;
}
bool lv_debug_check_malloc(void * p)
bool lv_debug_check_style(const void * str)
{
if(p) return true;
return true;
LV_LOG_WARN("Invalid style (local variable or not initialized?)");
return false;
}
bool lv_debug_check_str(const void * str)
{
const uint8_t * s = (const uint8_t *)str;
uint8_t last_byte = 0;
uint32_t rep = 0;
uint32_t i;
for(i = 0; s[i] != '\0' && i < LV_DEBUG_STR_MAX_LENGTH; i++) {
if(s[i] != last_byte) {
last_byte = s[i];
rep = 1;
} else {
rep++;
if(rep > LV_DEBUG_STR_MAX_REPEAT) {
LV_LOG_WARN("lv_debug_check_str: a char has repeated more than LV_DEBUG_STR_MAX_REPEAT times)");
return false;
}
}
if(s[i] < 10) {
LV_LOG_WARN("lv_debug_check_str: invalid char in the string (< 10 value)");
return false; /*Shouldn't occur in strings*/
}
}
if(s[i] == '\0') return true;
LV_LOG_WARN("lv_debug_check_str: string is longer than LV_DEBUG_STR_MAX_LENGTH");
return false;
}
@@ -125,7 +161,7 @@ void lv_debug_log_error(const char * msg, unsigned long int value)
* STATIC FUNCTIONS
**********************/
static bool obj_valid_child(lv_obj_t * parent, lv_obj_t * obj_to_find)
static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_find)
{
/*Check all children of `parent`*/
lv_obj_t * child = lv_obj_get_child(parent, NULL);

View File

@@ -28,11 +28,13 @@ extern "C" {
**********************/
bool lv_debug_check_null(const void * p);
bool lv_debug_check_obj_type(lv_obj_t * obj, const char * obj_type);
bool lv_debug_check_obj_type(const lv_obj_t * obj, const char * obj_type);
bool lv_debug_check_obj_valid(lv_obj_t * obj);
bool lv_debug_check_obj_valid(const lv_obj_t * obj);
bool lv_debug_check_malloc(void * p);
bool lv_debug_check_style(const void * str);
bool lv_debug_check_str(const void * str);
void lv_debug_log_error(const char * msg, uint64_t value);
@@ -40,42 +42,61 @@ void lv_debug_log_error(const char * msg, uint64_t value);
* MACROS
**********************/
#define LV_DEBUG_HALT(msg, value) \
{ \
lv_debug_log_error(msg, value); \
while(1); \
} \
#ifndef LV_DEBUG_ASSERT
#define LV_DEBUG_ASSERT(expr, msg, value) \
{ \
if(!(expr)) { \
LV_LOG_ERROR(__func__); \
lv_debug_log_error(msg, (unsigned long int)value); \
while(1); \
} \
}
#endif
/*----------------
* CHECKS
*----------------*/
#ifndef LV_DEBUG_IS_NULL
#define LV_DEBUG_IS_NULL(p) (lv_debug_check_null(p))
#endif
#ifndef LV_DEBUG_IS_STR
#define LV_DEBUG_IS_STR(str) (lv_debug_check_str(str))
#endif
#ifndef LV_DEBUG_IS_OBJ
#define LV_DEBUG_IS_OBJ(obj_p, obj_type) (lv_debug_check_null(obj_p) && \
lv_debug_check_obj_valid(obj_p) && \
lv_debug_check_obj_type(obj_p, obj_type))
#endif
#ifndef LV_DEBUG_IS_STYLE
#define LV_DEBUG_IS_STYLE(style_p) (lv_debug_check_style(style_p))
#endif
/*-----------------
* ASSERTS
*-----------------*/
#ifndef LV_ASSERT_NULL
#define LV_ASSERT_NULL(p) \
if(lv_debug_check_null(p) == false) { \
LV_LOG_ERROR(__func__); \
LV_DEBUG_HALT("NULL obj. found", (lv_uintptr_t)p); \
}
#define LV_ASSERT_NULL(p) LV_DEBUG_ASSERT(LV_DEBUG_IS_NULL(p), "NULL pointer", p);
#endif
#ifndef LV_ASSERT_OBJ_NOT_EXISTS
#define LV_ASSERT_OBJ_NOT_EXISTS(obj) \
if(lv_debug_check_obj_valid(obj) == false) { \
LV_LOG_ERROR(__func__); \
LV_DEBUG_HALT("Invalid obj, found", (lv_uintptr_t)obj); \
}
#ifndef LV_ASSERT_MEM
#define LV_ASSERT_MEM(p) LV_DEBUG_ASSERT(LV_DEBUG_IS_NULL(p), "Out of memory", p);
#endif
#ifndef LV_ASSERT_OBJ_TYPE_ERROR
#define LV_ASSERT_OBJ_TYPE_ERROR(obj, type) \
if(lv_debug_check_obj_type(obj, __LV_OBJX_TYPE) == false) { \
LV_LOG_ERROR(__func__); \
LV_DEBUG_HALT("Obj. type mismatch", (lv_uintptr_t)obj); \
}
#ifndef LV_ASSERT_STR
#define LV_ASSERT_STR(p) LV_DEBUG_ASSERT(LV_DEBUG_IS_STR(p), "Strange or invalid string", p);
#endif
#ifndef LV_ASSERT_NO_MEM
#define LV_ASSERT_NO_MEM(p) \
if(lv_debug_check_malloc(p) == false) { \
LV_LOG_ERROR(__func__); \
LV_DEBUG_HALT("Out of memory", (lv_uintptr_t)p); \
}
#ifndef LV_ASSERT_OBJ
#define LV_ASSERT_OBJ(obj_p, obj_type) LV_DEBUG_ASSERT(LV_DEBUG_IS_OBJ(obj_p, obj_type), "Invalid object", obj_p);
#endif
#ifndef LV_ASSERT_STYLE
#define LV_ASSERT_STYLE(style_p) LV_DEBUG_ASSERT(LV_DEBUG_IS_STYLE(style_p, obj_type), "Invalid style", style_p);
#endif
#ifdef __cplusplus

View File

@@ -63,7 +63,7 @@ void lv_group_init(void)
lv_group_t * lv_group_create(void)
{
lv_group_t * group = lv_ll_ins_head(&LV_GC_ROOT(_lv_group_ll));
LV_ASSERT_NO_MEM(group);
LV_ASSERT_MEM(group);
if(group == NULL) return NULL;
lv_ll_init(&group->obj_ll, sizeof(lv_obj_t *));
@@ -139,7 +139,7 @@ void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj)
obj->group_p = group;
lv_obj_t ** next = lv_ll_ins_tail(&group->obj_ll);
LV_ASSERT_NO_MEM(next);
LV_ASSERT_MEM(next);
if(next == NULL) return;
*next = obj;

View File

@@ -143,7 +143,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
}
new_obj = lv_ll_ins_head(&disp->scr_ll);
LV_ASSERT_NO_MEM(new_obj);
LV_ASSERT_MEM(new_obj);
if(new_obj == NULL) return NULL;
new_obj->par = NULL; /*Screens has no a parent*/
@@ -216,7 +216,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
LV_LOG_TRACE("Object create started");
new_obj = lv_ll_ins_head(&parent->child_ll);
LV_ASSERT_NO_MEM(new_obj);
LV_ASSERT_MEM(new_obj);
if(new_obj == NULL) return NULL;
new_obj->par = parent; /*Set the parent*/

View File

@@ -288,7 +288,7 @@ void lv_style_anim_init(lv_anim_t * a)
lv_style_anim_dsc_t * dsc;
dsc = lv_mem_alloc(sizeof(lv_style_anim_dsc_t));
LV_ASSERT_NO_MEM(dsc);
LV_ASSERT_MEM(dsc);
if(dsc == NULL) return;
dsc->ready_cb = NULL;
dsc->style_anim = NULL;

View File

@@ -61,12 +61,12 @@ void * lv_draw_get_buf(uint32_t size)
if(LV_GC_ROOT(_lv_draw_buf) == NULL) {
LV_GC_ROOT(_lv_draw_buf) = lv_mem_alloc(size);
LV_ASSERT_NO_MEM(LV_GC_ROOT(_lv_draw_buf));
LV_ASSERT_MEM(LV_GC_ROOT(_lv_draw_buf));
return LV_GC_ROOT(_lv_draw_buf);
}
LV_GC_ROOT(_lv_draw_buf) = lv_mem_realloc(LV_GC_ROOT(_lv_draw_buf), size);
LV_ASSERT_NO_MEM(LV_GC_ROOT(_lv_draw_buf));
LV_ASSERT_MEM(LV_GC_ROOT(_lv_draw_buf));
return LV_GC_ROOT(_lv_draw_buf);
}

View File

@@ -153,7 +153,7 @@ void lv_img_cache_set_size(uint16_t new_entry_cnt)
/*Reallocate the cache*/
LV_GC_ROOT(_lv_img_cache_array) = lv_mem_alloc(sizeof(lv_img_cache_entry_t) * new_entry_cnt);
LV_ASSERT_NO_MEM(LV_GC_ROOT(_lv_img_cache_array));
LV_ASSERT_MEM(LV_GC_ROOT(_lv_img_cache_array));
if(LV_GC_ROOT(_lv_img_cache_array) == NULL) {
entry_cnt = 0;
return;

View File

@@ -70,7 +70,7 @@ void lv_img_decoder_init(void)
decoder = lv_img_decoder_create();
if(decoder == NULL) {
LV_LOG_WARN("lv_img_decoder_init: out of memory");
LV_ASSERT_NO_MEM(decoder);
LV_ASSERT_MEM(decoder);
return;
}
@@ -188,7 +188,7 @@ lv_img_decoder_t * lv_img_decoder_create(void)
{
lv_img_decoder_t * decoder;
decoder = lv_ll_ins_head(&LV_GC_ROOT(_lv_img_defoder_ll));
LV_ASSERT_NO_MEM(decoder);
LV_ASSERT_MEM(decoder);
if(decoder == NULL) return NULL;
memset(decoder, 0, sizeof(lv_img_decoder_t));
@@ -323,7 +323,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
dsc->user_data = lv_mem_alloc(sizeof(lv_img_decoder_built_in_data_t));
if(dsc->user_data == NULL) {
LV_LOG_ERROR("img_decoder_built_in_open: out of memory");
LV_ASSERT_NO_MEM(dsc->user_data);
LV_ASSERT_MEM(dsc->user_data);
}
memset(dsc->user_data, 0, sizeof(lv_img_decoder_built_in_data_t));
}
@@ -332,7 +332,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
user_data->f = lv_mem_alloc(sizeof(f));
if(user_data->f == NULL) {
LV_LOG_ERROR("img_decoder_built_in_open: out of memory");
LV_ASSERT_NO_MEM(user_data->f);
LV_ASSERT_MEM(user_data->f);
}
memcpy(user_data->f, &f, sizeof(f));
@@ -370,7 +370,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
dsc->user_data = lv_mem_alloc(sizeof(lv_img_decoder_built_in_data_t));
if(dsc->user_data == NULL) {
LV_LOG_ERROR("img_decoder_built_in_open: out of memory");
LV_ASSERT_NO_MEM(dsc->user_data);
LV_ASSERT_MEM(dsc->user_data);
}
memset(dsc->user_data, 0, sizeof(lv_img_decoder_built_in_data_t));
}
@@ -381,7 +381,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
if(user_data->palette == NULL || user_data->opa == NULL) {
LV_LOG_ERROR("img_decoder_built_in_open: out of memory");
#if LV_USE_FILESYSTEM
LV_ASSERT_NO_MEM(user_data->f);
LV_ASSERT_MEM(user_data->f);
#endif
}

View File

@@ -101,7 +101,7 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic
if(lv_mem_get_size(buf) < buf_size) {
buf = lv_mem_realloc(buf, buf_size);
LV_ASSERT_NO_MEM(buf);
LV_ASSERT_MEM(buf);
if(buf == NULL) return NULL;
}

View File

@@ -119,7 +119,7 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
{
lv_disp_t * disp = lv_ll_ins_head(&LV_GC_ROOT(_lv_disp_ll));
if(!disp) {
LV_ASSERT_NO_MEM(disp);
LV_ASSERT_MEM(disp);
return NULL;
}
@@ -148,7 +148,7 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
/*Create a refresh task*/
disp->refr_task = lv_task_create(lv_disp_refr_task, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, disp);
LV_ASSERT_NO_MEM(disp->refr_task);
LV_ASSERT_MEM(disp->refr_task);
if(disp->refr_task == NULL) return NULL;
lv_task_ready(disp->refr_task); /*Be sure the screen will be refreshed immediately on start up*/

View File

@@ -78,7 +78,7 @@ lv_indev_t * lv_indev_drv_register(lv_indev_drv_t * driver)
lv_indev_t * indev = lv_ll_ins_head(&LV_GC_ROOT(_lv_indev_ll));
if(!indev) {
LV_ASSERT_NO_MEM(indev);
LV_ASSERT_MEM(indev);
return NULL;
}

View File

@@ -90,7 +90,7 @@ void lv_anim_create(lv_anim_t * a)
/*Add the new animation to the animation linked list*/
lv_anim_t * new_anim = lv_ll_ins_head(&LV_GC_ROOT(_lv_anim_ll));
LV_ASSERT_NO_MEM(new_anim);
LV_ASSERT_MEM(new_anim);
if(new_anim == NULL) return;
/*Initialize the animation descriptor*/

View File

@@ -108,7 +108,7 @@ lv_fs_res_t lv_fs_open(lv_fs_file_t * file_p, const char * path, lv_fs_mode_t mo
}
file_p->file_d = lv_mem_alloc(file_p->drv->file_size);
LV_ASSERT_NO_MEM(file_p->file_d);
LV_ASSERT_MEM(file_p->file_d);
if(file_p->file_d == NULL) {
file_p->drv = NULL;
return LV_FS_RES_OUT_OF_MEM; /* Out of memory */
@@ -368,7 +368,7 @@ lv_fs_res_t lv_fs_dir_open(lv_fs_dir_t * rddir_p, const char * path)
}
rddir_p->dir_d = lv_mem_alloc(rddir_p->drv->rddir_size);
LV_ASSERT_NO_MEM(rddir_p->dir_d);
LV_ASSERT_MEM(rddir_p->dir_d);
if(rddir_p->dir_d == NULL) {
rddir_p->dir_d = NULL;
return LV_FS_RES_OUT_OF_MEM; /* Out of memory */
@@ -487,7 +487,7 @@ void lv_fs_drv_register(lv_fs_drv_t * drv_p)
/*Save the new driver*/
lv_fs_drv_t * new_drv;
new_drv = lv_ll_ins_head(&LV_GC_ROOT(_lv_drv_ll));
LV_ASSERT_NO_MEM(new_drv);
LV_ASSERT_MEM(new_drv);
if(new_drv == NULL) return;
memcpy(new_drv, drv_p, sizeof(lv_fs_drv_t));

View File

@@ -174,7 +174,7 @@ lv_task_t * lv_task_create_basic(void)
/*It's the first task*/
if(NULL == tmp) {
new_task = lv_ll_ins_head(&LV_GC_ROOT(_lv_task_ll));
LV_ASSERT_NO_MEM(new_task);
LV_ASSERT_MEM(new_task);
if(new_task == NULL) return NULL;
}
/*Insert the new task to proper place according to its priority*/
@@ -182,7 +182,7 @@ lv_task_t * lv_task_create_basic(void)
do {
if(tmp->prio <= DEF_PRIO) {
new_task = lv_ll_ins_prev(&LV_GC_ROOT(_lv_task_ll), tmp);
LV_ASSERT_NO_MEM(new_task);
LV_ASSERT_MEM(new_task);
if(new_task == NULL) return NULL;
break;
}
@@ -192,7 +192,7 @@ lv_task_t * lv_task_create_basic(void)
/*Only too high priority tasks were found. Add the task to the end*/
if(tmp == NULL) {
new_task = lv_ll_ins_tail(&LV_GC_ROOT(_lv_task_ll));
LV_ASSERT_NO_MEM(new_task);
LV_ASSERT_MEM(new_task);
if(new_task == NULL) return NULL;
}
}
@@ -224,7 +224,7 @@ lv_task_t * lv_task_create_basic(void)
lv_task_t * lv_task_create(lv_task_cb_t task_cb, uint32_t period, lv_task_prio_t prio, void * user_data)
{
lv_task_t * new_task = lv_task_create_basic();
LV_ASSERT_NO_MEM(new_task);
LV_ASSERT_MEM(new_task);
if(new_task == NULL) return NULL;
lv_task_set_cb(new_task, task_cb);

View File

@@ -55,12 +55,12 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor of arc*/
lv_obj_t * new_arc = lv_obj_create(par, copy);
LV_ASSERT_NO_MEM(new_arc);
LV_ASSERT_MEM(new_arc);
if(new_arc == NULL) return NULL;
/*Allocate the arc type specific extended data*/
lv_arc_ext_t * ext = lv_obj_allocate_ext_attr(new_arc, sizeof(lv_arc_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_arc);

View File

@@ -62,7 +62,7 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor basic object*/
lv_obj_t * new_bar = lv_obj_create(par, copy);
LV_ASSERT_NO_MEM(new_bar);
LV_ASSERT_MEM(new_bar);
if(new_bar == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_bar);
@@ -70,7 +70,7 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, const lv_obj_t * copy)
/*Allocate the object type specific extended data*/
lv_bar_ext_t * ext = lv_obj_allocate_ext_attr(new_bar, sizeof(lv_bar_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
ext->min_value = 0;

View File

@@ -77,7 +77,7 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_t * new_btn;
new_btn = lv_cont_create(par, copy);
LV_ASSERT_NO_MEM(new_btn);
LV_ASSERT_MEM(new_btn);
if(new_btn == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_btn);
@@ -85,7 +85,7 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy)
/*Allocate the extended data*/
lv_btn_ext_t * ext = lv_obj_allocate_ext_attr(new_btn, sizeof(lv_btn_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
ext->state = LV_BTN_STATE_REL;

View File

@@ -71,14 +71,14 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor object*/
lv_obj_t * new_btnm = lv_obj_create(par, copy);
LV_ASSERT_NO_MEM(new_btnm);
LV_ASSERT_MEM(new_btnm);
if(new_btnm == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_btnm);
/*Allocate the object type specific extended data*/
lv_btnm_ext_t * ext = lv_obj_allocate_ext_attr(new_btnm, sizeof(lv_btnm_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
ext->btn_cnt = 0;
@@ -939,9 +939,9 @@ static void allocate_btn_areas_and_controls(const lv_obj_t * btnm, const char **
}
ext->button_areas = lv_mem_alloc(sizeof(lv_area_t) * btn_cnt);
LV_ASSERT_NO_MEM(ext->button_areas);
LV_ASSERT_MEM(ext->button_areas);
ext->ctrl_bits = lv_mem_alloc(sizeof(lv_btnm_ctrl_t) * btn_cnt);
LV_ASSERT_NO_MEM(ext->ctrl_bits);
LV_ASSERT_MEM(ext->ctrl_bits);
if(ext->button_areas == NULL || ext->ctrl_bits == NULL) btn_cnt = 0;
memset(ext->ctrl_bits, 0, sizeof(lv_btnm_ctrl_t) * btn_cnt);

View File

@@ -78,12 +78,12 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor of calendar*/
lv_obj_t * new_calendar = lv_obj_create(par, copy);
LV_ASSERT_NO_MEM(new_calendar);
LV_ASSERT_MEM(new_calendar);
if(new_calendar == NULL) return NULL;
/*Allocate the calendar type specific extended data*/
lv_calendar_ext_t * ext = lv_obj_allocate_ext_attr(new_calendar, sizeof(lv_calendar_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_calendar);
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_calendar);

View File

@@ -54,12 +54,12 @@ lv_obj_t * lv_canvas_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor of canvas*/
lv_obj_t * new_canvas = lv_img_create(par, copy);
LV_ASSERT_NO_MEM(new_canvas);
LV_ASSERT_MEM(new_canvas);
if(new_canvas == NULL) return NULL;
/*Allocate the canvas type specific extended data*/
lv_canvas_ext_t * ext = lv_obj_allocate_ext_attr(new_canvas, sizeof(lv_canvas_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_canvas);
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_canvas);

View File

@@ -56,14 +56,14 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor basic object*/
lv_obj_t * new_cb = lv_btn_create(par, copy);
LV_ASSERT_NO_MEM(new_cb);
LV_ASSERT_MEM(new_cb);
if(new_cb == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_cb);
if(ancestor_bg_design == NULL) ancestor_bg_design = lv_obj_get_design_cb(new_cb);
lv_cb_ext_t * ext = lv_obj_allocate_ext_attr(new_cb, sizeof(lv_cb_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
ext->bullet = NULL;

View File

@@ -87,12 +87,12 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor basic object*/
lv_obj_t * new_chart = lv_obj_create(par, copy);
LV_ASSERT_NO_MEM(new_chart);
LV_ASSERT_MEM(new_chart);
if(new_chart == NULL) return NULL;
/*Allocate the object type specific extended data*/
lv_chart_ext_t * ext = lv_obj_allocate_ext_attr(new_chart, sizeof(lv_chart_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
lv_ll_init(&ext->series_ll, sizeof(lv_chart_series_t));
@@ -175,7 +175,7 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color)
{
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
lv_chart_series_t * ser = lv_ll_ins_head(&ext->series_ll);
LV_ASSERT_NO_MEM(ser);
LV_ASSERT_MEM(ser);
if(ser == NULL) return NULL;
lv_coord_t def = LV_CHART_POINT_DEF;
@@ -184,7 +184,7 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color)
ser->color = color;
ser->points = lv_mem_alloc(sizeof(lv_coord_t) * ext->point_cnt);
LV_ASSERT_NO_MEM(ser->points);
LV_ASSERT_MEM(ser->points);
if(ser->points == NULL) {
lv_ll_rem(&ext->series_ll, ser);
lv_mem_free(ser);
@@ -298,7 +298,7 @@ void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt)
{
if(ser->start_point != 0) {
lv_coord_t * new_points = lv_mem_alloc(sizeof(lv_coord_t) * point_cnt);
LV_ASSERT_NO_MEM(new_points);
LV_ASSERT_MEM(new_points);
if(new_points == NULL) return;
if(point_cnt >= point_cnt_old) {
@@ -321,7 +321,7 @@ void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt)
ser->points = new_points;
} else {
ser->points = lv_mem_realloc(ser->points, sizeof(lv_coord_t) * point_cnt);
LV_ASSERT_NO_MEM(ser->points);
LV_ASSERT_MEM(ser->points);
if(ser->points == NULL) return;
/*Initialize the new points*/
if(point_cnt > point_cnt_old) {

View File

@@ -68,7 +68,7 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create a basic object*/
lv_obj_t * new_cont = lv_obj_create(par, copy);
LV_ASSERT_NO_MEM(new_cont);
LV_ASSERT_MEM(new_cont);
if(new_cont == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_cont);
@@ -77,7 +77,7 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy)
lv_cont_ext_t * ext = lv_obj_get_ext_attr(new_cont);
if(ext == NULL) return NULL;
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
ext->fit_left = LV_FIT_NONE;
ext->fit_right = LV_FIT_NONE;
ext->fit_top = LV_FIT_NONE;

View File

@@ -75,7 +75,7 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor drop down list*/
lv_obj_t * new_ddlist = lv_page_create(par, copy);
LV_ASSERT_NO_MEM(new_ddlist);
LV_ASSERT_MEM(new_ddlist);
if(new_ddlist == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_ddlist);
@@ -84,7 +84,7 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
/*Allocate the drop down list type specific extended data*/
lv_ddlist_ext_t * ext = lv_obj_allocate_ext_attr(new_ddlist, sizeof(lv_ddlist_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
/*Initialize the allocated 'ext' */

View File

@@ -66,12 +66,12 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor gauge*/
lv_obj_t * new_gauge = lv_lmeter_create(par, copy);
LV_ASSERT_NO_MEM(new_gauge);
LV_ASSERT_MEM(new_gauge);
if(new_gauge == NULL) return NULL;
/*Allocate the gauge type specific extended data*/
lv_gauge_ext_t * ext = lv_obj_allocate_ext_attr(new_gauge, sizeof(lv_gauge_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
/*Initialize the allocated 'ext' */
@@ -141,7 +141,7 @@ void lv_gauge_set_needle_count(lv_obj_t * gauge, uint8_t needle_cnt, const lv_co
}
ext->values = lv_mem_realloc(ext->values, needle_cnt * sizeof(int16_t));
LV_ASSERT_NO_MEM(ext->values);
LV_ASSERT_MEM(ext->values);
if(ext->values == NULL) return;
int16_t min = lv_gauge_get_min_value(gauge);

View File

@@ -62,14 +62,14 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create a basic object*/
new_img = lv_obj_create(par, copy);
LV_ASSERT_NO_MEM(new_img);
LV_ASSERT_MEM(new_img);
if(new_img == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_img);
/*Extend the basic object to image object*/
lv_img_ext_t * ext = lv_obj_allocate_ext_attr(new_img, sizeof(lv_img_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
ext->src = NULL;
@@ -165,7 +165,7 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img)
lv_mem_free(ext->src);
}
char * new_str = lv_mem_alloc(strlen(src_img) + 1);
LV_ASSERT_NO_MEM(new_str);
LV_ASSERT_MEM(new_str);
if(new_str == NULL) return;
strcpy(new_str, src_img);
ext->src = new_str;

View File

@@ -54,12 +54,12 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor of image button*/
lv_obj_t * new_imgbtn = lv_btn_create(par, copy);
LV_ASSERT_NO_MEM(new_imgbtn);
LV_ASSERT_MEM(new_imgbtn);
if(new_imgbtn == NULL) return NULL;
/*Allocate the image button type specific extended data*/
lv_imgbtn_ext_t * ext = lv_obj_allocate_ext_attr(new_imgbtn, sizeof(lv_imgbtn_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_imgbtn);
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_imgbtn);

View File

@@ -98,14 +98,14 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor of keyboard*/
lv_obj_t * new_kb = lv_btnm_create(par, copy);
LV_ASSERT_NO_MEM(new_kb);
LV_ASSERT_MEM(new_kb);
if(new_kb == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_kb);
/*Allocate the keyboard type specific extended data*/
lv_kb_ext_t * ext = lv_obj_allocate_ext_attr(new_kb, sizeof(lv_kb_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
/*Initialize the allocated 'ext' */

View File

@@ -19,7 +19,7 @@
/*********************
* DEFINES
*********************/
#define __LV_OBJX_TYPE "lv_label"
#define LV_OBJX_NAME "lv_label"
/*Test configurations*/
#ifndef LV_LABEL_DEF_SCROLL_SPEED
@@ -76,7 +76,7 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create a basic object*/
lv_obj_t * new_label = lv_obj_create(par, copy);
LV_ASSERT_NO_MEM(new_label);
LV_ASSERT_MEM(new_label);
if(new_label == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_label);
@@ -85,7 +85,7 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_allocate_ext_attr(new_label, sizeof(lv_label_ext_t));
lv_label_ext_t * ext = lv_obj_get_ext_attr(new_label);
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
ext->text = NULL;
@@ -139,7 +139,7 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
/*In DOT mode save the text byte-to-byte because a '\0' can be in the middle*/
if(copy_ext->long_mode == LV_LABEL_LONG_DOT) {
ext->text = lv_mem_realloc(ext->text, lv_mem_get_size(copy_ext->text));
LV_ASSERT_NO_MEM(ext->text);
LV_ASSERT_MEM(ext->text);
if(ext->text == NULL) return NULL;
memcpy(ext->text, copy_ext->text, lv_mem_get_size(copy_ext->text));
}
@@ -173,9 +173,7 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
*/
void lv_label_set_text(lv_obj_t * label, const char * text)
{
LV_ASSERT_NULL(label);
LV_ASSERT_OBJ_NOT_EXISTS(label);
LV_ASSERT_OBJ_TYPE_ERROR(label, __LV_OBJX_TYPE);
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
lv_obj_invalidate(label);
@@ -187,10 +185,12 @@ void lv_label_set_text(lv_obj_t * label, const char * text)
return;
}
LV_ASSERT_STR(text);
if(ext->text == text) {
/*If set its own text then reallocate it (maybe its size changed)*/
ext->text = lv_mem_realloc(ext->text, strlen(ext->text) + 1);
LV_ASSERT_NO_MEM(ext->text);
LV_ASSERT_MEM(ext->text);
if(ext->text == NULL) return;
} else {
/*Allocate space for the new text*/
@@ -201,7 +201,7 @@ void lv_label_set_text(lv_obj_t * label, const char * text)
}
ext->text = lv_mem_alloc(len);
LV_ASSERT_NO_MEM(ext->text);
LV_ASSERT_MEM(ext->text);
if(ext->text == NULL) return;
strcpy(ext->text, text);
@@ -218,6 +218,9 @@ void lv_label_set_text(lv_obj_t * label, const char * text)
*/
void lv_label_set_text_fmt(lv_obj_t * label, const char * fmt, ...)
{
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
LV_ASSERT_STR(fmt);
lv_obj_invalidate(label);
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
@@ -244,7 +247,7 @@ void lv_label_set_text_fmt(lv_obj_t * label, const char * fmt, ...)
ext->text = lv_mem_alloc(len+1);
LV_ASSERT_NO_MEM(ext->text);
LV_ASSERT_MEM(ext->text);
if(ext->text == NULL) return;
ext->text[len-1] = 0; /* Ensure NULL termination */
@@ -265,6 +268,8 @@ void lv_label_set_text_fmt(lv_obj_t * label, const char * fmt, ...)
*/
void lv_label_set_array_text(lv_obj_t * label, const char * array, uint16_t size)
{
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
lv_obj_invalidate(label);
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
@@ -281,7 +286,7 @@ void lv_label_set_array_text(lv_obj_t * label, const char * array, uint16_t size
ext->text = NULL;
}
ext->text = lv_mem_alloc(size + 1);
LV_ASSERT_NO_MEM(ext->text);
LV_ASSERT_MEM(ext->text);
if(ext->text == NULL) return;
memcpy(ext->text, array, size);
@@ -299,6 +304,9 @@ void lv_label_set_array_text(lv_obj_t * label, const char * array, uint16_t size
*/
void lv_label_set_static_text(lv_obj_t * label, const char * text)
{
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
LV_ASSERT_STR(text);
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
if(ext->static_txt == 0 && ext->text != NULL) {
lv_mem_free(ext->text);
@@ -322,6 +330,8 @@ void lv_label_set_static_text(lv_obj_t * label, const char * text)
*/
void lv_label_set_long_mode(lv_obj_t * label, lv_label_long_mode_t long_mode)
{
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
#if LV_USE_ANIMATION
@@ -355,6 +365,8 @@ void lv_label_set_long_mode(lv_obj_t * label, lv_label_long_mode_t long_mode)
*/
void lv_label_set_align(lv_obj_t * label, lv_label_align_t align)
{
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
if(ext->align == align) return;
@@ -371,6 +383,8 @@ void lv_label_set_align(lv_obj_t * label, lv_label_align_t align)
*/
void lv_label_set_recolor(lv_obj_t * label, bool en)
{
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
if(ext->recolor == en) return;
@@ -387,6 +401,8 @@ void lv_label_set_recolor(lv_obj_t * label, bool en)
*/
void lv_label_set_body_draw(lv_obj_t * label, bool en)
{
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
if(ext->body_draw == en) return;
@@ -404,6 +420,8 @@ void lv_label_set_body_draw(lv_obj_t * label, bool en)
*/
void lv_label_set_anim_speed(lv_obj_t * label, uint16_t anim_speed)
{
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
#if LV_USE_ANIMATION
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
if(ext->anim_speed == anim_speed) return;
@@ -421,6 +439,8 @@ void lv_label_set_anim_speed(lv_obj_t * label, uint16_t anim_speed)
void lv_label_set_text_sel_start(lv_obj_t * label, uint16_t index)
{
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
#if LV_LABEL_TEXT_SEL
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
ext->txt_sel_start = index;
@@ -433,6 +453,8 @@ void lv_label_set_text_sel_start(lv_obj_t * label, uint16_t index)
void lv_label_set_text_sel_end(lv_obj_t * label, uint16_t index)
{
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
#if LV_LABEL_TEXT_SEL
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
ext->txt_sel_end = index;
@@ -454,6 +476,8 @@ void lv_label_set_text_sel_end(lv_obj_t * label, uint16_t index)
*/
char * lv_label_get_text(const lv_obj_t * label)
{
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
return ext->text;
@@ -466,6 +490,8 @@ char * lv_label_get_text(const lv_obj_t * label)
*/
lv_label_long_mode_t lv_label_get_long_mode(const lv_obj_t * label)
{
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
return ext->long_mode;
}
@@ -477,6 +503,8 @@ lv_label_long_mode_t lv_label_get_long_mode(const lv_obj_t * label)
*/
lv_label_align_t lv_label_get_align(const lv_obj_t * label)
{
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
return ext->align;
}
@@ -488,6 +516,8 @@ lv_label_align_t lv_label_get_align(const lv_obj_t * label)
*/
bool lv_label_get_recolor(const lv_obj_t * label)
{
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
return ext->recolor == 0 ? false : true;
}
@@ -499,6 +529,8 @@ bool lv_label_get_recolor(const lv_obj_t * label)
*/
bool lv_label_get_body_draw(const lv_obj_t * label)
{
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
return ext->body_draw == 0 ? false : true;
}
@@ -510,6 +542,8 @@ bool lv_label_get_body_draw(const lv_obj_t * label)
*/
uint16_t lv_label_get_anim_speed(const lv_obj_t * label)
{
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
#if LV_USE_ANIMATION
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
return ext->anim_speed;
@@ -528,6 +562,9 @@ uint16_t lv_label_get_anim_speed(const lv_obj_t * label)
*/
void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t * pos)
{
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
LV_ASSERT_NULL(pos);
const char * txt = lv_label_get_text(label);
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
uint32_t line_start = 0;
@@ -597,6 +634,9 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t
*/
uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
{
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
LV_ASSERT_NULL(pos);
const char * txt = lv_label_get_text(label);
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
uint32_t line_start = 0;
@@ -679,6 +719,8 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
*/
uint16_t lv_label_get_text_sel_start(const lv_obj_t * label)
{
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
#if LV_LABEL_TEXT_SEL
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
return ext->txt_sel_start;
@@ -696,6 +738,8 @@ uint16_t lv_label_get_text_sel_start(const lv_obj_t * label)
*/
uint16_t lv_label_get_text_sel_end(const lv_obj_t * label)
{
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
#if LV_LABEL_TEXT_SEL
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
return ext->txt_sel_end;
@@ -713,6 +757,9 @@ uint16_t lv_label_get_text_sel_end(const lv_obj_t * label)
*/
bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos)
{
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
LV_ASSERT_NULL(pos);
const char * txt = lv_label_get_text(label);
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
uint32_t line_start = 0;
@@ -802,6 +849,9 @@ bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos)
*/
void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt)
{
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
LV_ASSERT_STR(txt);
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
/*Can not append to static text*/
@@ -814,7 +864,7 @@ void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt)
uint32_t ins_len = strlen(txt);
uint32_t new_len = ins_len + old_len;
ext->text = lv_mem_realloc(ext->text, new_len + 1);
LV_ASSERT_NO_MEM(ext->text);
LV_ASSERT_MEM(ext->text);
if(ext->text == NULL) return;
if(pos == LV_LABEL_POS_LAST) {
@@ -835,6 +885,8 @@ void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt)
*/
void lv_label_cut_text(lv_obj_t * label, uint32_t pos, uint32_t cnt)
{
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
/*Can not append to static text*/

View File

@@ -57,7 +57,7 @@ lv_obj_t * lv_led_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor basic object*/
lv_obj_t * new_led = lv_obj_create(par, copy);
LV_ASSERT_NO_MEM(new_led);
LV_ASSERT_MEM(new_led);
if(new_led == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_led);
@@ -65,7 +65,7 @@ lv_obj_t * lv_led_create(lv_obj_t * par, const lv_obj_t * copy)
/*Allocate the object type specific extended data*/
lv_led_ext_t * ext = lv_obj_allocate_ext_attr(new_led, sizeof(lv_led_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
ext->bright = LV_LED_BRIGHT_ON;

View File

@@ -54,14 +54,14 @@ lv_obj_t * lv_line_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create a basic object*/
lv_obj_t * new_line = lv_obj_create(par, copy);
LV_ASSERT_NO_MEM(new_line);
LV_ASSERT_MEM(new_line);
if(new_line == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_line);
/*Extend the basic object to line object*/
lv_line_ext_t * ext = lv_obj_allocate_ext_attr(new_line, sizeof(lv_line_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
ext->point_num = 0;

View File

@@ -70,13 +70,13 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor basic object*/
lv_obj_t * new_list = lv_page_create(par, copy);
LV_ASSERT_NO_MEM(new_list);
LV_ASSERT_MEM(new_list);
if(new_list == NULL) return NULL;
if(ancestor_page_signal == NULL) ancestor_page_signal = lv_obj_get_signal_cb(new_list);
lv_list_ext_t * ext = lv_obj_allocate_ext_attr(new_list, sizeof(lv_list_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
ext->style_img = NULL;

View File

@@ -58,14 +58,14 @@ lv_obj_t * lv_lmeter_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor of line meter*/
lv_obj_t * new_lmeter = lv_obj_create(par, copy);
LV_ASSERT_NO_MEM(new_lmeter);
LV_ASSERT_MEM(new_lmeter);
if(new_lmeter == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_lmeter);
/*Allocate the line meter type specific extended data*/
lv_lmeter_ext_t * ext = lv_obj_allocate_ext_attr(new_lmeter, sizeof(lv_lmeter_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
/*Initialize the allocated 'ext' */

View File

@@ -69,14 +69,14 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor message box*/
lv_obj_t * new_mbox = lv_cont_create(par, copy);
LV_ASSERT_NO_MEM(new_mbox);
LV_ASSERT_MEM(new_mbox);
if(new_mbox == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_mbox);
/*Allocate the message box type specific extended data*/
lv_mbox_ext_t * ext = lv_obj_allocate_ext_attr(new_mbox, sizeof(lv_mbox_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
ext->text = NULL;

View File

@@ -78,7 +78,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor object*/
lv_obj_t * new_page = lv_cont_create(par, copy);
LV_ASSERT_NO_MEM(new_page);
LV_ASSERT_MEM(new_page);
if(new_page == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_page);
@@ -86,7 +86,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
/*Allocate the object type specific extended data*/
lv_page_ext_t * ext = lv_obj_allocate_ext_attr(new_page, sizeof(lv_page_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
ext->scrl = NULL;

View File

@@ -67,12 +67,12 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor of pre loader*/
lv_obj_t * new_preload = lv_arc_create(par, copy);
LV_ASSERT_NO_MEM(new_preload);
LV_ASSERT_MEM(new_preload);
if(new_preload == NULL) return NULL;
/*Allocate the pre loader type specific extended data*/
lv_preload_ext_t * ext = lv_obj_allocate_ext_attr(new_preload, sizeof(lv_preload_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_preload);

View File

@@ -66,7 +66,7 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor of roller*/
lv_obj_t * new_roller = lv_ddlist_create(par, copy);
LV_ASSERT_NO_MEM(new_roller);
LV_ASSERT_MEM(new_roller);
if(new_roller == NULL) return NULL;
if(ancestor_scrl_signal == NULL) ancestor_scrl_signal = lv_obj_get_signal_cb(lv_page_get_scrl(new_roller));
@@ -74,7 +74,7 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy)
/*Allocate the roller type specific extended data*/
lv_roller_ext_t * ext = lv_obj_allocate_ext_attr(new_roller, sizeof(lv_roller_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
ext->ddlist.draw_arrow = 0; /*Do not draw arrow by default*/
@@ -264,8 +264,8 @@ uint16_t lv_roller_get_selected(const lv_obj_t * roller)
lv_label_align_t lv_roller_get_align(const lv_obj_t * roller)
{
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_NO_MEM(ext->ddlist.label);
LV_ASSERT_MEM(ext);
LV_ASSERT_MEM(ext->ddlist.label);
return lv_label_get_align(ext->ddlist.label);
}

View File

@@ -58,7 +58,7 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor slider*/
lv_obj_t * new_slider = lv_bar_create(par, copy);
LV_ASSERT_NO_MEM(new_slider);
LV_ASSERT_MEM(new_slider);
if(new_slider == NULL) return NULL;
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_cb(new_slider);
@@ -66,7 +66,7 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, const lv_obj_t * copy)
/*Allocate the slider type specific extended data*/
lv_slider_ext_t * ext = lv_obj_allocate_ext_attr(new_slider, sizeof(lv_slider_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
/*Initialize the allocated 'ext' */

View File

@@ -54,12 +54,12 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor of spinbox*/
lv_obj_t * new_spinbox = lv_ta_create(par, copy);
LV_ASSERT_NO_MEM(new_spinbox);
LV_ASSERT_MEM(new_spinbox);
if(new_spinbox == NULL) return NULL;
/*Allocate the spinbox type specific extended data*/
lv_spinbox_ext_t * ext = lv_obj_allocate_ext_attr(new_spinbox, sizeof(lv_spinbox_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_spinbox);
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_spinbox);

View File

@@ -57,14 +57,14 @@ lv_obj_t * lv_sw_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor of switch*/
lv_obj_t * new_sw = lv_slider_create(par, copy);
LV_ASSERT_NO_MEM(new_sw);
LV_ASSERT_MEM(new_sw);
if(new_sw == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_sw);
/*Allocate the switch type specific extended data*/
lv_sw_ext_t * ext = lv_obj_allocate_ext_attr(new_sw, sizeof(lv_sw_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
/*Initialize the allocated 'ext' */

View File

@@ -86,7 +86,7 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor object*/
lv_obj_t * new_ta = lv_page_create(par, copy);
LV_ASSERT_NO_MEM(new_ta);
LV_ASSERT_MEM(new_ta);
if(new_ta == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_ta);
@@ -96,7 +96,7 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
/*Allocate the object type specific extended data*/
lv_ta_ext_t * ext = lv_obj_allocate_ext_attr(new_ta, sizeof(lv_ta_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
ext->cursor.state = 1;
@@ -174,7 +174,7 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
if(copy_ext->pwd_tmp) {
uint16_t len = lv_mem_get_size(copy_ext->pwd_tmp);
ext->pwd_tmp = lv_mem_alloc(len);
LV_ASSERT_NO_MEM(ext->pwd_tmp);
LV_ASSERT_MEM(ext->pwd_tmp);
if(ext->pwd_tmp == NULL) return NULL;
memcpy(ext->pwd_tmp, copy_ext->pwd_tmp, len);
@@ -268,7 +268,7 @@ void lv_ta_add_char(lv_obj_t * ta, uint32_t c)
if(ext->pwd_mode != 0) {
ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + 2); /*+2: the new char + \0 */
LV_ASSERT_NO_MEM(ext->pwd_tmp);
LV_ASSERT_MEM(ext->pwd_tmp);
if(ext->pwd_tmp == NULL) return;
lv_txt_ins(ext->pwd_tmp, ext->cursor.pos, (const char *)letter_buf);
@@ -349,7 +349,7 @@ void lv_ta_add_text(lv_obj_t * ta, const char * txt)
if(ext->pwd_mode != 0) {
ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + strlen(txt) + 1);
LV_ASSERT_NO_MEM(ext->pwd_tmp);
LV_ASSERT_MEM(ext->pwd_tmp);
if(ext->pwd_tmp == NULL) return;
lv_txt_ins(ext->pwd_tmp, ext->cursor.pos, txt);
@@ -428,7 +428,7 @@ void lv_ta_del_char(lv_obj_t * ta)
lv_txt_cut(ext->pwd_tmp, ext->cursor.pos - 1, lv_txt_encoded_size(&label_txt[byte_pos]));
ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + 1);
LV_ASSERT_NO_MEM(ext->pwd_tmp);
LV_ASSERT_MEM(ext->pwd_tmp);
if(ext->pwd_tmp == NULL) return;
}
@@ -490,7 +490,7 @@ void lv_ta_set_text(lv_obj_t * ta, const char * txt)
if(ext->pwd_mode != 0) {
ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(txt) + 1);
LV_ASSERT_NO_MEM(ext->pwd_tmp);
LV_ASSERT_MEM(ext->pwd_tmp);
if(ext->pwd_tmp == NULL) return;
strcpy(ext->pwd_tmp, txt);
@@ -664,7 +664,7 @@ void lv_ta_set_pwd_mode(lv_obj_t * ta, bool en)
char * txt = lv_label_get_text(ext->label);
uint16_t len = strlen(txt);
ext->pwd_tmp = lv_mem_alloc(len + 1);
LV_ASSERT_NO_MEM(ext->pwd_tmp);
LV_ASSERT_MEM(ext->pwd_tmp);
if(ext->pwd_tmp == NULL) return;
strcpy(ext->pwd_tmp, txt);

View File

@@ -57,12 +57,12 @@ lv_obj_t * lv_table_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor of table*/
lv_obj_t * new_table = lv_obj_create(par, copy);
LV_ASSERT_NO_MEM(new_table);
LV_ASSERT_MEM(new_table);
if(new_table == NULL) return NULL;
/*Allocate the table type specific extended data*/
lv_table_ext_t * ext = lv_obj_allocate_ext_attr(new_table, sizeof(lv_table_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_table);
if(ancestor_scrl_design == NULL) ancestor_scrl_design = lv_obj_get_design_cb(new_table);

View File

@@ -72,13 +72,13 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor of tab*/
lv_obj_t * new_tabview = lv_obj_create(par, copy);
LV_ASSERT_NO_MEM(new_tabview);
LV_ASSERT_MEM(new_tabview);
if(new_tabview == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_tabview);
/*Allocate the tab type specific extended data*/
lv_tabview_ext_t * ext = lv_obj_allocate_ext_attr(new_tabview, sizeof(lv_tabview_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
/*Initialize the allocated 'ext' */
@@ -104,7 +104,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
/*Init the new tab tab*/
if(copy == NULL) {
ext->tab_name_ptr = lv_mem_alloc(sizeof(char *));
LV_ASSERT_NO_MEM(ext->tab_name_ptr);
LV_ASSERT_MEM(ext->tab_name_ptr);
if(ext->tab_name_ptr == NULL) return NULL;
ext->tab_name_ptr[0] = "";
ext->tab_cnt = 0;
@@ -162,7 +162,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
#endif
ext->tab_name_ptr = lv_mem_alloc(sizeof(char *));
LV_ASSERT_NO_MEM(ext->tab_name_ptr);
LV_ASSERT_MEM(ext->tab_name_ptr);
if(ext->tab_name_ptr == NULL) return NULL;
ext->tab_name_ptr[0] = "";
lv_btnm_set_map(ext->btns, ext->tab_name_ptr);
@@ -226,7 +226,7 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name)
/*Extend the button matrix map with the new name*/
char * name_dm;
name_dm = lv_mem_alloc(strlen(name) + 1); /*+1 for the the closing '\0' */
LV_ASSERT_NO_MEM(name_dm);
LV_ASSERT_MEM(name_dm);
if(name_dm == NULL) return NULL;
strcpy(name_dm, name);
@@ -243,7 +243,7 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name)
break;
}
LV_ASSERT_NO_MEM(ext->tab_name_ptr);
LV_ASSERT_MEM(ext->tab_name_ptr);
if(ext->tab_name_ptr == NULL) return NULL;
/* FIXME: It is not possible yet to switch tab button position from/to top/bottom from/to left/right at runtime.

View File

@@ -66,12 +66,12 @@ lv_obj_t * lv_tileview_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor of tileview*/
lv_obj_t * new_tileview = lv_page_create(par, copy);
LV_ASSERT_NO_MEM(new_tileview);
LV_ASSERT_MEM(new_tileview);
if(new_tileview == NULL) return NULL;
/*Allocate the tileview type specific extended data*/
lv_tileview_ext_t * ext = lv_obj_allocate_ext_attr(new_tileview, sizeof(lv_tileview_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_tileview);
if(ancestor_scrl_signal == NULL) ancestor_scrl_signal = lv_obj_get_signal_cb(lv_page_get_scrl(new_tileview));

View File

@@ -52,14 +52,14 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create the ancestor object*/
lv_obj_t * new_win = lv_obj_create(par, copy);
LV_ASSERT_NO_MEM(new_win);
LV_ASSERT_MEM(new_win);
if(new_win == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_win);
/*Allocate the object type specific extended data*/
lv_win_ext_t * ext = lv_obj_allocate_ext_attr(new_win, sizeof(lv_win_ext_t));
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_MEM(ext);
if(ext == NULL) return NULL;
ext->page = NULL;