From 662c22b51a3ef2c58cb261be99a90dffa9d5fdc9 Mon Sep 17 00:00:00 2001 From: Gabor Date: Wed, 21 Jun 2017 10:26:23 +0200 Subject: [PATCH] lv_obj_del: reset the dispi-s only if it is really required --- lv_obj/lv_dispi.c | 16 ++++++++++++---- lv_obj/lv_dispi.h | 6 ++++++ lv_obj/lv_obj.c | 23 +++++++++++++++++++---- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/lv_obj/lv_dispi.c b/lv_obj/lv_dispi.c index 157b65f93..27afa2ce9 100644 --- a/lv_obj/lv_dispi.c +++ b/lv_obj/lv_dispi.c @@ -41,6 +41,7 @@ static void dispi_drag_throw(lv_dispi_t * dispi_p); static ptask_t* dispi_task_p; static bool lv_dispi_reset_qry; static bool lv_dispi_reset_now; +static lv_dispi_t dispi_array[INDEV_NUM]; /********************** * MACROS @@ -65,6 +66,15 @@ void lv_dispi_init(void) #endif } +/** + * Get an array with all the display inputs. Contains (INDEV_NUM elements) + * @return pointer to a an lv_dispi_t array. + */ +lv_dispi_t * lv_dispi_get_array(void) +{ + return dispi_array; +} + /** * Reset all display inputs */ @@ -135,15 +145,13 @@ void lv_dispi_wait_release(lv_dispi_t * dispi) */ static void dispi_task(void * param) { - - static lv_dispi_t dispi[INDEV_NUM]; cord_t x; cord_t y; uint8_t i; for (i = 0; i < INDEV_NUM; i++) { - dispi[i].pressed = indev_get(i, &x, &y); - dispi_proc_point(&dispi[i], x, y); + dispi_array[i].pressed = indev_get(i, &x, &y); + dispi_proc_point(&dispi_array[i], x, y); } /*If reset query occurred in this round then set a flag to diff --git a/lv_obj/lv_dispi.h b/lv_obj/lv_dispi.h index b5175cb05..beb0eade4 100644 --- a/lv_obj/lv_dispi.h +++ b/lv_obj/lv_dispi.h @@ -55,6 +55,12 @@ typedef lv_action_res_t ( * lv_action_t) (struct __LV_OBJ_T * obj, lv_dispi_t * */ void lv_dispi_init(void); +/** + * Get an array with all the display inputs. Contains (INDEV_NUM elements) + * @return pointer to a an lv_dispi_t array. + */ +lv_dispi_t * lv_dispi_get_array(void); + /** * Reset all display inputs */ diff --git a/lv_obj/lv_obj.c b/lv_obj/lv_obj.c index 969cbf89f..4ec4539e8 100644 --- a/lv_obj/lv_obj.c +++ b/lv_obj/lv_obj.c @@ -15,6 +15,7 @@ #include "lvgl/lv_app/lv_app.h" #include "lvgl/lv_draw/lv_draw_rbasic.h" #include "misc/gfx/anim.h" +#include "hal/indev/indev.h" #include #include @@ -280,10 +281,24 @@ void lv_obj_del(lv_obj_t * obj) if(obj->ext != NULL) dm_free(obj->ext); dm_free(obj); /*Free the object itself*/ - /* Reset all display input (dispi) because - * the deleted object can be being pressed*/ - lv_dispi_reset(); - + /* Reset all display input (dispi) if + * the currently pressed object is deleted too*/ + lv_dispi_t * dispi_array = lv_dispi_get_array(); + lv_obj_t * dpar; + uint8_t d; + for(d = 0; d < INDEV_NUM; d++) { + dpar = obj; + while(dpar != NULL) { + if(dispi_array[d].act_obj == dpar || + dispi_array[d].last_obj == dpar) { + lv_dispi_reset(); + break; + } else { + dpar = lv_obj_get_parent(dpar); + } + } + } + /*Send a signal to the parent to notify it about the child delete*/ if(par != NULL) { par->signal_f(par, LV_SIGNAL_CHILD_CHG, NULL);