From 076540752b7664d1d3d7920f5c60b7f6f54806d8 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sat, 24 Feb 2018 15:36:06 +0100 Subject: [PATCH] prevent refresh after drag is no movement happened --- lv_core/lv_indev.c | 10 ++++++++-- lv_core/lv_refr.c | 19 +++++++++++++++++++ lv_core/lv_refr.h | 11 +++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/lv_core/lv_indev.c b/lv_core/lv_indev.c index e5fa5b14d..4b6a875e9 100644 --- a/lv_core/lv_indev.c +++ b/lv_core/lv_indev.c @@ -11,6 +11,7 @@ #include "../lv_hal/lv_hal_tick.h" #include "../lv_core/lv_group.h" +#include "../lv_core/lv_refr.h" #include "../lv_misc/lv_task.h" #include "../lv_misc/lv_math.h" #include "../lv_draw/lv_draw_rbasic.h" @@ -646,9 +647,10 @@ static void indev_drag(lv_indev_proc_t * state) /*Set new position if the vector is not zero*/ if(state->vect.x != 0 || state->vect.y != 0) { - /*Get the coordinates of the object end modify them*/ + /*Get the coordinates of the object and modify them*/ lv_coord_t act_x = lv_obj_get_x(drag_obj); lv_coord_t act_y = lv_obj_get_y(drag_obj); + uint16_t inv_buf_size = lv_refr_get_buf_size(); /*Get the number of currently invalidated areas*/ lv_obj_set_pos(drag_obj, act_x + state->vect.x, act_y + state->vect.y); @@ -660,7 +662,11 @@ static void indev_drag(lv_indev_proc_t * state) } state->drag_in_prog = 1; } - + /*If the object didn't moved then clear the invalidated areas*/ + else { + uint16_t new_inv_buf_size = lv_refr_get_buf_size(); + lv_refr_pop_from_buf(new_inv_buf_size - inv_buf_size); + } } } } diff --git a/lv_core/lv_refr.c b/lv_core/lv_refr.c index fe204e2e9..fe6f065de 100644 --- a/lv_core/lv_refr.c +++ b/lv_core/lv_refr.c @@ -139,6 +139,25 @@ void lv_refr_set_round_cd(void(*cb)(lv_area_t*)) round_cb = cb; } +/** + * Get the number of areas in the buffer + * @return number of invalid areas + */ +uint16_t lv_refr_get_buf_size(void) +{ + return inv_buf_p; +} + +/** + * Pop (delete) the last 'num' invalidated areas from the buffer + * @param num number of areas to delete + */ +void lv_refr_pop_from_buf(uint16_t num) +{ + if(inv_buf_p < num) inv_buf_p = 0; + else inv_buf_p -= num; +} + /********************** * STATIC FUNCTIONS **********************/ diff --git a/lv_core/lv_refr.h b/lv_core/lv_refr.h index f0b5ab079..5b3d67e7c 100644 --- a/lv_core/lv_refr.h +++ b/lv_core/lv_refr.h @@ -65,6 +65,17 @@ void lv_refr_set_monitor_cb(void (*cb)(uint32_t, uint32_t)); */ void lv_refr_set_round_cd(void(*cb)(lv_area_t*)); +/** + * Get the number of areas in the buffer + * @return number of invalid areas + */ +uint16_t lv_refr_get_buf_size(void); + +/** + * Pop (delete) the last 'num' invalidated areas from the buffer + * @param num number of areas to delete + */ +void lv_refr_pop_from_buf(uint16_t num); /********************** * STATIC FUNCTIONS **********************/