debug: add the basics of LV_DEBUG

This commit is contained in:
Gabor Kiss-Vamosi
2019-09-24 16:30:38 +02:00
parent bebd2dd896
commit 366f958e1a
48 changed files with 397 additions and 137 deletions

1
lvgl.h
View File

@@ -28,6 +28,7 @@ extern "C" {
#include "src/lv_core/lv_refr.h"
#include "src/lv_core/lv_disp.h"
#include "src/lv_core/lv_debug.h"
#include "src/lv_themes/lv_theme.h"

143
src/lv_core/lv_debug.c Normal file
View File

@@ -0,0 +1,143 @@
/**
* @file lv_debug.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_obj.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static bool obj_valid_child(lv_obj_t * parent, lv_obj_t * obj_to_find);
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
bool lv_debug_check_null(const void * p)
{
if(p) return true;
return false;
}
bool lv_debug_check_obj_type(lv_obj_t * obj, const char * obj_type)
{
lv_obj_type_t types;
lv_obj_get_type(obj, &types);
uint8_t i;
for(i = 0; i < LV_MAX_ANCESTOR_NUM; i++) {
if(strcmp(types.type[i], obj_type) == 0) return true;
}
return false;
}
bool lv_debug_check_obj_valid(lv_obj_t * obj)
{
lv_disp_t * disp = lv_disp_get_next(NULL);
while(disp) {
lv_obj_t * scr;
LV_LL_READ(disp->scr_ll, scr) {
if(scr == obj) return true;
bool found = obj_valid_child(scr, obj);
if(found) return true;
}
disp = lv_disp_get_next(disp);
}
return false;
}
bool lv_debug_check_malloc(void * p)
{
if(p) return true;
return false;
}
void lv_debug_log_error(const char * msg, unsigned long int value)
{
static const char hex[] = "0123456789ABCDEF";
uint32_t msg_len = strlen(msg);
uint32_t value_len = sizeof(unsigned long int);
if(msg_len < 230) {
char buf[255];
char * bufp = buf;
/*Add the function name*/
memcpy(bufp, msg, msg_len);
bufp += msg_len;
/*Add value in hey*/
*bufp = ' ';
bufp ++;
*bufp = '(';
bufp ++;
*bufp = '0';
bufp ++;
*bufp = 'x';
bufp ++;
int8_t i;
for(i = value_len * 2 - 1; i >= 0; i--) {
uint8_t x = (unsigned long int)((unsigned long int)value >> (i * 4)) & 0xF;
*bufp = hex[x];
bufp++;
}
*bufp = ')';
bufp ++;
*bufp = '\0';
LV_LOG_ERROR(buf);
} else {
LV_LOG_ERROR(msg);
}
}
/**********************
* STATIC FUNCTIONS
**********************/
static bool obj_valid_child(lv_obj_t * parent, lv_obj_t * obj_to_find)
{
/*Check all children of `parent`*/
lv_obj_t * child = lv_obj_get_child(parent, NULL);
while(child) {
if(child == obj_to_find) return true;
/*Check the children*/
bool found = obj_valid_child(child, obj_to_find);
if(found) return true;
child = lv_obj_get_child(parent, child);
}
return false;
}

85
src/lv_core/lv_debug.h Normal file
View File

@@ -0,0 +1,85 @@
/**
* @file lv_debug.h
*
*/
#ifndef LV_DEBUG_H
#define LV_DEBUG_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_obj.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
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_valid(lv_obj_t * obj);
bool lv_debug_check_malloc(void * p);
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_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); \
}
#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); \
}
#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); \
}
#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); \
}
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_DEBUG_H*/

View File

@@ -8,8 +8,9 @@
*********************/
#include "lv_group.h"
#if LV_USE_GROUP != 0
#include "../lv_themes/lv_theme.h"
#include <stddef.h>
#include "../lv_core/lv_debug.h"
#include "../lv_themes/lv_theme.h"
#include "../lv_misc/lv_gc.h"
#if defined(LV_GC_INCLUDE)
@@ -62,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_mem_assert(group);
LV_ASSERT_NO_MEM(group);
if(group == NULL) return NULL;
lv_ll_init(&group->obj_ll, sizeof(lv_obj_t *));
@@ -138,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_mem_assert(next);
LV_ASSERT_NO_MEM(next);
if(next == NULL) return;
*next = obj;

View File

@@ -11,6 +11,7 @@
#include "lv_refr.h"
#include "lv_group.h"
#include "lv_disp.h"
#include "../lv_core/lv_debug.h"
#include "../lv_themes/lv_theme.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_misc/lv_anim.h"
@@ -142,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_mem_assert(new_obj);
LV_ASSERT_NO_MEM(new_obj);
if(new_obj == NULL) return NULL;
new_obj->par = NULL; /*Screens has no a parent*/
@@ -215,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_mem_assert(new_obj);
LV_ASSERT_NO_MEM(new_obj);
if(new_obj == NULL) return NULL;
new_obj->par = parent; /*Set the parent*/

View File

@@ -7,6 +7,7 @@
* INCLUDES
*********************/
#include "lv_obj.h"
#include "../lv_core/lv_debug.h"
#include "../lv_misc/lv_mem.h"
#include "../lv_misc/lv_anim.h"
@@ -287,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_mem_assert(dsc);
LV_ASSERT_NO_MEM(dsc);
if(dsc == NULL) return;
dsc->ready_cb = NULL;
dsc->style_anim = NULL;

View File

@@ -10,6 +10,7 @@
#include <stdio.h>
#include <stdbool.h>
#include "lv_draw.h"
#include "../lv_core/lv_debug.h"
#include "../lv_misc/lv_math.h"
#include "../lv_misc/lv_log.h"
#include "../lv_misc/lv_math.h"
@@ -60,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_mem_assert(LV_GC_ROOT(_lv_draw_buf));
LV_ASSERT_NO_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_mem_assert(LV_GC_ROOT(_lv_draw_buf));
LV_ASSERT_NO_MEM(LV_GC_ROOT(_lv_draw_buf));
return LV_GC_ROOT(_lv_draw_buf);
}

View File

@@ -6,6 +6,7 @@
/*********************
* INCLUDES
*********************/
#include "../lv_core/lv_debug.h"
#include "lv_img_cache.h"
#include "../lv_hal/lv_hal_tick.h"
#include "../lv_misc/lv_gc.h"
@@ -152,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_mem_assert(LV_GC_ROOT(_lv_img_cache_array));
LV_ASSERT_NO_MEM(LV_GC_ROOT(_lv_img_cache_array));
if(LV_GC_ROOT(_lv_img_cache_array) == NULL) {
entry_cnt = 0;
return;

View File

@@ -7,6 +7,7 @@
* INCLUDES
*********************/
#include "lv_img_decoder.h"
#include "../lv_core/lv_debug.h"
#include "../lv_draw/lv_draw_img.h"
#include "../lv_misc/lv_ll.h"
#include "../lv_misc/lv_color.h"
@@ -69,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_mem_assert(decoder);
LV_ASSERT_NO_MEM(decoder);
return;
}
@@ -187,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_mem_assert(decoder);
LV_ASSERT_NO_MEM(decoder);
if(decoder == NULL) return NULL;
memset(decoder, 0, sizeof(lv_img_decoder_t));
@@ -322,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_mem_assert(dsc->user_data);
LV_ASSERT_NO_MEM(dsc->user_data);
}
memset(dsc->user_data, 0, sizeof(lv_img_decoder_built_in_data_t));
}
@@ -331,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_mem_assert(user_data->f);
LV_ASSERT_NO_MEM(user_data->f);
}
memcpy(user_data->f, &f, sizeof(f));
@@ -369,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_mem_assert(dsc->user_data);
LV_ASSERT_NO_MEM(dsc->user_data);
}
memset(dsc->user_data, 0, sizeof(lv_img_decoder_built_in_data_t));
}
@@ -380,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_mem_assert(user_data->f);
LV_ASSERT_NO_MEM(user_data->f);
#endif
}

View File

@@ -8,6 +8,7 @@
*********************/
#include "lv_font.h"
#include "lv_font_fmt_txt.h"
#include "../lv_core/lv_debug.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_misc/lv_types.h"
#include "../lv_misc/lv_log.h"
@@ -100,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_mem_assert(buf);
LV_ASSERT_NO_MEM(buf);
if(buf == NULL) return NULL;
}

View File

@@ -12,6 +12,7 @@
#include <stdint.h>
#include <stddef.h>
#include "lv_hal.h"
#include "../lv_core/lv_debug.h"
#include "../lv_misc/lv_mem.h"
#include "../lv_core/lv_obj.h"
#include "../lv_core/lv_refr.h"
@@ -118,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_mem_assert(disp);
LV_ASSERT_NO_MEM(disp);
return NULL;
}
@@ -147,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_mem_assert(disp->refr_task);
LV_ASSERT_NO_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

@@ -8,6 +8,7 @@
/*********************
* INCLUDES
*********************/
#include "../lv_core/lv_debug.h"
#include "../lv_hal/lv_hal_indev.h"
#include "../lv_core/lv_indev.h"
#include "../lv_misc/lv_mem.h"
@@ -77,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_mem_assert(indev);
LV_ASSERT_NO_MEM(indev);
return NULL;
}

View File

@@ -11,6 +11,7 @@
#if LV_USE_ANIMATION
#include <stddef.h>
#include <string.h>
#include "../lv_core/lv_debug.h"
#include "../lv_hal/lv_hal_tick.h"
#include "lv_task.h"
#include "lv_math.h"
@@ -89,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_mem_assert(new_anim);
LV_ASSERT_NO_MEM(new_anim);
if(new_anim == NULL) return;
/*Initialize the animation descriptor*/

View File

@@ -9,6 +9,7 @@
#include "lv_fs.h"
#if LV_USE_FILESYSTEM
#include "../lv_core/lv_debug.h"
#include "lv_ll.h"
#include <string.h>
#include "lv_gc.h"
@@ -107,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_mem_assert(file_p->file_d);
LV_ASSERT_NO_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 */
@@ -367,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_mem_assert(rddir_p->dir_d);
LV_ASSERT_NO_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 */
@@ -486,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_mem_assert(new_drv);
LV_ASSERT_NO_MEM(new_drv);
if(new_drv == NULL) return;
memcpy(new_drv, drv_p, sizeof(lv_fs_drv_t));

View File

@@ -110,27 +110,6 @@ uint32_t lv_mem_get_size(const void * data);
* MACROS
**********************/
/**
* Halt on NULL pointer
* p pointer to a memory
*/
#if LV_USE_LOG == 0
#define lv_mem_assert(p) \
{ \
if(p == NULL) \
while(1) \
; \
}
#else
#define lv_mem_assert(p) \
{ \
if(p == NULL) { \
LV_LOG_ERROR("Out of memory!"); \
while(1) \
; \
} \
}
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif

View File

@@ -9,6 +9,7 @@
*********************/
#include <stddef.h>
#include "lv_task.h"
#include "../lv_core/lv_debug.h"
#include "../lv_hal/lv_hal_tick.h"
#include "lv_gc.h"
@@ -173,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_mem_assert(new_task);
LV_ASSERT_NO_MEM(new_task);
if(new_task == NULL) return NULL;
}
/*Insert the new task to proper place according to its priority*/
@@ -181,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_mem_assert(new_task);
LV_ASSERT_NO_MEM(new_task);
if(new_task == NULL) return NULL;
break;
}
@@ -191,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_mem_assert(new_task);
LV_ASSERT_NO_MEM(new_task);
if(new_task == NULL) return NULL;
}
}
@@ -223,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_mem_assert(new_task);
LV_ASSERT_NO_MEM(new_task);
if(new_task == NULL) return NULL;
lv_task_set_cb(new_task, task_cb);

View File

@@ -9,6 +9,7 @@
#include "lv_arc.h"
#if LV_USE_ARC != 0
#include "../lv_core/lv_debug.h"
#include "../lv_misc/lv_math.h"
#include "../lv_draw/lv_draw_arc.h"
#include "../lv_themes/lv_theme.h"
@@ -54,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_mem_assert(new_arc);
LV_ASSERT_NO_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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
if(ext == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_arc);

View File

@@ -11,6 +11,7 @@
#include "lv_bar.h"
#if LV_USE_BAR != 0
#include "../lv_core/lv_debug.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_themes/lv_theme.h"
#include "../lv_misc/lv_anim.h"
@@ -61,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_mem_assert(new_bar);
LV_ASSERT_NO_MEM(new_bar);
if(new_bar == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_bar);
@@ -69,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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
if(ext == NULL) return NULL;
ext->min_value = 0;

View File

@@ -12,6 +12,7 @@
#include <string.h>
#include "../lv_core/lv_group.h"
#include "../lv_core/lv_debug.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_themes/lv_theme.h"
#include "../lv_misc/lv_area.h"
@@ -76,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_mem_assert(new_btn);
LV_ASSERT_NO_MEM(new_btn);
if(new_btn == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_btn);
@@ -84,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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
if(ext == NULL) return NULL;
ext->state = LV_BTN_STATE_REL;

View File

@@ -9,6 +9,7 @@
#include "lv_btnm.h"
#if LV_USE_BTNM != 0
#include "../lv_core/lv_debug.h"
#include "../lv_core/lv_group.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_core/lv_refr.h"
@@ -70,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_mem_assert(new_btnm);
LV_ASSERT_NO_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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
if(ext == NULL) return NULL;
ext->btn_cnt = 0;
@@ -938,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_mem_assert(ext->button_areas);
LV_ASSERT_NO_MEM(ext->button_areas);
ext->ctrl_bits = lv_mem_alloc(sizeof(lv_btnm_ctrl_t) * btn_cnt);
lv_mem_assert(ext->ctrl_bits);
LV_ASSERT_NO_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

@@ -9,6 +9,7 @@
#include "lv_calendar.h"
#if LV_USE_CALENDAR != 0
#include "../lv_core/lv_debug.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_hal/lv_hal_indev.h"
#include "../lv_misc/lv_utils.h"
@@ -77,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_mem_assert(new_calendar);
LV_ASSERT_NO_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_mem_assert(ext);
LV_ASSERT_NO_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

@@ -8,6 +8,7 @@
*********************/
#include <stdlib.h>
#include "lv_canvas.h"
#include "../lv_core/lv_debug.h"
#include "../lv_misc/lv_math.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_core/lv_refr.h"
@@ -53,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_mem_assert(new_canvas);
LV_ASSERT_NO_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_mem_assert(ext);
LV_ASSERT_NO_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

@@ -9,6 +9,7 @@
#include "lv_cb.h"
#if LV_USE_CB != 0
#include "../lv_core/lv_debug.h"
#include "../lv_core/lv_group.h"
#include "../lv_themes/lv_theme.h"
@@ -55,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_mem_assert(new_cb);
LV_ASSERT_NO_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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
if(ext == NULL) return NULL;
ext->bullet = NULL;

View File

@@ -9,6 +9,7 @@
#include "lv_chart.h"
#if LV_USE_CHART != 0
#include "../lv_core/lv_debug.h"
#include "../lv_core/lv_refr.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_themes/lv_theme.h"
@@ -86,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_mem_assert(new_chart);
LV_ASSERT_NO_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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
if(ext == NULL) return NULL;
lv_ll_init(&ext->series_ll, sizeof(lv_chart_series_t));
@@ -174,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_mem_assert(ser);
LV_ASSERT_NO_MEM(ser);
if(ser == NULL) return NULL;
lv_coord_t def = LV_CHART_POINT_DEF;
@@ -183,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_mem_assert(ser->points);
LV_ASSERT_NO_MEM(ser->points);
if(ser->points == NULL) {
lv_ll_rem(&ext->series_ll, ser);
lv_mem_free(ser);
@@ -297,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_mem_assert(new_points);
LV_ASSERT_NO_MEM(new_points);
if(new_points == NULL) return;
if(point_cnt >= point_cnt_old) {
@@ -320,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_mem_assert(ser->points);
LV_ASSERT_NO_MEM(ser->points);
if(ser->points == NULL) return;
/*Initialize the new points*/
if(point_cnt > point_cnt_old) {

View File

@@ -14,6 +14,7 @@
#include <stdint.h>
#include <string.h>
#include "../lv_core/lv_debug.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_draw/lv_draw_basic.h"
#include "../lv_themes/lv_theme.h"
@@ -67,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_mem_assert(new_cont);
LV_ASSERT_NO_MEM(new_cont);
if(new_cont == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_cont);
@@ -76,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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
ext->fit_left = LV_FIT_NONE;
ext->fit_right = LV_FIT_NONE;
ext->fit_top = LV_FIT_NONE;

View File

@@ -9,6 +9,7 @@
#include "lv_ddlist.h"
#if LV_USE_DDLIST != 0
#include "../lv_core/lv_debug.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_core/lv_group.h"
#include "../lv_core/lv_indev.h"
@@ -74,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_mem_assert(new_ddlist);
LV_ASSERT_NO_MEM(new_ddlist);
if(new_ddlist == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_ddlist);
@@ -83,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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
if(ext == NULL) return NULL;
/*Initialize the allocated 'ext' */

View File

@@ -9,6 +9,7 @@
#include "lv_gauge.h"
#if LV_USE_GAUGE != 0
#include "../lv_core/lv_debug.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_themes/lv_theme.h"
#include "../lv_misc/lv_txt.h"
@@ -65,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_mem_assert(new_gauge);
LV_ASSERT_NO_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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
if(ext == NULL) return NULL;
/*Initialize the allocated 'ext' */
@@ -140,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_mem_assert(ext->values);
LV_ASSERT_NO_MEM(ext->values);
if(ext->values == NULL) return;
int16_t min = lv_gauge_get_min_value(gauge);

View File

@@ -14,6 +14,7 @@
#error "lv_img: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1) "
#endif
#include "../lv_core/lv_debug.h"
#include "../lv_themes/lv_theme.h"
#include "../lv_draw/lv_img_decoder.h"
#include "../lv_misc/lv_fs.h"
@@ -61,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_mem_assert(new_img);
LV_ASSERT_NO_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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
if(ext == NULL) return NULL;
ext->src = NULL;
@@ -164,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_mem_assert(new_str);
LV_ASSERT_NO_MEM(new_str);
if(new_str == NULL) return;
strcpy(new_str, src_img);
ext->src = new_str;

View File

@@ -6,7 +6,10 @@
/*********************
* INCLUDES
*********************/
#include "../lv_core/lv_debug.h"
#include "lv_imgbtn.h"
#if LV_USE_IMGBTN != 0
/*********************
@@ -51,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_mem_assert(new_imgbtn);
LV_ASSERT_NO_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_mem_assert(ext);
LV_ASSERT_NO_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

@@ -10,8 +10,9 @@
#include "lv_kb.h"
#if LV_USE_KB != 0
#include "lv_ta.h"
#include "../lv_core/lv_debug.h"
#include "../lv_themes/lv_theme.h"
#include "lv_ta.h"
/*********************
* DEFINES
@@ -97,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_mem_assert(new_kb);
LV_ASSERT_NO_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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
if(ext == NULL) return NULL;
/*Initialize the allocated 'ext' */

View File

@@ -10,6 +10,7 @@
#if LV_USE_LABEL != 0
#include "../lv_core/lv_obj.h"
#include "../lv_core/lv_debug.h"
#include "../lv_core/lv_group.h"
#include "../lv_misc/lv_color.h"
#include "../lv_misc/lv_math.h"
@@ -18,6 +19,8 @@
/*********************
* DEFINES
*********************/
#define __LV_OBJX_TYPE "lv_label"
/*Test configurations*/
#ifndef LV_LABEL_DEF_SCROLL_SPEED
#define LV_LABEL_DEF_SCROLL_SPEED (25)
@@ -73,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_mem_assert(new_label);
LV_ASSERT_NO_MEM(new_label);
if(new_label == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_label);
@@ -82,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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
if(ext == NULL) return NULL;
ext->text = NULL;
@@ -136,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_mem_assert(ext->text);
LV_ASSERT_NO_MEM(ext->text);
if(ext->text == NULL) return NULL;
memcpy(ext->text, copy_ext->text, lv_mem_get_size(copy_ext->text));
}
@@ -170,6 +173,10 @@ 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_obj_invalidate(label);
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
@@ -183,7 +190,7 @@ void lv_label_set_text(lv_obj_t * label, const char * 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_mem_assert(ext->text);
LV_ASSERT_NO_MEM(ext->text);
if(ext->text == NULL) return;
} else {
/*Allocate space for the new text*/
@@ -194,7 +201,7 @@ void lv_label_set_text(lv_obj_t * label, const char * text)
}
ext->text = lv_mem_alloc(len);
lv_mem_assert(ext->text);
LV_ASSERT_NO_MEM(ext->text);
if(ext->text == NULL) return;
strcpy(ext->text, text);
@@ -237,7 +244,7 @@ void lv_label_set_text_fmt(lv_obj_t * label, const char * fmt, ...)
ext->text = lv_mem_alloc(len+1);
lv_mem_assert(ext->text);
LV_ASSERT_NO_MEM(ext->text);
if(ext->text == NULL) return;
ext->text[len-1] = 0; /* Ensure NULL termination */
@@ -274,7 +281,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_mem_assert(ext->text);
LV_ASSERT_NO_MEM(ext->text);
if(ext->text == NULL) return;
memcpy(ext->text, array, size);
@@ -807,7 +814,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_mem_assert(ext->text);
LV_ASSERT_NO_MEM(ext->text);
if(ext->text == NULL) return;
if(pos == LV_LABEL_POS_LAST) {

View File

@@ -9,6 +9,7 @@
#include "lv_led.h"
#if LV_USE_LED != 0
#include "../lv_core/lv_debug.h"
#include "../lv_themes/lv_theme.h"
#include "../lv_draw/lv_draw.h"
@@ -56,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_mem_assert(new_led);
LV_ASSERT_NO_MEM(new_led);
if(new_led == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_led);
@@ -64,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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
if(ext == NULL) return NULL;
ext->bright = LV_LED_BRIGHT_ON;

View File

@@ -9,6 +9,7 @@
#include "lv_line.h"
#if LV_USE_LINE != 0
#include "../lv_core/lv_debug.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_misc/lv_math.h"
#include <stdbool.h>
@@ -53,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_mem_assert(new_line);
LV_ASSERT_NO_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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
if(ext == NULL) return NULL;
ext->point_num = 0;

View File

@@ -9,6 +9,7 @@
#include "lv_list.h"
#if LV_USE_LIST != 0
#include "../lv_core/lv_debug.h"
#include "../lv_core/lv_group.h"
#include "../lv_themes/lv_theme.h"
#include "../lv_misc/lv_anim.h"
@@ -69,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_mem_assert(new_list);
LV_ASSERT_NO_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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
if(ext == NULL) return NULL;
ext->style_img = NULL;

View File

@@ -9,6 +9,7 @@
#include "lv_lmeter.h"
#if LV_USE_LMETER != 0
#include "../lv_core/lv_debug.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_themes/lv_theme.h"
#include "../lv_core/lv_group.h"
@@ -57,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_mem_assert(new_lmeter);
LV_ASSERT_NO_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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
if(ext == NULL) return NULL;
/*Initialize the allocated 'ext' */

View File

@@ -9,6 +9,7 @@
#include "lv_mbox.h"
#if LV_USE_MBOX != 0
#include "../lv_core/lv_debug.h"
#include "../lv_core/lv_group.h"
#include "../lv_themes/lv_theme.h"
#include "../lv_misc/lv_anim.h"
@@ -68,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_mem_assert(new_mbox);
LV_ASSERT_NO_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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
if(ext == NULL) return NULL;
ext->text = NULL;

View File

@@ -15,6 +15,7 @@
/*********************
* INCLUDES
*********************/
#include "../lv_core/lv_debug.h"
//#include "lv_templ.h" /*TODO uncomment this*/
#if defined(LV_USE_TEMPL) && LV_USE_TEMPL != 0

View File

@@ -9,6 +9,7 @@
#include "../lv_objx/lv_page.h"
#if LV_USE_PAGE != 0
#include "../lv_core/lv_debug.h"
#include "../lv_core/lv_group.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_themes/lv_theme.h"
@@ -77,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_mem_assert(new_page);
LV_ASSERT_NO_MEM(new_page);
if(new_page == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_page);
@@ -85,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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
if(ext == NULL) return NULL;
ext->scrl = NULL;

View File

@@ -9,6 +9,7 @@
#include "lv_preload.h"
#if LV_USE_PRELOAD != 0
#include "../lv_core/lv_debug.h"
#include "../lv_misc/lv_math.h"
#include "../lv_draw/lv_draw_rect.h"
#include "../lv_draw/lv_draw_arc.h"
@@ -66,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_mem_assert(new_preload);
LV_ASSERT_NO_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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
if(ext == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_preload);

View File

@@ -9,6 +9,7 @@
#include "lv_roller.h"
#if LV_USE_ROLLER != 0
#include "../lv_core/lv_debug.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_core/lv_group.h"
#include "../lv_themes/lv_theme.h"
@@ -65,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_mem_assert(new_roller);
LV_ASSERT_NO_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));
@@ -73,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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
if(ext == NULL) return NULL;
ext->ddlist.draw_arrow = 0; /*Do not draw arrow by default*/
@@ -263,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_mem_assert(ext);
lv_mem_assert(ext->ddlist.label);
LV_ASSERT_NO_MEM(ext);
LV_ASSERT_NO_MEM(ext->ddlist.label);
return lv_label_get_align(ext->ddlist.label);
}

View File

@@ -10,6 +10,7 @@
#include "lv_slider.h"
#if LV_USE_SLIDER != 0
#include "../lv_core/lv_debug.h"
#include "../lv_core/lv_group.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_themes/lv_theme.h"
@@ -57,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_mem_assert(new_slider);
LV_ASSERT_NO_MEM(new_slider);
if(new_slider == NULL) return NULL;
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_cb(new_slider);
@@ -65,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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
if(ext == NULL) return NULL;
/*Initialize the allocated 'ext' */

View File

@@ -9,6 +9,7 @@
#include "lv_spinbox.h"
#if LV_USE_SPINBOX != 0
#include "../lv_core/lv_debug.h"
#include "../lv_themes/lv_theme.h"
#include "../lv_misc/lv_math.h"
#include "../lv_misc/lv_utils.h"
@@ -53,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_mem_assert(new_spinbox);
LV_ASSERT_NO_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_mem_assert(ext);
LV_ASSERT_NO_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

@@ -15,6 +15,7 @@
#error "lv_sw: lv_slider is required. Enable it in lv_conf.h (LV_USE_SLIDER 1) "
#endif
#include "../lv_core/lv_debug.h"
#include "../lv_themes/lv_theme.h"
#include "../lv_misc/lv_math.h"
@@ -56,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_mem_assert(new_sw);
LV_ASSERT_NO_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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
if(ext == NULL) return NULL;
/*Initialize the allocated 'ext' */

View File

@@ -9,6 +9,7 @@
#include "lv_ta.h"
#if LV_USE_TA != 0
#include <string.h>
#include "../lv_core/lv_debug.h"
#include "../lv_core/lv_group.h"
#include "../lv_core/lv_refr.h"
#include "../lv_draw/lv_draw.h"
@@ -85,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_mem_assert(new_ta);
LV_ASSERT_NO_MEM(new_ta);
if(new_ta == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_ta);
@@ -95,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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
if(ext == NULL) return NULL;
ext->cursor.state = 1;
@@ -173,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_mem_assert(ext->pwd_tmp);
LV_ASSERT_NO_MEM(ext->pwd_tmp);
if(ext->pwd_tmp == NULL) return NULL;
memcpy(ext->pwd_tmp, copy_ext->pwd_tmp, len);
@@ -267,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_mem_assert(ext->pwd_tmp);
LV_ASSERT_NO_MEM(ext->pwd_tmp);
if(ext->pwd_tmp == NULL) return;
lv_txt_ins(ext->pwd_tmp, ext->cursor.pos, (const char *)letter_buf);
@@ -348,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_mem_assert(ext->pwd_tmp);
LV_ASSERT_NO_MEM(ext->pwd_tmp);
if(ext->pwd_tmp == NULL) return;
lv_txt_ins(ext->pwd_tmp, ext->cursor.pos, txt);
@@ -427,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_mem_assert(ext->pwd_tmp);
LV_ASSERT_NO_MEM(ext->pwd_tmp);
if(ext->pwd_tmp == NULL) return;
}
@@ -489,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_mem_assert(ext->pwd_tmp);
LV_ASSERT_NO_MEM(ext->pwd_tmp);
if(ext->pwd_tmp == NULL) return;
strcpy(ext->pwd_tmp, txt);
@@ -663,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_mem_assert(ext->pwd_tmp);
LV_ASSERT_NO_MEM(ext->pwd_tmp);
if(ext->pwd_tmp == NULL) return;
strcpy(ext->pwd_tmp, txt);

View File

@@ -9,6 +9,7 @@
#include "lv_table.h"
#if LV_USE_TABLE != 0
#include "../lv_core/lv_debug.h"
#include "../lv_misc/lv_txt.h"
#include "../lv_misc/lv_math.h"
#include "../lv_draw/lv_draw_label.h"
@@ -56,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_mem_assert(new_table);
LV_ASSERT_NO_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_mem_assert(ext);
LV_ASSERT_NO_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

@@ -10,6 +10,7 @@
#if LV_USE_TABVIEW != 0
#include "lv_btnm.h"
#include "../lv_core/lv_debug.h"
#include "../lv_themes/lv_theme.h"
#include "../lv_misc/lv_anim.h"
#include "../lv_core/lv_disp.h"
@@ -71,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_mem_assert(new_tabview);
LV_ASSERT_NO_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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
if(ext == NULL) return NULL;
/*Initialize the allocated 'ext' */
@@ -103,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_mem_assert(ext->tab_name_ptr);
LV_ASSERT_NO_MEM(ext->tab_name_ptr);
if(ext->tab_name_ptr == NULL) return NULL;
ext->tab_name_ptr[0] = "";
ext->tab_cnt = 0;
@@ -161,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_mem_assert(ext->tab_name_ptr);
LV_ASSERT_NO_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);
@@ -225,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_mem_assert(name_dm);
LV_ASSERT_NO_MEM(name_dm);
if(name_dm == NULL) return NULL;
strcpy(name_dm, name);
@@ -242,7 +243,7 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name)
break;
}
lv_mem_assert(ext->tab_name_ptr);
LV_ASSERT_NO_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

@@ -11,6 +11,7 @@
#include <stdbool.h>
#include "lv_cont.h"
#include "../lv_core/lv_debug.h"
#include "../lv_themes/lv_theme.h"
/*********************
@@ -65,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_mem_assert(new_tileview);
LV_ASSERT_NO_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_mem_assert(ext);
LV_ASSERT_NO_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

@@ -9,6 +9,7 @@
#include "lv_win.h"
#if LV_USE_WIN != 0
#include "../lv_core/lv_debug.h"
#include "../lv_themes/lv_theme.h"
#include "../lv_core/lv_disp.h"
@@ -51,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_mem_assert(new_win);
LV_ASSERT_NO_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_mem_assert(ext);
LV_ASSERT_NO_MEM(ext);
if(ext == NULL) return NULL;
ext->page = NULL;