1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-21 06:53:01 +08:00

add logs + minor fixes

This commit is contained in:
Gabor Kiss-Vamosi 2021-03-01 12:00:13 +01:00
parent bcafd8a0b0
commit 403351222e
7 changed files with 75 additions and 22 deletions

View File

@ -20,7 +20,6 @@
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/
#if LV_INDEV_DEF_SCROLL_THROW <= 0 #if LV_INDEV_DEF_SCROLL_THROW <= 0
#warning "LV_INDEV_DRAG_THROW must be greater than 0" #warning "LV_INDEV_DRAG_THROW must be greater than 0"
#endif #endif
@ -52,6 +51,11 @@ static lv_obj_t * indev_obj_act = NULL;
/********************** /**********************
* MACROS * MACROS
**********************/ **********************/
#if LV_LOG_TRACE_INDEV
# define INDEV_TRACE(...) LV_LOG_TRACE( __VA_ARGS__)
#else
# define INDEV_TRACE(...)
#endif
/********************** /**********************
* GLOBAL FUNCTIONS * GLOBAL FUNCTIONS
@ -59,7 +63,7 @@ static lv_obj_t * indev_obj_act = NULL;
void lv_indev_read_task_cb(lv_timer_t * task) void lv_indev_read_task_cb(lv_timer_t * task)
{ {
LV_LOG_TRACE("begin"); INDEV_TRACE("begin");
lv_indev_data_t data; lv_indev_data_t data;
@ -111,7 +115,7 @@ void lv_indev_read_task_cb(lv_timer_t * task)
indev_act = NULL; indev_act = NULL;
indev_obj_act = NULL; indev_obj_act = NULL;
LV_LOG_TRACE("finished"); INDEV_TRACE("finished");
} }
void lv_indev_enable(lv_indev_t * indev, bool en) void lv_indev_enable(lv_indev_t * indev, bool en)
@ -387,6 +391,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
/*Key press happened*/ /*Key press happened*/
if(data->state == LV_INDEV_STATE_PRESSED && prev_state == LV_INDEV_STATE_RELEASED) { if(data->state == LV_INDEV_STATE_PRESSED && prev_state == LV_INDEV_STATE_RELEASED) {
LV_LOG_INFO("%d key is pressed", data->key);
i->proc.pr_timestamp = lv_tick_get(); i->proc.pr_timestamp = lv_tick_get();
/*Simulate a press on the object if ENTER was pressed*/ /*Simulate a press on the object if ENTER was pressed*/
@ -478,6 +483,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
} }
/*Release happened*/ /*Release happened*/
else if(data->state == LV_INDEV_STATE_RELEASED && prev_state == LV_INDEV_STATE_PRESSED) { else if(data->state == LV_INDEV_STATE_RELEASED && prev_state == LV_INDEV_STATE_PRESSED) {
LV_LOG_INFO("%d key is released", data->key);
/*The user might clear the key when it was released. Always release the pressed key*/ /*The user might clear the key when it was released. Always release the pressed key*/
data->key = prev_key; data->key = prev_key;
if(data->key == LV_KEY_ENTER) { if(data->key == LV_KEY_ENTER) {
@ -541,6 +547,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
/*Button press happened*/ /*Button press happened*/
if(data->state == LV_INDEV_STATE_PRESSED && last_state == LV_INDEV_STATE_RELEASED) { if(data->state == LV_INDEV_STATE_PRESSED && last_state == LV_INDEV_STATE_RELEASED) {
LV_LOG_INFO("pressed");
i->proc.pr_timestamp = lv_tick_get(); i->proc.pr_timestamp = lv_tick_get();
@ -633,6 +640,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
} }
/*Release happened*/ /*Release happened*/
else if(data->state == LV_INDEV_STATE_RELEASED && last_state == LV_INDEV_STATE_PRESSED) { else if(data->state == LV_INDEV_STATE_RELEASED && last_state == LV_INDEV_STATE_PRESSED) {
LV_LOG_INFO("released");
if(data->key == LV_KEY_ENTER) { if(data->key == LV_KEY_ENTER) {
bool editable = lv_obj_is_editable(indev_obj_act); bool editable = lv_obj_is_editable(indev_obj_act);
@ -684,6 +692,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
/*if encoder steps or simulated steps via left/right keys*/ /*if encoder steps or simulated steps via left/right keys*/
if(data->enc_diff != 0) { if(data->enc_diff != 0) {
LV_LOG_INFO("rotated by %d", data->enc_diff);
/*In edit mode send LEFT/RIGHT keys*/ /*In edit mode send LEFT/RIGHT keys*/
if(lv_group_get_editing(g)) { if(lv_group_get_editing(g)) {
int32_t s; int32_t s;
@ -717,13 +726,23 @@ static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data)
{ {
/* Die gracefully if i->btn_points is NULL */ /* Die gracefully if i->btn_points is NULL */
if(i->btn_points == NULL) { if(i->btn_points == NULL) {
LV_LOG_WARN("indev_button_proc: btn_points was NULL"); LV_LOG_WARN("btn_points is NULL");
return; return;
} }
lv_coord_t x = i->btn_points[data->btn_id].x; lv_coord_t x = i->btn_points[data->btn_id].x;
lv_coord_t y = i->btn_points[data->btn_id].y; lv_coord_t y = i->btn_points[data->btn_id].y;
static lv_indev_state_t prev_state = LV_INDEV_STATE_RELEASED;
if(prev_state != data->state) {
if(data->state == LV_INDEV_STATE_PRESSED) {
LV_LOG_INFO("button %d is pressed (x:%d y:%d)", data->btn_id, x, y);
}
else {
LV_LOG_INFO("button %d is released (x:%d y:%d)", data->btn_id, x, y);
}
}
/*If a new point comes always make a release*/ /*If a new point comes always make a release*/
if(data->state == LV_INDEV_STATE_PRESSED) { if(data->state == LV_INDEV_STATE_PRESSED) {
if(i->proc.types.pointer.last_point.x != x || if(i->proc.types.pointer.last_point.x != x ||
@ -754,6 +773,7 @@ static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data)
*/ */
static void indev_proc_press(lv_indev_proc_t * proc) static void indev_proc_press(lv_indev_proc_t * proc)
{ {
LV_LOG_INFO("pressed at x:%d y:%d", proc->types.pointer.act_point.x, proc->types.pointer.act_point.y);
indev_obj_act = proc->types.pointer.act_obj; indev_obj_act = proc->types.pointer.act_obj;
if(proc->wait_until_release != 0) return; if(proc->wait_until_release != 0) return;
@ -911,6 +931,7 @@ static void indev_proc_release(lv_indev_proc_t * proc)
/*Forget the act obj and send a released signal */ /*Forget the act obj and send a released signal */
if(indev_obj_act) { if(indev_obj_act) {
LV_LOG_INFO("released");
/*Send RELEASE signal and event*/ /*Send RELEASE signal and event*/
lv_signal_send(indev_obj_act, LV_SIGNAL_RELEASED, indev_act); lv_signal_send(indev_obj_act, LV_SIGNAL_RELEASED, indev_act);

View File

@ -88,6 +88,17 @@ const lv_obj_class_t lv_obj_class = {
/********************** /**********************
* MACROS * MACROS
**********************/ **********************/
#if LV_LOG_TRACE_EVENT
# define EVENT_TRACE(...) LV_LOG_TRACE( __VA_ARGS__)
#else
# define EVENT_TRACE(...)
#endif
#if LV_LOG_TRACE_SIGNAL
# define SIGNAL_TRACE(...) LV_LOG_TRACE( __VA_ARGS__)
#else
# define SIGNAL_TRACE(...)
#endif
/********************** /**********************
* GLOBAL FUNCTIONS * GLOBAL FUNCTIONS
@ -101,7 +112,7 @@ void lv_init(void)
return; return;
} }
LV_LOG_TRACE("begin"); LV_LOG_INFO("begin");
/*Initialize the lv_misc modules*/ /*Initialize the lv_misc modules*/
lv_mem_init(); lv_mem_init();
@ -188,7 +199,7 @@ lv_res_t lv_event_send(lv_obj_t * obj, lv_event_t event, void * param)
LV_ASSERT_OBJ(obj, MY_CLASS); LV_ASSERT_OBJ(obj, MY_CLASS);
LV_LOG_TRACE("Sending event %d to 0x%p with 0x%p param", event, obj, param); EVENT_TRACE("Sending event %d to 0x%p with 0x%p param", event, obj, param);
/*Nothing to do if no event function and not bubbled*/ /*Nothing to do if no event function and not bubbled*/
lv_event_dsc_t * event_dsc = lv_obj_get_event_dsc(obj, 0); lv_event_dsc_t * event_dsc = lv_obj_get_event_dsc(obj, 0);
@ -289,7 +300,7 @@ lv_res_t lv_signal_send(lv_obj_t * obj, lv_signal_t signal, void * param)
{ {
if(obj == NULL) return LV_RES_OK; if(obj == NULL) return LV_RES_OK;
LV_LOG_TRACE("Sending signal %d to 0x%p with 0x%p param", signal, obj, param); SIGNAL_TRACE("Sending signal %d to 0x%p with 0x%p param", signal, obj, param);
const lv_obj_class_t * class_p = obj->class_p; const lv_obj_class_t * class_p = obj->class_p;
while(class_p && class_p->signal_cb == NULL) class_p = class_p->base_class; while(class_p && class_p->signal_cb == NULL) class_p = class_p->base_class;
@ -546,12 +557,12 @@ bool lv_obj_is_valid(const lv_obj_t * obj)
static void lv_obj_constructor(lv_obj_t * obj, const lv_obj_t * copy) static void lv_obj_constructor(lv_obj_t * obj, const lv_obj_t * copy)
{ {
LV_LOG_TRACE("begin"); LV_TRACE_OBJ_CREATE("begin");
lv_obj_t * parent = obj->parent; lv_obj_t * parent = obj->parent;
/*Create a screen*/ /*Create a screen*/
if(parent == NULL) { if(parent == NULL) {
LV_LOG_TRACE("creating a screen"); LV_TRACE_OBJ_CREATE("creating a screen");
lv_disp_t * disp = lv_disp_get_default(); lv_disp_t * disp = lv_disp_get_default();
if(!disp) { if(!disp) {
LV_LOG_WARN("No display created to so far. No place to assign the new screen"); LV_LOG_WARN("No display created to so far. No place to assign the new screen");
@ -576,7 +587,7 @@ static void lv_obj_constructor(lv_obj_t * obj, const lv_obj_t * copy)
} }
/*Create a normal object*/ /*Create a normal object*/
else { else {
LV_LOG_TRACE("creating normal object"); LV_TRACE_OBJ_CREATE("creating normal object");
LV_ASSERT_OBJ(parent, MY_CLASS); LV_ASSERT_OBJ(parent, MY_CLASS);
if(parent->spec_attr == NULL) { if(parent->spec_attr == NULL) {
lv_obj_allocate_spec_attr(parent); lv_obj_allocate_spec_attr(parent);
@ -648,7 +659,7 @@ static void lv_obj_constructor(lv_obj_t * obj, const lv_obj_t * copy)
} }
} }
LV_LOG_TRACE("finished"); LV_TRACE_OBJ_CREATE("finished");
} }
static void lv_obj_destructor(lv_obj_t * p) static void lv_obj_destructor(lv_obj_t * p)

View File

@ -525,6 +525,12 @@ bool lv_obj_is_valid(const lv_obj_t * obj);
# define LV_ASSERT_OBJ(obj_p, obj_class) do{}while(0) # define LV_ASSERT_OBJ(obj_p, obj_class) do{}while(0)
#endif #endif
#if LV_LOG_TRACE_OBJ_CREATE
# define LV_TRACE_OBJ_CREATE(...) LV_LOG_TRACE( __VA_ARGS__)
#else
# define LV_TRACE_OBJ_CREATE(...)
#endif
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */

View File

@ -42,7 +42,7 @@ static uint32_t get_instance_size(const lv_obj_class_t * class_p);
lv_obj_t * lv_obj_create_from_class(const lv_obj_class_t * class_p, lv_obj_t * parent, const lv_obj_t * copy) lv_obj_t * lv_obj_create_from_class(const lv_obj_class_t * class_p, lv_obj_t * parent, const lv_obj_t * copy)
{ {
LV_LOG_TRACE("Creating object with 0x%p class on 0x%p parent", class_p, parent); LV_TRACE_OBJ_CREATE("Creating object with 0x%p class on 0x%p parent", class_p, parent);
uint32_t s = get_instance_size(class_p); uint32_t s = get_instance_size(class_p);
lv_obj_t * obj = lv_mem_alloc(s); lv_obj_t * obj = lv_mem_alloc(s);
lv_memset_00(obj, s); lv_memset_00(obj, s);
@ -66,7 +66,7 @@ lv_obj_t * lv_obj_create_from_class(const lv_obj_class_t * class_p, lv_obj_t * p
if(!copy) lv_theme_apply(obj); if(!copy) lv_theme_apply(obj);
// else lv_style_list_copy(&checkbox->style_indic, &checkbox_copy->style_indic); // else lv_style_list_copy(&checkbox->style_indic, &checkbox_copy->style_indic);
LV_LOG_TRACE("Object created at 0x%p address with 0x%p class on 0x%p parent", obj, class_p, parent); LV_TRACE_OBJ_CREATE("Object created at 0x%p address with 0x%p class on 0x%p parent", obj, class_p, parent);
return obj; return obj;
} }

View File

@ -187,15 +187,15 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
lv_coord_t ptop = lv_obj_get_style_pad_top(parent, LV_PART_MAIN); lv_coord_t ptop = lv_obj_get_style_pad_top(parent, LV_PART_MAIN);
switch(align) { switch(align) {
case LV_ALIGN_CENTER: case LV_ALIGN_CENTER:
x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2 - pleft; x = lv_obj_get_width_fit(base) / 2 - lv_obj_get_width(obj) / 2;
y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2- ptop; y = lv_obj_get_height_fit(base) / 2 - lv_obj_get_height(obj) / 2;
break; break;
case LV_ALIGN_IN_TOP_LEFT: case LV_ALIGN_IN_TOP_LEFT:
x = 0; x = 0;
y = 0; y = 0;
break; break;
case LV_ALIGN_IN_TOP_MID: case LV_ALIGN_IN_TOP_MID:
x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2 - pleft; x = lv_obj_get_width_fit(base) / 2 - lv_obj_get_width(obj) / 2;
y = 0; y = 0;
break; break;
@ -209,7 +209,7 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
y = lv_obj_get_height_fit(base) - lv_obj_get_height(obj); y = lv_obj_get_height_fit(base) - lv_obj_get_height(obj);
break; break;
case LV_ALIGN_IN_BOTTOM_MID: case LV_ALIGN_IN_BOTTOM_MID:
x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2 - pleft; x = lv_obj_get_width_fit(base) / 2 - lv_obj_get_width(obj) / 2;
y = lv_obj_get_height_fit(base) - lv_obj_get_height(obj); y = lv_obj_get_height_fit(base) - lv_obj_get_height(obj);
break; break;
@ -220,7 +220,7 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
case LV_ALIGN_IN_LEFT_MID: case LV_ALIGN_IN_LEFT_MID:
x = 0; x = 0;
y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2; y = lv_obj_get_height_fit(base) / 2 - lv_obj_get_height(obj) / 2;
break; break;
case LV_ALIGN_IN_RIGHT_MID: case LV_ALIGN_IN_RIGHT_MID:

View File

@ -45,6 +45,7 @@ static void obj_del_core(lv_obj_t * obj);
void lv_obj_del(lv_obj_t * obj) void lv_obj_del(lv_obj_t * obj)
{ {
LV_LOG_TRACE("begin (delete 0x%p)", obj)
LV_ASSERT_OBJ(obj, MY_CLASS); LV_ASSERT_OBJ(obj, MY_CLASS);
lv_obj_invalidate(obj); lv_obj_invalidate(obj);
@ -76,12 +77,17 @@ void lv_obj_del(lv_obj_t * obj)
/*Handle if the active screen was deleted*/ /*Handle if the active screen was deleted*/
if(act_scr_del) { if(act_scr_del) {
LV_LOG_WARN("the active screen was deleted")
disp->act_scr = NULL; disp->act_scr = NULL;
} }
LV_ASSERT_MEM_INTEGRITY();
LV_LOG_TRACE("finished (delete 0x%p)", obj)
} }
void lv_obj_clean(lv_obj_t * obj) void lv_obj_clean(lv_obj_t * obj)
{ {
LV_LOG_TRACE("begin (delete 0x%p)", obj)
LV_ASSERT_OBJ(obj, MY_CLASS); LV_ASSERT_OBJ(obj, MY_CLASS);
lv_obj_invalidate(obj); lv_obj_invalidate(obj);
@ -97,6 +103,10 @@ void lv_obj_clean(lv_obj_t * obj)
obj->spec_attr->scroll.x = 0; obj->spec_attr->scroll.x = 0;
obj->spec_attr->scroll.y = 0; obj->spec_attr->scroll.y = 0;
} }
LV_ASSERT_MEM_INTEGRITY();
LV_LOG_TRACE("finished (delete 0x%p)", obj)
} }
void lv_obj_del_anim_ready_cb(lv_anim_t * a) void lv_obj_del_anim_ready_cb(lv_anim_t * a)

View File

@ -60,6 +60,11 @@ static lv_disp_t * disp_refr; /*Display being refreshed*/
/********************** /**********************
* MACROS * MACROS
**********************/ **********************/
#if LV_LOG_TRACE_DISP_REFR
# define TRACE_REFR(...) LV_LOG_TRACE( __VA_ARGS__)
#else
# define TRACE_REFR(...)
#endif
/********************** /**********************
* GLOBAL FUNCTIONS * GLOBAL FUNCTIONS
@ -180,7 +185,7 @@ void _lv_refr_set_disp_refreshing(lv_disp_t * disp)
*/ */
void _lv_disp_refr_task(lv_timer_t * tmr) void _lv_disp_refr_task(lv_timer_t * tmr)
{ {
LV_LOG_TRACE("begin"); TRACE_REFR("begin");
uint32_t start = lv_tick_get(); uint32_t start = lv_tick_get();
uint32_t elaps = 0; uint32_t elaps = 0;
@ -197,7 +202,7 @@ void _lv_disp_refr_task(lv_timer_t * tmr)
/*Do nothing if there is no active screen*/ /*Do nothing if there is no active screen*/
if(disp_refr->act_scr == NULL) { if(disp_refr->act_scr == NULL) {
disp_refr->inv_p = 0; disp_refr->inv_p = 0;
LV_LOG_TRACE("finished (there were no invalid areas to redraw)"); TRACE_REFR("finished (there were no invalid areas to redraw)");
return; return;
} }
@ -299,7 +304,7 @@ void _lv_disp_refr_task(lv_timer_t * tmr)
} }
#endif #endif
LV_LOG_TRACE("finished"); TRACE_REFR("finished");
} }
#if LV_USE_PERF_MONITOR #if LV_USE_PERF_MONITOR
@ -933,6 +938,6 @@ static lv_draw_res_t call_draw_cb(lv_obj_t * obj, const lv_area_t * clip_area, l
static void call_flush_cb(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_p) static void call_flush_cb(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_p)
{ {
LV_LOG_TRACE("Calling flush_cb on (%d;%d)(%d;%d) area with 0x%p image pointer", area->x1, area->y1, area->x2, area->y2, color_p); TRACE_REFR("Calling flush_cb on (%d;%d)(%d;%d) area with 0x%p image pointer", area->x1, area->y1, area->x2, area->y2, color_p);
drv->flush_cb(drv, area, color_p); drv->flush_cb(drv, area, color_p);
} }