From bc369de6fa7086f68f968ac5bb43074ab1a80ceb Mon Sep 17 00:00:00 2001 From: xennex22 <25083624+xennex22@users.noreply.github.com> Date: Tue, 24 Nov 2020 09:16:16 -0800 Subject: [PATCH 01/15] Removed trailing semi-colon from macros (#1928) * Removed commented out test definition Removed commented out test definition LV_BUILD_TEST * Remove blank line * Fix comment spelling * Added blank line * Removed trailing semi-colon in macros --- lvgl.h | 2 -- src/lv_conf_internal.h | 2 +- src/lv_draw/lv_draw_blend.c | 1 - src/lv_misc/lv_color.h | 26 +++++++++++++------------- src/lv_misc/lv_txt.h | 1 + 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/lvgl.h b/lvgl.h index 66f6984cd..94a9301d0 100644 --- a/lvgl.h +++ b/lvgl.h @@ -82,8 +82,6 @@ extern "C" { #include "src/lv_api_map.h" -//#define LV_BUILD_TEST 1 - /********************* * DEFINES *********************/ diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index 5287c7471..c24c0131a 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -1318,7 +1318,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ /* Support bidirectional texts. * Allows mixing Left-to-Right and Right-to-Left texts. - * The direction will be processed according to the Unicode Bidirectioanl Algorithm: + * The direction will be processed according to the Unicode Bidirectional Algorithm: * https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ #ifndef LV_USE_BIDI # ifdef CONFIG_LV_USE_BIDI diff --git a/src/lv_draw/lv_draw_blend.c b/src/lv_draw/lv_draw_blend.c index 320a6a790..d5187815c 100644 --- a/src/lv_draw/lv_draw_blend.c +++ b/src/lv_draw/lv_draw_blend.c @@ -25,7 +25,6 @@ *********************/ #define GPU_SIZE_LIMIT 240 - /********************** * TYPEDEFS **********************/ diff --git a/src/lv_misc/lv_color.h b/src/lv_misc/lv_color.h index b7d5e5299..42f2c413e 100644 --- a/src/lv_misc/lv_color.h +++ b/src/lv_misc/lv_color.h @@ -108,9 +108,9 @@ enum { * Macros for all existing color depths * to set/get values of the color channels *------------------------------------------*/ -# define LV_COLOR_SET_R1(c, v) (c).ch.red = (uint8_t)((v) & 0x1); -# define LV_COLOR_SET_G1(c, v) (c).ch.green = (uint8_t)((v) & 0x1); -# define LV_COLOR_SET_B1(c, v) (c).ch.blue = (uint8_t)((v) & 0x1); +# define LV_COLOR_SET_R1(c, v) (c).ch.red = (uint8_t)((v) & 0x1) +# define LV_COLOR_SET_G1(c, v) (c).ch.green = (uint8_t)((v) & 0x1) +# define LV_COLOR_SET_B1(c, v) (c).ch.blue = (uint8_t)((v) & 0x1) # define LV_COLOR_SET_A1(c, v) # define LV_COLOR_GET_R1(c) (c).ch.red @@ -118,9 +118,9 @@ enum { # define LV_COLOR_GET_B1(c) (c).ch.blue # define LV_COLOR_GET_A1(c) 1 -# define LV_COLOR_SET_R8(c, v) (c).ch.red = (uint8_t)(v) & 0x7U; -# define LV_COLOR_SET_G8(c, v) (c).ch.green = (uint8_t)(v) & 0x7U; -# define LV_COLOR_SET_B8(c, v) (c).ch.blue = (uint8_t)(v) & 0x3U; +# define LV_COLOR_SET_R8(c, v) (c).ch.red = (uint8_t)(v) & 0x7U +# define LV_COLOR_SET_G8(c, v) (c).ch.green = (uint8_t)(v) & 0x7U +# define LV_COLOR_SET_B8(c, v) (c).ch.blue = (uint8_t)(v) & 0x3U # define LV_COLOR_SET_A8(c, v) do {} while(0) # define LV_COLOR_GET_R8(c) (c).ch.red @@ -128,10 +128,10 @@ enum { # define LV_COLOR_GET_B8(c) (c).ch.blue # define LV_COLOR_GET_A8(c) 0xFF -# define LV_COLOR_SET_R16(c, v) (c).ch.red = (uint8_t)(v) & 0x1FU; -# define LV_COLOR_SET_G16(c, v) (c).ch.green = (uint8_t)(v) & 0x3FU; +# define LV_COLOR_SET_R16(c, v) (c).ch.red = (uint8_t)(v) & 0x1FU +# define LV_COLOR_SET_G16(c, v) (c).ch.green = (uint8_t)(v) & 0x3FU # define LV_COLOR_SET_G16_SWAP(c, v) {(c).ch.green_h = (uint8_t)(((v) >> 3) & 0x7); (c).ch.green_l = (uint8_t)((v) & 0x7);} -# define LV_COLOR_SET_B16(c, v) (c).ch.blue = (uint8_t)(v) & 0x1FU; +# define LV_COLOR_SET_B16(c, v) (c).ch.blue = (uint8_t)(v) & 0x1FU # define LV_COLOR_SET_A16(c, v) do {} while(0) # define LV_COLOR_GET_R16(c) (c).ch.red @@ -140,10 +140,10 @@ enum { # define LV_COLOR_GET_B16(c) (c).ch.blue # define LV_COLOR_GET_A16(c) 0xFF -# define LV_COLOR_SET_R32(c, v) (c).ch.red = (uint32_t)((v) & 0xFF); -# define LV_COLOR_SET_G32(c, v) (c).ch.green = (uint32_t)((v) & 0xFF); -# define LV_COLOR_SET_B32(c, v) (c).ch.blue = (uint32_t)((v) & 0xFF); -# define LV_COLOR_SET_A32(c, v) (c).ch.alpha = (uint32_t)((v) & 0xFF); +# define LV_COLOR_SET_R32(c, v) (c).ch.red = (uint32_t)((v) & 0xFF) +# define LV_COLOR_SET_G32(c, v) (c).ch.green = (uint32_t)((v) & 0xFF) +# define LV_COLOR_SET_B32(c, v) (c).ch.blue = (uint32_t)((v) & 0xFF) +# define LV_COLOR_SET_A32(c, v) (c).ch.alpha = (uint32_t)((v) & 0xFF) # define LV_COLOR_GET_R32(c) (c).ch.red # define LV_COLOR_GET_G32(c) (c).ch.green diff --git a/src/lv_misc/lv_txt.h b/src/lv_misc/lv_txt.h index 77a911d14..52df561ce 100644 --- a/src/lv_misc/lv_txt.h +++ b/src/lv_misc/lv_txt.h @@ -20,6 +20,7 @@ extern "C" { #include "lv_area.h" #include "../lv_font/lv_font.h" #include "lv_printf.h" + /********************* * DEFINES *********************/ From fa49f35b14b4395617c42aa351cba846ed1cec8c Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 25 Nov 2020 09:47:35 +0100 Subject: [PATCH 02/15] fix(indev): in LV_INDEV_TYPE_BUTTON recognize 1 cycle long presses too Fixes https://forum.lvgl.io/t/bug-in-indev-button-proc-misses-buttons-that-are-pressed-for-a-single-callback/3699 --- CHANGELOG.md | 1 + src/lv_core/lv_indev.c | 29 +++++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2308ada3c..fe575f96e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - fix(textarea) support Arabic letter connections - fix(dropdown) support Arabic letter connections - fix(value_str) support Arabic letter connections in value string property +- fix(indev) in LV_INDEV_TYPE_BUTTON recognize 1 cycle long presses too ## v7.7.2 (17.11.2020) ### Bugfixes diff --git a/src/lv_core/lv_indev.c b/src/lv_core/lv_indev.c index 217e712e4..597a0ae6f 100644 --- a/src/lv_core/lv_indev.c +++ b/src/lv_core/lv_indev.c @@ -807,19 +807,28 @@ static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data) return; } - i->proc.types.pointer.act_point.x = i->btn_points[data->btn_id].x; - i->proc.types.pointer.act_point.y = i->btn_points[data->btn_id].y; + lv_coord_t x = i->btn_points[data->btn_id].x; + lv_coord_t y = i->btn_points[data->btn_id].y; - /*Still the same point is pressed*/ - if(i->proc.types.pointer.last_point.x == i->proc.types.pointer.act_point.x && - i->proc.types.pointer.last_point.y == i->proc.types.pointer.act_point.y && data->state == LV_INDEV_STATE_PR) { - indev_proc_press(&i->proc); - } - else { - /*If a new point comes always make a release*/ - indev_proc_release(&i->proc); + /*If a new point comes always make a release*/ + if(data->state == LV_INDEV_STATE_PR) { + if(i->proc.types.pointer.last_point.x != x || + i->proc.types.pointer.last_point.y != y) { + indev_proc_release(&i->proc); + } } + if(indev_reset_check(&i->proc)) return; + + /*Save the new points*/ + i->proc.types.pointer.act_point.x = x; + i->proc.types.pointer.act_point.y = y; + + if(data->state == LV_INDEV_STATE_PR) indev_proc_press(&i->proc); + else indev_proc_release(&i->proc); + + if(indev_reset_check(&i->proc)) return; + i->proc.types.pointer.last_point.x = i->proc.types.pointer.act_point.x; i->proc.types.pointer.last_point.y = i->proc.types.pointer.act_point.y; } From a2535fe6f1a7f12bce9cbb19215ad0d4c3e48d9b Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 25 Nov 2020 09:56:20 +0100 Subject: [PATCH 03/15] fix(arc): make arc work with encoder fixes https://forum.lvgl.io/t/lv-arc-with-encoder-lv-group/3769 --- CHANGELOG.md | 1 + src/lv_widgets/lv_arc.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe575f96e..84b62abba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - fix(dropdown) support Arabic letter connections - fix(value_str) support Arabic letter connections in value string property - fix(indev) in LV_INDEV_TYPE_BUTTON recognize 1 cycle long presses too +- fix(arc) make arc work with encoder ## v7.7.2 (17.11.2020) ### Bugfixes diff --git a/src/lv_widgets/lv_arc.c b/src/lv_widgets/lv_arc.c index 5e27a29fa..4b2105bab 100644 --- a/src/lv_widgets/lv_arc.c +++ b/src/lv_widgets/lv_arc.c @@ -860,8 +860,12 @@ static lv_res_t lv_arc_signal(lv_obj_t * arc, lv_signal_t sign, void * param) res = lv_event_send(arc, LV_EVENT_VALUE_CHANGED, NULL); if(res != LV_RES_OK) return res; } - } - else if(sign == LV_SIGNAL_CLEANUP) { + }else if(sign == LV_SIGNAL_GET_EDITABLE) { +#if LV_USE_GROUP + bool * editable = (bool *)param; + *editable = true; +#endif + }else if(sign == LV_SIGNAL_CLEANUP) { lv_obj_clean_style_list(arc, LV_ARC_PART_KNOB); lv_obj_clean_style_list(arc, LV_ARC_PART_INDIC); } From 82fdfb34c0e2c1a4f970eaf506661a60e55f9347 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 25 Nov 2020 10:12:58 +0100 Subject: [PATCH 04/15] fix(slider): adjusting the left knob too with encoder https://forum.lvgl.io/t/slider-with-2-knobs-and-encoder-functionality/3770 --- CHANGELOG.md | 1 + src/lv_widgets/lv_bar.c | 13 ++++++++----- src/lv_widgets/lv_slider.c | 20 +++++++++++++++++--- src/lv_widgets/lv_slider.h | 1 + 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84b62abba..8c32b323d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - fix(value_str) support Arabic letter connections in value string property - fix(indev) in LV_INDEV_TYPE_BUTTON recognize 1 cycle long presses too - fix(arc) make arc work with encoder +- fix(slider) adjusting the left knob too with encoder ## v7.7.2 (17.11.2020) ### Bugfixes diff --git a/src/lv_widgets/lv_bar.c b/src/lv_widgets/lv_bar.c index efd53af91..37112fdce 100644 --- a/src/lv_widgets/lv_bar.c +++ b/src/lv_widgets/lv_bar.c @@ -157,9 +157,11 @@ void lv_bar_set_value(lv_obj_t * bar, int16_t value, lv_anim_enable_t anim) lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar); if(ext->cur_value == value) return; - int16_t new_value; - new_value = value > ext->max_value ? ext->max_value : value; + int16_t new_value = value; + new_value = value > ext->max_value ? ext->max_value : new_value; new_value = new_value < ext->min_value ? ext->min_value : new_value; + new_value = new_value < ext->start_value ? ext->start_value : new_value; + if(ext->cur_value == new_value) return; #if LV_USE_ANIMATION == 0 @@ -184,9 +186,10 @@ void lv_bar_set_start_value(lv_obj_t * bar, int16_t start_value, lv_anim_enable_ lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar); if(ext->start_value == start_value) return; - int16_t new_value; - new_value = start_value > ext->max_value ? ext->max_value : start_value; - new_value = new_value < ext->min_value ? ext->min_value : start_value; + int16_t new_value = start_value; + new_value = new_value > ext->max_value ? ext->max_value : new_value; + new_value = new_value < ext->min_value ? ext->min_value : new_value; + new_value = new_value > ext->cur_value ? ext->cur_value : new_value; if(ext->start_value == new_value) return; #if LV_USE_ANIMATION == 0 diff --git a/src/lv_widgets/lv_slider.c b/src/lv_widgets/lv_slider.c index 7cc949244..5447d5111 100644 --- a/src/lv_widgets/lv_slider.c +++ b/src/lv_widgets/lv_slider.c @@ -81,6 +81,7 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, const lv_obj_t * copy) /*Initialize the allocated 'ext' */ ext->value_to_set = NULL; ext->dragging = 0; + ext->right_knob_focus = 0; lv_style_list_init(&ext->style_knob); /*The signal and design functions are not copied so set them here*/ @@ -390,11 +391,20 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par bool editing = lv_group_get_editing(g); lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act()); if(indev_type == LV_INDEV_TYPE_ENCODER) { - if(editing) lv_group_set_editing(g, false); + if(editing) { + if(ext->right_knob_focus == 0) ext->right_knob_focus = 1; + else { + ext->right_knob_focus = 0; + lv_group_set_editing(g, false); + } + } } #endif } + else if(sign == LV_SIGNAL_FOCUS) { + ext->right_knob_focus = 0; + } else if(sign == LV_SIGNAL_COORD_CHG) { /* The knob size depends on slider size. * During the drawing method the ext. size is used by the knob so refresh the ext. size.*/ @@ -425,12 +435,16 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par char c = *((char *)param); if(c == LV_KEY_RIGHT || c == LV_KEY_UP) { - lv_slider_set_value(slider, lv_slider_get_value(slider) + 1, LV_ANIM_ON); + if(ext->right_knob_focus) lv_slider_set_value(slider, lv_slider_get_value(slider) + 1, LV_ANIM_ON); + else lv_slider_set_left_value(slider, lv_slider_get_left_value(slider) + 1, LV_ANIM_ON); + res = lv_event_send(slider, LV_EVENT_VALUE_CHANGED, NULL); if(res != LV_RES_OK) return res; } else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) { - lv_slider_set_value(slider, lv_slider_get_value(slider) - 1, LV_ANIM_ON); + if(ext->right_knob_focus) lv_slider_set_value(slider, lv_slider_get_value(slider) - 1, LV_ANIM_ON); + else lv_slider_set_left_value(slider, lv_slider_get_left_value(slider) - 1, LV_ANIM_ON); + res = lv_event_send(slider, LV_EVENT_VALUE_CHANGED, NULL); if(res != LV_RES_OK) return res; } diff --git a/src/lv_widgets/lv_slider.h b/src/lv_widgets/lv_slider.h index 9012bb4a5..44827409d 100644 --- a/src/lv_widgets/lv_slider.h +++ b/src/lv_widgets/lv_slider.h @@ -49,6 +49,7 @@ typedef struct { lv_area_t right_knob_area; int16_t * value_to_set; /* Which bar value to set */ uint8_t dragging : 1; /*1: the slider is being dragged*/ + uint8_t right_knob_focus :1; /*1: with encoder now the right knob can be adjusted*/ } lv_slider_ext_t; /** Built-in styles of slider*/ From 9d0335f38cbda1a3023b4041dadbc60b4a72f4a0 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 25 Nov 2020 11:35:12 +0100 Subject: [PATCH 05/15] fix(arc_draw): remove statments that do nothing fix #1930 --- src/lv_draw/lv_draw_arc.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/lv_draw/lv_draw_arc.c b/src/lv_draw/lv_draw_arc.c index bcf94d000..67d8ea55d 100644 --- a/src/lv_draw/lv_draw_arc.c +++ b/src/lv_draw/lv_draw_arc.c @@ -394,20 +394,11 @@ static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t tickness, int32_t thick_half = tickness / 2; uint8_t thick_corr = (tickness & 0x01) ? 0 : 1; - int32_t rx_corr; - int32_t ry_corr; - - if(angle > 90 && angle < 270) rx_corr = 0; - else rx_corr = 0; - - if(angle > 0 && angle < 180) ry_corr = 0; - else ry_corr = 0; - int32_t cir_x; int32_t cir_y; - cir_x = ((radius - rx_corr - thick_half) * _lv_trigo_sin(90 - angle)) >> (LV_TRIGO_SHIFT - ps); - cir_y = ((radius - ry_corr - thick_half) * _lv_trigo_sin(angle)) >> (LV_TRIGO_SHIFT - ps); + cir_x = ((radius - thick_half) * _lv_trigo_sin(90 - angle)) >> (LV_TRIGO_SHIFT - ps); + cir_y = ((radius - thick_half) * _lv_trigo_sin(angle)) >> (LV_TRIGO_SHIFT - ps); /* Actually the center of the pixel need to be calculated so apply 1/2 px offset*/ if(cir_x > 0) { From d6dd6199f31e515a8cf93626bdb12abc5d2263c3 Mon Sep 17 00:00:00 2001 From: incity <610455681@qq.com> Date: Thu, 26 Nov 2020 01:21:22 +0800 Subject: [PATCH 06/15] Change LV_DRAW_BUF_MAX_NUM to LV_MEM_BUF_MAX_NUM (#1931) --- src/lv_misc/lv_mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_misc/lv_mem.c b/src/lv_misc/lv_mem.c index 7fa3146f8..a2cfd3489 100644 --- a/src/lv_misc/lv_mem.c +++ b/src/lv_misc/lv_mem.c @@ -536,7 +536,7 @@ void * _lv_mem_buf_get(uint32_t size) } } - LV_DEBUG_ASSERT(false, "No free buffer. Increase LV_DRAW_BUF_MAX_NUM.", 0x00); + LV_DEBUG_ASSERT(false, "No free buffer. Increase LV_MEM_BUF_MAX_NUM.", 0x00); return NULL; } From 8cd738eaa18125c496881197f34097c453c99ff4 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Wed, 25 Nov 2020 12:22:11 -0500 Subject: [PATCH 07/15] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c32b323d..5ee7738ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - fix(indev) in LV_INDEV_TYPE_BUTTON recognize 1 cycle long presses too - fix(arc) make arc work with encoder - fix(slider) adjusting the left knob too with encoder +- fix reference to LV_DRAW_BUF_MAX_NUM in lv_mem.c ## v7.7.2 (17.11.2020) ### Bugfixes From 819f01c930b6f272edf298f74ce3b9bc00090ee4 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 26 Nov 2020 11:21:29 +0100 Subject: [PATCH 08/15] fix(draw polygon): join adjacent points if they are on the same coordinate --- CHANGELOG.md | 1 + src/lv_draw/lv_draw_triangle.c | 72 ++++++++++++++++++++++------------ 2 files changed, 48 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ee7738ef..219a26df2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - fix(arc) make arc work with encoder - fix(slider) adjusting the left knob too with encoder - fix reference to LV_DRAW_BUF_MAX_NUM in lv_mem.c +- fix(polygon draw) join adjacent points if they are on the same coordinate ## v7.7.2 (17.11.2020) ### Bugfixes diff --git a/src/lv_draw/lv_draw_triangle.c b/src/lv_draw/lv_draw_triangle.c index 8ffa343e1..1cb14c742 100644 --- a/src/lv_draw/lv_draw_triangle.c +++ b/src/lv_draw/lv_draw_triangle.c @@ -58,29 +58,50 @@ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_are if(point_cnt < 3) return; if(points == NULL) return; - int16_t i; + /*Join adjacent points if they are on the same coordinate*/ + lv_point_t * p = _lv_mem_buf_get(point_cnt * sizeof(lv_point_t)); + if(p == NULL) return; + uint32_t i; + uint32_t pcnt = 0; + p[0] = points[0]; + for(i = 0; i < point_cnt - 1; i++) { + if(points[i].x != points[i+1].x && points[i].y != points[i+1].y) { + p[pcnt] = points[i]; + pcnt++; + } + } + /*The first and the last points are also adjacent */ + if(points[0].x != points[point_cnt - 1].x && points[0].y != points[point_cnt - 1].y) { + p[pcnt] = points[point_cnt - 1]; + pcnt++; + } + + point_cnt = pcnt; + if(point_cnt < 3) return; + lv_area_t poly_coords = {.x1 = LV_COORD_MAX, .y1 = LV_COORD_MAX, .x2 = LV_COORD_MIN, .y2 = LV_COORD_MIN}; for(i = 0; i < point_cnt; i++) { - poly_coords.x1 = LV_MATH_MIN(poly_coords.x1, points[i].x); - poly_coords.y1 = LV_MATH_MIN(poly_coords.y1, points[i].y); - poly_coords.x2 = LV_MATH_MAX(poly_coords.x2, points[i].x); - poly_coords.y2 = LV_MATH_MAX(poly_coords.y2, points[i].y); + poly_coords.x1 = LV_MATH_MIN(poly_coords.x1, p[i].x); + poly_coords.y1 = LV_MATH_MIN(poly_coords.y1, p[i].y); + poly_coords.x2 = LV_MATH_MAX(poly_coords.x2, p[i].x); + poly_coords.y2 = LV_MATH_MAX(poly_coords.y2, p[i].y); } - bool is_common; lv_area_t poly_mask; is_common = _lv_area_intersect(&poly_mask, &poly_coords, clip_area); - if(!is_common) return; - + if(!is_common) { + _lv_mem_buf_release(p); + return; + } /*Find the lowest point*/ - lv_coord_t y_min = points[0].y; + lv_coord_t y_min = p[0].y; int16_t y_min_i = 0; for(i = 1; i < point_cnt; i++) { - if(points[i].y < y_min) { - y_min = points[i].y; + if(p[i].y < y_min) { + y_min = p[i].y; y_min_i = i; } } @@ -109,10 +130,10 @@ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_are * dy_left/dx_left < dy_right/dx_right * dy_left * dx_right < dy_right * dx_left */ - lv_coord_t dxl = points[i_next_left].x - points[y_min_i].x; - lv_coord_t dxr = points[i_next_right].x - points[y_min_i].x; - lv_coord_t dyl = points[i_next_left].y - points[y_min_i].y; - lv_coord_t dyr = points[i_next_right].y - points[y_min_i].y; + lv_coord_t dxl = p[i_next_left].x - p[y_min_i].x; + lv_coord_t dxr = p[i_next_right].x - p[y_min_i].x; + lv_coord_t dyl = p[i_next_left].y - p[y_min_i].y; + lv_coord_t dyr = p[i_next_right].y - p[y_min_i].y; bool inv = false; if(dyl * dxr < dyr * dxl) inv = true; @@ -133,11 +154,11 @@ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_are if(i_next_right < 0) i_next_right = point_cnt + i_next_right; } - if(points[i_next_left].y >= points[i_prev_left].y) { - if(points[i_next_left].y != points[i_prev_left].y && - points[i_next_left].x != points[i_prev_left].x) { - lv_draw_mask_line_points_init(mp_next, points[i_prev_left].x, points[i_prev_left].y, - points[i_next_left].x, points[i_next_left].y, + if(p[i_next_left].y >= p[i_prev_left].y) { + if(p[i_next_left].y != p[i_prev_left].y && + p[i_next_left].x != p[i_prev_left].x) { + lv_draw_mask_line_points_init(mp_next, p[i_prev_left].x, p[i_prev_left].y, + p[i_next_left].x, p[i_next_left].y, LV_DRAW_MASK_LINE_SIDE_RIGHT); lv_draw_mask_add(mp_next, mp); mp_next++; @@ -148,12 +169,12 @@ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_are if(mask_cnt == point_cnt) break; - if(points[i_next_right].y >= points[i_prev_right].y) { - if(points[i_next_right].y != points[i_prev_right].y && - points[i_next_right].x != points[i_prev_right].x) { + if(p[i_next_right].y >= p[i_prev_right].y) { + if(p[i_next_right].y != p[i_prev_right].y && + p[i_next_right].x != p[i_prev_right].x) { - lv_draw_mask_line_points_init(mp_next, points[i_prev_right].x, points[i_prev_right].y, - points[i_next_right].x, points[i_next_right].y, + lv_draw_mask_line_points_init(mp_next, p[i_prev_right].x, p[i_prev_right].y, + p[i_next_right].x, p[i_next_right].y, LV_DRAW_MASK_LINE_SIDE_LEFT); lv_draw_mask_add(mp_next, mp); mp_next++; @@ -169,6 +190,7 @@ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_are lv_draw_mask_remove_custom(mp); _lv_mem_buf_release(mp); + _lv_mem_buf_release(p); } From 89eca30da8e97c41f730629338775ba57bd6edd6 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 26 Nov 2020 15:13:36 +0100 Subject: [PATCH 09/15] fix(draw polygon): fix memory leak and vertex joining --- src/lv_draw/lv_draw_triangle.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/lv_draw/lv_draw_triangle.c b/src/lv_draw/lv_draw_triangle.c index 1cb14c742..162b8d28e 100644 --- a/src/lv_draw/lv_draw_triangle.c +++ b/src/lv_draw/lv_draw_triangle.c @@ -61,23 +61,26 @@ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_are /*Join adjacent points if they are on the same coordinate*/ lv_point_t * p = _lv_mem_buf_get(point_cnt * sizeof(lv_point_t)); if(p == NULL) return; - uint32_t i; - uint32_t pcnt = 0; + uint16_t i; + uint16_t pcnt = 0; p[0] = points[0]; for(i = 0; i < point_cnt - 1; i++) { - if(points[i].x != points[i+1].x && points[i].y != points[i+1].y) { + if(points[i].x != points[i+1].x ||points[i].y != points[i+1].y) { p[pcnt] = points[i]; pcnt++; } } /*The first and the last points are also adjacent */ - if(points[0].x != points[point_cnt - 1].x && points[0].y != points[point_cnt - 1].y) { + if(points[0].x != points[point_cnt - 1].x || points[0].y != points[point_cnt - 1].y) { p[pcnt] = points[point_cnt - 1]; pcnt++; } point_cnt = pcnt; - if(point_cnt < 3) return; + if(point_cnt < 3) { + _lv_mem_buf_release(p); + return; + } lv_area_t poly_coords = {.x1 = LV_COORD_MAX, .y1 = LV_COORD_MAX, .x2 = LV_COORD_MIN, .y2 = LV_COORD_MIN}; From 313f7f30a7bd90b32cde40ac2bf56b0cc392d74f Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 26 Nov 2020 15:22:09 +0100 Subject: [PATCH 10/15] fix(style): invalidate cache on every PART Inherited properties on parts other than MAIN needs to be recached on property change beacuse they are inherted from MAIN fixes #1933 --- src/lv_core/lv_obj.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 9739dc985..86b95cced 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -4759,25 +4759,19 @@ static void invalidate_style_cache(lv_obj_t * obj, uint8_t part, lv_style_proper { if(style_prop_is_cacheble(prop) == false) return; - if(part != LV_OBJ_PART_ALL) { + for(part = 0; part < _LV_OBJ_PART_REAL_FIRST; part++) { lv_style_list_t * list = lv_obj_get_style_list(obj, part); - if(list == NULL) return; + if(list == NULL) break; list->valid_cache = 0; } - else { - for(part = 0; part < _LV_OBJ_PART_REAL_FIRST; part++) { - lv_style_list_t * list = lv_obj_get_style_list(obj, part); - if(list == NULL) break; - list->valid_cache = 0; - } - for(part = _LV_OBJ_PART_REAL_FIRST; part < 0xFF; part++) { - lv_style_list_t * list = lv_obj_get_style_list(obj, part); - if(list == NULL) break; - list->valid_cache = 0; - } + for(part = _LV_OBJ_PART_REAL_FIRST; part < 0xFF; part++) { + lv_style_list_t * list = lv_obj_get_style_list(obj, part); + if(list == NULL) break; + list->valid_cache = 0; } + lv_obj_t * child = lv_obj_get_child(obj, NULL); while(child) { update_style_cache_children(child); From d6d5903be1880dbc1bc89c5e1e5bf616c6732b6a Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 26 Nov 2020 15:22:58 +0100 Subject: [PATCH 11/15] fix(anim): fix bounce path --- src/lv_misc/lv_anim.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/lv_misc/lv_anim.c b/src/lv_misc/lv_anim.c index e4a20b391..f813c9197 100644 --- a/src/lv_misc/lv_anim.c +++ b/src/lv_misc/lv_anim.c @@ -362,7 +362,7 @@ lv_anim_value_t lv_anim_path_bounce(const lv_anim_path_t * path, const lv_anim_t LV_UNUSED(path); /*Calculate the current step*/ - uint32_t t; + int32_t t; if(a->time == a->act_time) t = 1024; else @@ -381,31 +381,32 @@ lv_anim_value_t lv_anim_path_bounce(const lv_anim_path_t * path, const lv_anim_t t -= 408; t = t * 5; /*to [0..1024] range*/ t = 1024 - t; - diff = diff / 6; + diff = diff / 20; } else if(t >= 614 && t < 819) { /*Fall back*/ t -= 614; t = t * 5; /*to [0..1024] range*/ - diff = diff / 6; + diff = diff / 20; } else if(t >= 819 && t < 921) { /*Second bounce back*/ t -= 819; t = t * 10; /*to [0..1024] range*/ t = 1024 - t; - diff = diff / 16; + diff = diff / 40; } else if(t >= 921 && t <= 1024) { /*Fall back*/ t -= 921; t = t * 10; /*to [0..1024] range*/ - diff = diff / 16; + diff = diff / 40; } if(t > 1024) t = 1024; + if(t < 0) t = 0; - int32_t step = _lv_bezier3(t, 1024, 1024, 800, 0); + int32_t step = _lv_bezier3(t, 1024, 800, 500, 0); int32_t new_value; new_value = (int32_t)step * diff; From 5e8581a3459d20018afdcc3a80c32b61ed9818b2 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 26 Nov 2020 15:30:50 +0100 Subject: [PATCH 12/15] fix(slider): do not let edit left knob in non-range mode --- src/lv_widgets/lv_slider.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lv_widgets/lv_slider.c b/src/lv_widgets/lv_slider.c index 5447d5111..bae71c0f4 100644 --- a/src/lv_widgets/lv_slider.c +++ b/src/lv_widgets/lv_slider.c @@ -392,9 +392,13 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act()); if(indev_type == LV_INDEV_TYPE_ENCODER) { if(editing) { - if(ext->right_knob_focus == 0) ext->right_knob_focus = 1; - else { - ext->right_knob_focus = 0; + if(lv_slider_get_type(slider) == LV_SLIDER_TYPE_RANGE) { + if(ext->right_knob_focus == 0) ext->right_knob_focus = 1; + else { + ext->right_knob_focus = 0; + lv_group_set_editing(g, false); + } + } else { lv_group_set_editing(g, false); } } From 2f6eaa516cc512d5c16c2dabc3768b7bbebe80d1 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 26 Nov 2020 15:54:39 +0100 Subject: [PATCH 13/15] Update ROADMAP.md --- docs/ROADMAP.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 488a478d5..7b22b1e36 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -59,3 +59,4 @@ Planned to November/December 2020 - Need static analize (via coverity.io or somehing else) - Support dot_begin and dot_middle long modes for labels - Add new label alignment modes. [#1656](https://github.com/lvgl/lvgl/issues/1656) +- Support larger images: [#1892](https://github.com/lvgl/lvgl/issues/1892) From 48a676f40427bd8ca7bacab0fb96c401d4a9ef83 Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 27 Nov 2020 03:12:21 +0300 Subject: [PATCH 14/15] Fix hardfault when DCache is disabled with no callback (#1935) --- src/lv_gpu/lv_gpu_stm32_dma2d.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lv_gpu/lv_gpu_stm32_dma2d.c b/src/lv_gpu/lv_gpu_stm32_dma2d.c index ab02ed29c..74b0a7201 100644 --- a/src/lv_gpu/lv_gpu_stm32_dma2d.c +++ b/src/lv_gpu/lv_gpu_stm32_dma2d.c @@ -241,7 +241,8 @@ static void invalidate_cache(void) if(disp->driver.clean_dcache_cb) disp->driver.clean_dcache_cb(&disp->driver); else { #if __CORTEX_M >= 0x07 - SCB_CleanInvalidateDCache(); + if((SCB->CCR) & (uint32_t)SCB_CCR_DC_Msk) + SCB_CleanInvalidateDCache(); #endif } } From 4853eacfa43667459d09642be8949b44c530367c Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 27 Nov 2020 09:48:34 +0100 Subject: [PATCH 15/15] fix(linemeter): fix invalidation when setting new value The old complex but more optimal invalidation was buggy in some cases fixes #1904 --- CHANGELOG.md | 1 + src/lv_widgets/lv_linemeter.c | 80 ++--------------------------------- 2 files changed, 4 insertions(+), 77 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 219a26df2..9d6a977a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - fix(slider) adjusting the left knob too with encoder - fix reference to LV_DRAW_BUF_MAX_NUM in lv_mem.c - fix(polygon draw) join adjacent points if they are on the same coordinate +- fix(linemeter) fix invalidation when setting new value ## v7.7.2 (17.11.2020) ### Bugfixes diff --git a/src/lv_widgets/lv_linemeter.c b/src/lv_widgets/lv_linemeter.c index b85610ed0..234fa33c0 100644 --- a/src/lv_widgets/lv_linemeter.c +++ b/src/lv_widgets/lv_linemeter.c @@ -131,83 +131,9 @@ void lv_linemeter_set_value(lv_obj_t * lmeter, int32_t value) int16_t level_new = (int32_t)((int32_t)(ext->cur_value - ext->min_value) * (ext->line_cnt - 1)) / (ext->max_value - ext->min_value); - if(level_new == level_old) { - return; - } - - lv_style_int_t left = lv_obj_get_style_pad_left(lmeter, LV_LINEMETER_PART_MAIN); - lv_style_int_t right = lv_obj_get_style_pad_right(lmeter, LV_LINEMETER_PART_MAIN); - lv_style_int_t top = lv_obj_get_style_pad_top(lmeter, LV_LINEMETER_PART_MAIN); - lv_style_int_t bottom = lv_obj_get_style_pad_bottom(lmeter, LV_LINEMETER_PART_MAIN); - - lv_coord_t r_out = (lv_obj_get_width(lmeter) - left - right) / 2 ; - lv_coord_t r_in = r_out - lv_obj_get_style_scale_width(lmeter, LV_LINEMETER_PART_MAIN); - if(r_in < 1) r_in = 1; - - lv_coord_t x_ofs = lmeter->coords.x1 + r_out + left; - lv_coord_t y_ofs = lmeter->coords.y1 + r_out + top; - int16_t angle_ofs = ext->angle_ofs + 90 + (360 - ext->scale_angle) / 2; - - lv_style_int_t line_width = lv_obj_get_style_scale_end_line_width(lmeter, LV_LINEMETER_PART_MAIN); - lv_style_int_t end_line_width = lv_obj_get_style_scale_end_line_width(lmeter, LV_LINEMETER_PART_MAIN); - line_width = LV_MATH_MAX(line_width, end_line_width); - - int32_t angle_old = (level_old * ext->scale_angle) / (ext->line_cnt - 1); - - /*Use smaller clip area only around the visible line*/ - int32_t y_in_old = (int32_t)((int32_t)_lv_trigo_sin(angle_old + angle_ofs) * r_in) >> LV_TRIGO_SHIFT; - int32_t x_in_old = (int32_t)((int32_t)_lv_trigo_sin(angle_old + 90 + angle_ofs) * r_in) >> LV_TRIGO_SHIFT; - - - int32_t y_out_old = (int32_t)((int32_t)_lv_trigo_sin(angle_old + angle_ofs) * r_out) >> LV_TRIGO_SHIFT; - int32_t x_out_old = (int32_t)((int32_t)_lv_trigo_sin(angle_old + 90 + angle_ofs) * r_out) >> LV_TRIGO_SHIFT; - - - - int32_t angle_new = (level_new * ext->scale_angle) / (ext->line_cnt - 1); - - /*Use smaller clip area only around the visible line*/ - int32_t y_in_new = (int32_t)((int32_t)_lv_trigo_sin(angle_new + angle_ofs) * r_in) >> LV_TRIGO_SHIFT; - int32_t x_in_new = (int32_t)((int32_t)_lv_trigo_sin(angle_new + 90 + angle_ofs) * r_in) >> LV_TRIGO_SHIFT; - - - int32_t y_out_new = (int32_t)((int32_t)_lv_trigo_sin(angle_new + angle_ofs) * r_out) >> LV_TRIGO_SHIFT; - int32_t x_out_new = (int32_t)((int32_t)_lv_trigo_sin(angle_new + 90 + angle_ofs) * r_out) >> LV_TRIGO_SHIFT; - - lv_area_t a; - if(x_out_old < 0 && x_out_new < 0) { - a.x1 = lmeter->coords.x1 + left - line_width; - a.y1 = LV_MATH_MIN4(y_out_old, y_out_new, y_in_old, y_in_new) + y_ofs - line_width; - a.x2 = LV_MATH_MAX(x_in_old, x_in_new) + x_ofs + line_width; - a.y2 = LV_MATH_MAX4(y_out_old, y_out_new, y_in_old, y_in_new) + y_ofs + line_width; - } - else if(x_out_old > 0 && x_out_new > 0) { - a.x1 = LV_MATH_MIN(x_in_old, x_in_new) + x_ofs - line_width; - a.y1 = LV_MATH_MIN4(y_out_old, y_out_new, y_in_old, y_in_new) + y_ofs - line_width; - a.x2 = lmeter->coords.x2 - right + line_width; - a.y2 = LV_MATH_MAX4(y_out_old, y_out_new, y_in_old, y_in_new) + y_ofs + line_width; - } - else if(y_out_old < 0 && y_out_new < 0) { - a.x1 = LV_MATH_MIN4(x_out_old, x_out_new, x_in_old, x_in_new) + x_ofs - line_width; - a.y1 = lmeter->coords.y1 + top - line_width; - a.x2 = LV_MATH_MAX4(x_out_old, x_out_new, x_in_old, x_in_new) + x_ofs + line_width; - a.y2 = LV_MATH_MAX(y_in_old, y_in_new) + y_ofs + line_width; - } - else if(y_out_old > 0 && y_out_new > 0) { - a.x1 = LV_MATH_MIN4(x_out_old, x_out_new, x_in_old, x_in_new) + x_ofs - line_width; - a.y1 = LV_MATH_MIN(y_in_old, y_in_new) + y_ofs - line_width; - a.x2 = LV_MATH_MAX4(x_out_old, x_out_new, x_in_old, x_in_new) + x_ofs + line_width; - a.y2 = lmeter->coords.y2 - bottom + line_width; - } - else { - a.x1 = lmeter->coords.x1 + left - line_width; - a.y1 = lmeter->coords.y1 + top - line_width; - a.x2 = lmeter->coords.x2 - right + line_width; - a.y2 = lmeter->coords.y2 - bottom + line_width; - } - - lv_obj_invalidate_area(lmeter, &a); + if(level_new == level_old) return; + lv_obj_invalidate(lmeter); } /** @@ -521,7 +447,7 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin p1.y = y_out_extra; /* Set the color of the lines */ - if((!ext->mirrored && i >= level) || (ext->mirrored && i <= level)) { + if((!ext->mirrored && i > level) || (ext->mirrored && i < level)) { line_dsc.color = end_color; line_dsc.width = end_line_width; }