From ba5ee315e9bf56284fddb8de46cc2fc1a8f4d106 Mon Sep 17 00:00:00 2001 From: Amir Gonnen Date: Fri, 4 Dec 2020 01:42:42 +0200 Subject: [PATCH 01/31] lv_txt.h: Add missing include (#1949) --- src/lv_misc/lv_txt.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lv_misc/lv_txt.h b/src/lv_misc/lv_txt.h index a5e78d9da..3f1f858e9 100644 --- a/src/lv_misc/lv_txt.h +++ b/src/lv_misc/lv_txt.h @@ -16,6 +16,7 @@ extern "C" { #include "../lv_conf_internal.h" #include +#include #include "lv_area.h" #include "lv_area.h" #include "../lv_font/lv_font.h" From b9aff011022853b13018cbe63072f44ac3367785 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Sat, 5 Dec 2020 19:47:50 -0500 Subject: [PATCH 02/31] Correct preprocessor syntax (#1951) --- src/lv_gpu/lv_gpu_nxp_pxp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_gpu/lv_gpu_nxp_pxp.c b/src/lv_gpu/lv_gpu_nxp_pxp.c index d8ea7532a..ccb720297 100644 --- a/src/lv_gpu/lv_gpu_nxp_pxp.c +++ b/src/lv_gpu/lv_gpu_nxp_pxp.c @@ -56,7 +56,7 @@ #define PXP_OUT_PIXEL_FORMAT kPXP_OutputPixelFormatRGB565 #define PXP_AS_PIXEL_FORMAT kPXP_AsPixelFormatRGB565 #define PXP_PS_PIXEL_FORMAT kPXP_PsPixelFormatRGB565 -#elif +#else #error Only 16bit color depth is supported. Set LV_COLOR_DEPTH to 16. #endif From b80f1dbf14cdd73976486de7f7706a0bda8d788a Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 7 Dec 2020 18:04:40 +0100 Subject: [PATCH 03/31] fix(lv_scr_load_anim): fix when multiple screen are loaded at tsame time with delay --- CHANGELOG.md | 7 ++++++- src/lv_core/lv_disp.c | 16 +++++++++++++++- src/lv_hal/lv_hal_disp.h | 7 +++++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6294f639a..6bc5582bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog -## v7.8.0 (Planned to 01.12.2020) +## v7.8.1 (Plannad at 15.12.2020) + +### Bugfixes +- fix(lv_scr_load_anim) fix when multiple screen are loaded at tsame time with delay + +## v7.8.0 (01.12.2020) ### New features - make DMA2D non blocking diff --git a/src/lv_core/lv_disp.c b/src/lv_core/lv_disp.c index 440232b64..251f28c34 100644 --- a/src/lv_core/lv_disp.c +++ b/src/lv_core/lv_disp.c @@ -214,6 +214,20 @@ void lv_disp_set_bg_opa(lv_disp_t * disp, lv_opa_t opa) void lv_scr_load_anim(lv_obj_t * new_scr, lv_scr_load_anim_t anim_type, uint32_t time, uint32_t delay, bool auto_del) { lv_disp_t * d = lv_obj_get_disp(new_scr); + lv_obj_t * act_scr = lv_scr_act(); + + + if(d->del_prev && act_scr != d->scr_to_load) { + lv_obj_del(act_scr); + lv_disp_load_scr(d->scr_to_load); + lv_anim_del(d->scr_to_load, NULL); + lv_obj_set_pos(d->scr_to_load, 0, 0); + lv_style_remove_prop(lv_obj_get_local_style(d->scr_to_load, LV_OBJ_PART_MAIN), LV_STYLE_OPA_SCALE); + + act_scr = d->scr_to_load; + } + + d->scr_to_load = new_scr; if(d->prev_scr && d->del_prev) { lv_obj_del(d->prev_scr); @@ -396,13 +410,13 @@ static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v) lv_obj_set_style_local_opa_scale(obj, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, v); } - static void scr_anim_ready(lv_anim_t * a) { lv_disp_t * d = lv_obj_get_disp(a->var); if(d->prev_scr && d->del_prev) lv_obj_del(d->prev_scr); d->prev_scr = NULL; + d->scr_to_load = NULL; lv_style_remove_prop(lv_obj_get_local_style(a->var, LV_OBJ_PART_MAIN), LV_STYLE_OPA_SCALE); } #endif diff --git a/src/lv_hal/lv_hal_disp.h b/src/lv_hal/lv_hal_disp.h index 7a1eef6b0..87b020843 100644 --- a/src/lv_hal/lv_hal_disp.h +++ b/src/lv_hal/lv_hal_disp.h @@ -153,8 +153,11 @@ typedef struct _disp_t { /** Screens of the display*/ lv_ll_t scr_ll; - struct _lv_obj_t * act_scr; /**< Currently active screen on this display */ - struct _lv_obj_t * prev_scr; /**< Previous screen. Used during screen animations */ + struct _lv_obj_t * act_scr; /**< Currently active screen on this display */ + struct _lv_obj_t * prev_scr; /**< Previous screen. Used during screen animations */ +#if LV_USE_ANIMATION + struct _lv_obj_t * scr_to_load; /**< The screen prepared to load in lv_scr_load_anim*/ +#endif struct _lv_obj_t * top_layer; /**< @see lv_disp_get_layer_top */ struct _lv_obj_t * sys_layer; /**< @see lv_disp_get_layer_sys */ From 03d2d10f17c6cb981c8acc66497e4bc10ccc494c Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Tue, 8 Dec 2020 07:45:52 -0500 Subject: [PATCH 04/31] Fix #1955: wrong display size macro being used --- src/lv_themes/lv_theme_material.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lv_themes/lv_theme_material.c b/src/lv_themes/lv_theme_material.c index 9da688732..43c3d4927 100644 --- a/src/lv_themes/lv_theme_material.c +++ b/src/lv_themes/lv_theme_material.c @@ -316,10 +316,10 @@ static void basic_init(void) style_init_reset(&styles->pad_inner); lv_style_set_pad_inner(&styles->pad_inner, LV_STATE_DEFAULT, - lv_disp_get_size_category(NULL) <= LV_DISP_MEDIUM_LIMIT ? LV_DPX(20) : LV_DPX(40)); + lv_disp_get_size_category(NULL) <= LV_DISP_SIZE_MEDIUM ? LV_DPX(20) : LV_DPX(40)); style_init_reset(&styles->pad_small); - lv_style_int_t pad_small_value = lv_disp_get_size_category(NULL) <= LV_DISP_MEDIUM_LIMIT ? LV_DPX(10) : LV_DPX(20); + lv_style_int_t pad_small_value = lv_disp_get_size_category(NULL) <= LV_DISP_SIZE_MEDIUM ? LV_DPX(10) : LV_DPX(20); lv_style_set_pad_left(&styles->pad_small, LV_STATE_DEFAULT, pad_small_value); lv_style_set_pad_right(&styles->pad_small, LV_STATE_DEFAULT, pad_small_value); lv_style_set_pad_top(&styles->pad_small, LV_STATE_DEFAULT, pad_small_value); From 99bb4cb8f109d3dfe5b43c2f48dea52672ed4c1f Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 9 Dec 2020 14:02:28 +0100 Subject: [PATCH 05/31] fix(page): fix LV_SCOLLBAR_MODE_DRAG fixes https://forum.lvgl.io/t/page-scrollbar-appears-even-if-scrollbar-mode-is-set-to-lv-scrlbar-mode-drag/3883 --- CHANGELOG.md | 1 + src/lv_widgets/lv_page.c | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bc5582bf..0dc6dae23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Bugfixes - fix(lv_scr_load_anim) fix when multiple screen are loaded at tsame time with delay +- fix(page) fix LV_SCOLLBAR_MODE_DRAG ## v7.8.0 (01.12.2020) diff --git a/src/lv_widgets/lv_page.c b/src/lv_widgets/lv_page.c index 2400dccd3..936537c0a 100644 --- a/src/lv_widgets/lv_page.c +++ b/src/lv_widgets/lv_page.c @@ -1250,8 +1250,22 @@ static void scrlbar_refresh(lv_obj_t * page) (scrl_w + bg_left + bg_right - obj_w), obj_h - sb_width - sb_bottom); - if(ext->scrlbar.mode == LV_SCROLLBAR_MODE_AUTO || - ext->scrlbar.mode == LV_SCROLLBAR_MODE_DRAG) ext->scrlbar.hor_draw = 1; + if(ext->scrlbar.mode == LV_SCROLLBAR_MODE_AUTO) ext->scrlbar.hor_draw = 1; + else if(ext->scrlbar.mode == LV_SCROLLBAR_MODE_DRAG) { + lv_indev_t * indev = lv_indev_get_next(NULL); + while(indev) { + if(indev->driver.type == LV_INDEV_TYPE_POINTER && (indev->proc.types.pointer.drag_dir & LV_DRAG_DIR_HOR)) { + lv_obj_t * drag_obj = indev->proc.types.pointer.act_obj; + while(drag_obj && drag_obj->drag_parent) drag_obj = lv_obj_get_parent(drag_obj); + + if(drag_obj && drag_obj == scrl) { + ext->scrlbar.hor_draw = 1; + break; + } + } + indev = lv_indev_get_next(indev); + } + } } /*Full sized vertical scroll bar*/ @@ -1275,8 +1289,22 @@ static void scrlbar_refresh(lv_obj_t * page) (obj_h - size_tmp - 2 * sb_ver_pad)) / (scrl_h + bg_top + bg_bottom - obj_h)); - if(ext->scrlbar.mode == LV_SCROLLBAR_MODE_AUTO || - ext->scrlbar.mode == LV_SCROLLBAR_MODE_DRAG) ext->scrlbar.ver_draw = 1; + if(ext->scrlbar.mode == LV_SCROLLBAR_MODE_AUTO) ext->scrlbar.ver_draw = 1; + else if(ext->scrlbar.mode == LV_SCROLLBAR_MODE_DRAG) { + lv_indev_t * indev = lv_indev_get_next(NULL); + while(indev) { + if(indev->driver.type == LV_INDEV_TYPE_POINTER && (indev->proc.types.pointer.drag_dir & LV_DRAG_DIR_VER)) { + lv_obj_t * drag_obj = indev->proc.types.pointer.act_obj; + while(drag_obj && drag_obj->drag_parent) drag_obj = lv_obj_get_parent(drag_obj); + + if(drag_obj && drag_obj == scrl) { + ext->scrlbar.ver_draw = 1; + break; + } + } + indev = lv_indev_get_next(indev); + } + } } /*Invalidate the new scrollbar areas*/ From 6d4de787564eb9b1a3083b3f7520360535f36514 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 9 Dec 2020 14:11:14 +0100 Subject: [PATCH 06/31] set version number --- CHANGELOG.md | 6 ++++++ lvgl.h | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0dc6dae23..28e5b5ce7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## v7.9.0 + +### New features + +### Bugfixes + ## v7.8.1 (Plannad at 15.12.2020) ### Bugfixes diff --git a/lvgl.h b/lvgl.h index 2583fc422..8aa6b1bc7 100644 --- a/lvgl.h +++ b/lvgl.h @@ -15,8 +15,8 @@ extern "C" { * CURRENT VERSION OF LVGL ***************************/ #define LVGL_VERSION_MAJOR 7 -#define LVGL_VERSION_MINOR 8 -#define LVGL_VERSION_PATCH 1 +#define LVGL_VERSION_MINOR 9 +#define LVGL_VERSION_PATCH 0 #define LVGL_VERSION_INFO "dev" /********************* From 861f07bb77ee20d6002a0299a0d069e5d62150cf Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 9 Dec 2020 14:15:56 +0100 Subject: [PATCH 07/31] feat(chart): add lv_chart_remove_series and lv_chart_hide_series --- CHANGELOG.md | 1 + src/lv_widgets/lv_chart.c | 47 +++++++++++++++++++++++++++++++++++++++ src/lv_widgets/lv_chart.h | 17 ++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28e5b5ce7..0464f3306 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## v7.9.0 ### New features +- feat(chart) add lv_chart_remove_series and lv_chart_hide_series ### Bugfixes diff --git a/src/lv_widgets/lv_chart.c b/src/lv_widgets/lv_chart.c index 481f15b93..ceff11af2 100644 --- a/src/lv_widgets/lv_chart.c +++ b/src/lv_widgets/lv_chart.c @@ -195,6 +195,7 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color) ser->start_point = 0; ser->ext_buf_assigned = false; + ser->hidden = 0; ser->y_axis = LV_CHART_AXIS_PRIMARY_Y; uint16_t i; @@ -207,6 +208,33 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color) return ser; } +/** + * Deallocate and remove a data series from a chart + * @param chart pointer to a chart object + * @param series pointer to a data series on 'chart' + */ +void lv_chart_remove_series(lv_obj_t * chart, lv_chart_series_t * series) +{ + LV_ASSERT_OBJ(chart, LV_OBJX_NAME); + LV_ASSERT_NULL(series); + + if(chart == NULL || series == NULL) return; + lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); + if(!series->ext_buf_assigned && series->points) lv_mem_free(series->points); + + _lv_ll_remove(&ext->series_ll, series); + lv_mem_free(series); + + return; +} + +/** + * Add a cursor with a given color + * @param chart pointer to chart object + * @param color color of the cursor + * @param dir direction of the cursor. `LV_CHART_CURSOR_RIGHT/LEFT/TOP/DOWN`. OR-ed values are possible + * @return pointer to the created cursor + */ lv_chart_cursor_t * lv_chart_add_cursor(lv_obj_t * chart, lv_color_t color, lv_cursor_direction_t axes) { LV_ASSERT_OBJ(chart, LV_OBJX_NAME); @@ -246,6 +274,22 @@ void lv_chart_clear_series(lv_obj_t * chart, lv_chart_series_t * series) series->start_point = 0; } +/** + * Hide/Unhide a single series of a chart. + * @param chart pointer to a chart object. + * @param series pointer to a series object + * @param hide true: hide the series + */ +void lv_chart_hide_series(lv_obj_t * chart, lv_chart_series_t * series, bool hide) +{ + LV_ASSERT_OBJ(chart, LV_OBJX_NAME); + LV_ASSERT_NULL(series); + + series->hidden = hide ? 1 : 0; + lv_chart_refresh(chart); +} + + /*===================== * Setter functions *====================*/ @@ -666,6 +710,7 @@ void lv_chart_set_cursor_point(lv_obj_t * chart, lv_chart_cursor_t * cursor, lv_ lv_chart_refresh(chart); } + /*===================== * Getter functions *====================*/ @@ -1135,6 +1180,7 @@ static void draw_series_line(lv_obj_t * chart, const lv_area_t * series_area, co /*Go through all data lines*/ _LV_LL_READ_BACK(ext->series_ll, ser) { + if (ser->hidden) continue; line_dsc.color = ser->color; point_dsc.bg_color = ser->color; area_dsc.bg_color = ser->color; @@ -1271,6 +1317,7 @@ static void draw_series_column(lv_obj_t * chart, const lv_area_t * series_area, /*Draw the current point of all data line*/ _LV_LL_READ_BACK(ext->series_ll, ser) { + if (ser->hidden) continue; lv_coord_t start_point = ext->update_mode == LV_CHART_UPDATE_MODE_SHIFT ? ser->start_point : 0; col_a.x1 = x_act; diff --git a/src/lv_widgets/lv_chart.h b/src/lv_widgets/lv_chart.h index 2bd9fc069..0234b411d 100644 --- a/src/lv_widgets/lv_chart.h +++ b/src/lv_widgets/lv_chart.h @@ -74,6 +74,7 @@ typedef struct { lv_color_t color; uint16_t start_point; uint8_t ext_buf_assigned : 1; + uint8_t hidden : 1; lv_chart_axis_t y_axis : 1; } lv_chart_series_t; @@ -153,6 +154,13 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy); */ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color); +/** + * Deallocate and remove a data series from a chart + * @param chart pointer to a chart object + * @param series pointer to a data series on 'chart' + */ +void lv_chart_remove_series(lv_obj_t * chart, lv_chart_series_t * series); + /** * Add a cursor with a given color * @param chart pointer to chart object @@ -169,6 +177,15 @@ lv_chart_cursor_t * lv_chart_add_cursor(lv_obj_t * chart, lv_color_t color, lv_c */ void lv_chart_clear_series(lv_obj_t * chart, lv_chart_series_t * series); +/** + * Hide/Unhide a single series of a chart. + * @param chart pointer to a chart object. + * @param series pointer to a series object + * @param hide true: hide the series + */ +void lv_chart_hide_series(lv_obj_t * chart, lv_chart_series_t * series, bool hide); + + /*===================== * Setter functions *====================*/ From b565a69c76e9b133d0365d2cc6f96d82a87b599d Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Wed, 9 Dec 2020 13:07:21 -0500 Subject: [PATCH 08/31] fix(dropdown): always invalidate if selected option changes Reported on the forum: https://forum.lvgl.io/t/dropdown-selected-value-doesnt-change-after-calling-lv-dropdown-set-selected/3983 --- src/lv_widgets/lv_dropdown.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/lv_widgets/lv_dropdown.c b/src/lv_widgets/lv_dropdown.c index 47c380d26..253ed1950 100644 --- a/src/lv_widgets/lv_dropdown.c +++ b/src/lv_widgets/lv_dropdown.c @@ -356,10 +356,8 @@ void lv_dropdown_set_selected(lv_obj_t * ddlist, uint16_t sel_opt) ext->sel_opt_id = sel_opt < ext->option_cnt ? sel_opt : ext->option_cnt - 1; ext->sel_opt_id_orig = ext->sel_opt_id; - /*Move the list to show the current option*/ - if(ext->page != NULL) { - lv_obj_invalidate(ddlist); - } + + lv_obj_invalidate(ddlist); } /** From 5fc66822b93212582db13287ba5aaf2f219f6837 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 10 Dec 2020 11:14:22 +0100 Subject: [PATCH 09/31] feat(img_cache): allow disabling image cacheing related to #1954 --- CHANGELOG.md | 1 + lv_conf_template.h | 2 +- src/lv_core/lv_obj.c | 3 +- src/lv_draw/lv_draw_img.c | 21 ++++++-- src/lv_draw/lv_img_cache.c | 104 +++++++++++++++++++++---------------- 5 files changed, 79 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0464f3306..98f155cd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### New features - feat(chart) add lv_chart_remove_series and lv_chart_hide_series +- feat(img_cahce) allow disabling image cacheing ### Bugfixes diff --git a/lv_conf_template.h b/lv_conf_template.h index ec423dfaf..fddd29882 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -240,7 +240,7 @@ typedef void * lv_fs_drv_user_data_t; * (I.e. no new image decoder is added) * With complex image decoders (e.g. PNG or JPG) caching can save the continuous open/decode of images. * However the opened images might consume additional RAM. - * LV_IMG_CACHE_DEF_SIZE must be >= 1 */ + * Set it to 0 to disable caching */ #define LV_IMG_CACHE_DEF_SIZE 1 /*Declare the type of the user data of image decoder (can be e.g. `void *`, `int`, `struct`)*/ diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index c73d58e3f..d962144d3 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -221,8 +221,9 @@ void lv_init(void) _lv_indev_init(); _lv_img_decoder_init(); +#if LV_IMG_CACHE_DEF_SIZE lv_img_cache_set_size(LV_IMG_CACHE_DEF_SIZE); - +#endif /*Test if the IDE has UTF-8 encoding*/ char * txt = "Á"; diff --git a/src/lv_draw/lv_draw_img.c b/src/lv_draw/lv_draw_img.c index 1e6de095f..2970fe43a 100644 --- a/src/lv_draw/lv_draw_img.c +++ b/src/lv_draw/lv_draw_img.c @@ -40,6 +40,7 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const bool chroma_key, bool alpha_byte); static void show_error(const lv_area_t * coords, const lv_area_t * clip_area, const char * msg); +static void draw_cleanup(lv_img_cache_entry_t * cache); /********************** * STATIC VARIABLES @@ -267,9 +268,10 @@ LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords, lv_area_t mask_com; /*Common area of mask and coords*/ bool union_ok; union_ok = _lv_area_intersect(&mask_com, clip_area, &map_area_rot); + /*Out of mask. There is nothing to draw so the image is drawn successfully.*/ if(union_ok == false) { - return LV_RES_OK; /*Out of mask. There is nothing to draw so the image is drawn - successfully.*/ + draw_cleanup(cdsc); + return LV_RES_OK; } lv_draw_map(coords, &mask_com, cdsc->dec_dsc.img_data, draw_dsc, chroma_keyed, alpha_byte); @@ -279,9 +281,10 @@ LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords, lv_area_t mask_com; /*Common area of mask and coords*/ bool union_ok; union_ok = _lv_area_intersect(&mask_com, clip_area, coords); + /*Out of mask. There is nothing to draw so the image is drawn successfully.*/ if(union_ok == false) { - return LV_RES_OK; /*Out of mask. There is nothing to draw so the image is drawn - successfully.*/ + draw_cleanup(cdsc); + return LV_RES_OK; } int32_t width = lv_area_get_width(&mask_com); @@ -306,6 +309,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords, lv_img_decoder_close(&cdsc->dec_dsc); LV_LOG_WARN("Image draw can't read the line"); _lv_mem_buf_release(buf); + draw_cleanup(cdsc); return LV_RES_INV; } @@ -318,6 +322,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords, _lv_mem_buf_release(buf); } + draw_cleanup(cdsc); return LV_RES_OK; } @@ -649,3 +654,11 @@ static void show_error(const lv_area_t * coords, const lv_area_t * clip_area, co lv_draw_label(coords, clip_area, &label_dsc, msg, NULL); } +static void draw_cleanup(lv_img_cache_entry_t * cache) +{ +/*Automatically close images with no caching*/ +#if LV_IMG_CACHE_DEF_SIZE == 0 + lv_img_decoder_close(&cache->dec_dsc); +#endif +} + diff --git a/src/lv_draw/lv_img_cache.c b/src/lv_draw/lv_img_cache.c index cef32144f..2488865c3 100644 --- a/src/lv_draw/lv_img_cache.c +++ b/src/lv_draw/lv_img_cache.c @@ -19,7 +19,7 @@ /********************* * DEFINES *********************/ -/*Decrement life with this value in every open*/ +/*Decrement life with this value on every open*/ #define LV_IMG_CACHE_AGING 1 /*Boost life by this factor (multiply time_to_open with this value)*/ @@ -29,10 +29,6 @@ * "die" from very high values */ #define LV_IMG_CACHE_LIFE_LIMIT 1000 -#if LV_IMG_CACHE_DEF_SIZE < 1 - #error "LV_IMG_CACHE_DEF_SIZE must be >= 1. See lv_conf.h" -#endif - /********************** * TYPEDEFS **********************/ @@ -40,11 +36,16 @@ /********************** * STATIC PROTOTYPES **********************/ +#if LV_IMG_CACHE_DEF_SIZE == 0 +static lv_img_cache_entry_t cache_temp; +#endif /********************** * STATIC VARIABLES **********************/ +#if LV_IMG_CACHE_DEF_SIZE static uint16_t entry_cnt; +#endif /********************** * MACROS @@ -64,6 +65,10 @@ static uint16_t entry_cnt; */ lv_img_cache_entry_t * _lv_img_cache_open(const void * src, lv_color_t color) { + /*Is the image cached?*/ + lv_img_cache_entry_t * cached_src = NULL; + +#if LV_IMG_CACHE_DEF_SIZE if(entry_cnt == 0) { LV_LOG_WARN("lv_img_cache_open: the cache size is 0"); return NULL; @@ -79,8 +84,6 @@ lv_img_cache_entry_t * _lv_img_cache_open(const void * src, lv_color_t color) } } - /*Is the image cached?*/ - lv_img_cache_entry_t * cached_src = NULL; for(i = 0; i < entry_cnt; i++) { bool match = false; lv_img_src_t src_type = lv_img_src_get_type(cache[i].dec_dsc.src); @@ -104,48 +107,51 @@ lv_img_cache_entry_t * _lv_img_cache_open(const void * src, lv_color_t color) } /*The image is not cached then cache it now*/ - if(cached_src == NULL) { - /*Find an entry to reuse. Select the entry with the least life*/ - cached_src = &cache[0]; - for(i = 1; i < entry_cnt; i++) { - if(cache[i].life < cached_src->life) { - cached_src = &cache[i]; - } - } + if(cached_src) return cached_src; - /*Close the decoder to reuse if it was opened (has a valid source)*/ - if(cached_src->dec_dsc.src) { - lv_img_decoder_close(&cached_src->dec_dsc); - LV_LOG_INFO("image draw: cache miss, close and reuse an entry"); + /*Find an entry to reuse. Select the entry with the least life*/ + cached_src = &cache[0]; + for(i = 1; i < entry_cnt; i++) { + if(cache[i].life < cached_src->life) { + cached_src = &cache[i]; } - else { - LV_LOG_INFO("image draw: cache miss, cached to an empty entry"); - } - - /*Open the image and measure the time to open*/ - uint32_t t_start; - t_start = lv_tick_get(); - cached_src->dec_dsc.time_to_open = 0; - lv_res_t open_res = lv_img_decoder_open(&cached_src->dec_dsc, src, color); - if(open_res == LV_RES_INV) { - LV_LOG_WARN("Image draw cannot open the image resource"); - lv_img_decoder_close(&cached_src->dec_dsc); - _lv_memset_00(&cached_src->dec_dsc, sizeof(lv_img_decoder_dsc_t)); - _lv_memset_00(cached_src, sizeof(lv_img_cache_entry_t)); - cached_src->life = INT32_MIN; /*Make the empty entry very "weak" to force its use */ - return NULL; - } - - cached_src->life = 0; - - /*If `time_to_open` was not set in the open function set it here*/ - if(cached_src->dec_dsc.time_to_open == 0) { - cached_src->dec_dsc.time_to_open = lv_tick_elaps(t_start); - } - - if(cached_src->dec_dsc.time_to_open == 0) cached_src->dec_dsc.time_to_open = 1; } + /*Close the decoder to reuse if it was opened (has a valid source)*/ + if(cached_src->dec_dsc.src) { + lv_img_decoder_close(&cached_src->dec_dsc); + LV_LOG_INFO("image draw: cache miss, close and reuse an entry"); + } + else { + LV_LOG_INFO("image draw: cache miss, cached to an empty entry"); + } + +#else + cached_src = &cache_temp; +#endif + /*Open the image and measure the time to open*/ + uint32_t t_start; + t_start = lv_tick_get(); + cached_src->dec_dsc.time_to_open = 0; + lv_res_t open_res = lv_img_decoder_open(&cached_src->dec_dsc, src, color); + if(open_res == LV_RES_INV) { + LV_LOG_WARN("Image draw cannot open the image resource"); + lv_img_decoder_close(&cached_src->dec_dsc); + _lv_memset_00(&cached_src->dec_dsc, sizeof(lv_img_decoder_dsc_t)); + _lv_memset_00(cached_src, sizeof(lv_img_cache_entry_t)); + cached_src->life = INT32_MIN; /*Make the empty entry very "weak" to force its use */ + return NULL; + } + + cached_src->life = 0; + + /*If `time_to_open` was not set in the open function set it here*/ + if(cached_src->dec_dsc.time_to_open == 0) { + cached_src->dec_dsc.time_to_open = lv_tick_elaps(t_start); + } + + if(cached_src->dec_dsc.time_to_open == 0) cached_src->dec_dsc.time_to_open = 1; + return cached_src; } @@ -157,6 +163,10 @@ lv_img_cache_entry_t * _lv_img_cache_open(const void * src, lv_color_t color) */ void lv_img_cache_set_size(uint16_t new_entry_cnt) { +#if LV_IMG_CACHE_DEF_SIZE == 0 + LV_UNUSED(new_entry_cnt); + LV_LOG_WARN("Can't change cache size because it's disabled by LV_IMG_CACHE_DEF_SIZE = 0"); +#else if(LV_GC_ROOT(_lv_img_cache_array) != NULL) { /*Clean the cache before free it*/ lv_img_cache_invalidate_src(NULL); @@ -178,6 +188,7 @@ void lv_img_cache_set_size(uint16_t new_entry_cnt) _lv_memset_00(&LV_GC_ROOT(_lv_img_cache_array)[i].dec_dsc, sizeof(lv_img_decoder_dsc_t)); _lv_memset_00(&LV_GC_ROOT(_lv_img_cache_array)[i], sizeof(lv_img_cache_entry_t)); } +#endif } /** @@ -187,7 +198,7 @@ void lv_img_cache_set_size(uint16_t new_entry_cnt) */ void lv_img_cache_invalidate_src(const void * src) { - +#if LV_IMG_CACHE_DEF_SIZE lv_img_cache_entry_t * cache = LV_GC_ROOT(_lv_img_cache_array); uint16_t i; @@ -201,6 +212,7 @@ void lv_img_cache_invalidate_src(const void * src) _lv_memset_00(&cache[i], sizeof(lv_img_cache_entry_t)); } } +#endif } /********************** From b04dea5971dd968a38bbfe24c58d245a5669ae3b Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 10 Dec 2020 11:18:30 +0100 Subject: [PATCH 10/31] fix warnings --- src/lv_draw/lv_draw_img.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lv_draw/lv_draw_img.c b/src/lv_draw/lv_draw_img.c index 2970fe43a..0ad15f0c6 100644 --- a/src/lv_draw/lv_draw_img.c +++ b/src/lv_draw/lv_draw_img.c @@ -659,6 +659,8 @@ static void draw_cleanup(lv_img_cache_entry_t * cache) /*Automatically close images with no caching*/ #if LV_IMG_CACHE_DEF_SIZE == 0 lv_img_decoder_close(&cache->dec_dsc); +#else + LV_UNUSED(cache); #endif } From 0a7f6a6331eb6d49950e39eff9c991d8237aae9a Mon Sep 17 00:00:00 2001 From: Rhaoma <65562497+Rhaoma@users.noreply.github.com> Date: Fri, 11 Dec 2020 16:37:20 +0100 Subject: [PATCH 11/31] Add option to align title text in window (#1953) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add option to align title text in window I found that i really needed a basic way to align the title text in a window, and therefore i did a bit of tinkering and came up with this solution. Mind you that I'm very new to this so it might not be the most optimal way. I have tested a bit and it pretty looked promising, I have of course written the alignments as I felt was most suitable, but I shouldn't be the judge of that. Current alignment: LV_TXT_FLAG_CENTER makes the text align in the center of the header but ensures it can’t overextend into to header button area; LV_TXT_FLAG_RIGHT makes the text align at the right side, but takes the right side header buttons into account LV_TXT_FLAG_FIT & LV_TXT_FLAG_EXPAND I wasn’t too sure about what to do so as of now it just aligns them as normal LV_TXT_FLAG_NONE Is equal to no flag set by the user and therefore I have just set it to the default coords, like normal. The text then align at the left side. * Update lv_win.h * Added functions Added function to set and get alignment of the header title as requested * Added functions Added setter and getter functions for the header title alignment as requested --- src/lv_widgets/lv_win.c | 55 +++++++++++++++++++++++++++++++++++------ src/lv_widgets/lv_win.h | 14 +++++++++++ 2 files changed, 61 insertions(+), 8 deletions(-) diff --git a/src/lv_widgets/lv_win.c b/src/lv_widgets/lv_win.c index b0f123ee8..3e4a5f3f8 100644 --- a/src/lv_widgets/lv_win.c +++ b/src/lv_widgets/lv_win.c @@ -92,6 +92,7 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy) ext->page = NULL; ext->header = NULL; ext->title_txt = lv_mem_alloc(strlen(DEF_TITLE) + 1); + ext->title_txt_align = LV_TXT_FLAG_NONE; strcpy(ext->title_txt, DEF_TITLE); /*Init the new window object*/ @@ -363,6 +364,14 @@ void lv_win_set_drag(lv_obj_t * win, bool en) lv_obj_set_drag(win, en); } +void lv_win_title_set_alignment(lv_obj_t * win, uint8_t alignment) +{ + lv_win_ext_t * ext = lv_obj_get_ext_attr(win); + + ext->title_txt_align = alignment; + +} + /*===================== * Getter functions *====================*/ @@ -491,6 +500,14 @@ lv_coord_t lv_win_get_width(lv_obj_t * win) return lv_obj_get_width_fit(scrl) - left - right; } +uint8_t lv_win_title_get_alignment(lv_obj_t * win) +{ + lv_win_ext_t * ext = lv_obj_get_ext_attr(win); + + return ext->title_txt_align; +} + + /*===================== * Other functions *====================*/ @@ -538,11 +555,13 @@ static lv_design_res_t lv_win_header_design(lv_obj_t * header, const lv_area_t * lv_win_ext_t * ext = lv_obj_get_ext_attr(win); lv_style_int_t header_left = lv_obj_get_style_pad_left(win, LV_WIN_PART_HEADER); + lv_style_int_t header_right = lv_obj_get_style_pad_right(win, LV_WIN_PART_HEADER); lv_style_int_t header_inner = lv_obj_get_style_pad_inner(win, LV_WIN_PART_HEADER); lv_draw_label_dsc_t label_dsc; lv_draw_label_dsc_init(&label_dsc); lv_obj_init_draw_label_dsc(header, LV_OBJ_PART_MAIN, &label_dsc); + label_dsc.flag = ext->title_txt_align; lv_area_t txt_area; lv_point_t txt_size; @@ -557,21 +576,41 @@ static lv_design_res_t lv_win_header_design(lv_obj_t * header, const lv_area_t * /*Get x position of the title (should be on the right of the buttons on the left)*/ - lv_coord_t left_btn_offset = 0; + lv_coord_t btn_offset = 0; btn = lv_obj_get_child_back(ext->header, NULL); while(btn != NULL) { if(LV_WIN_BTN_ALIGN_LEFT == lv_win_btn_get_alignment(btn)) { - left_btn_offset += btn_w + header_inner; + btn_offset += btn_w + header_inner; } btn = lv_obj_get_child_back(header, btn); } - - txt_area.x1 = header->coords.x1 + header_left + left_btn_offset; - txt_area.y1 = header->coords.y1 + (lv_obj_get_height(header) - txt_size.y) / 2; - txt_area.x2 = txt_area.x1 + txt_size.x + left_btn_offset; - txt_area.y2 = txt_area.y1 + txt_size.y; - + switch(label_dsc.flag) { + case LV_TXT_FLAG_CENTER: + txt_area.x1 = header->coords.x1 + header_left + btn_offset; + txt_area.x2 = header->coords.x2 - header_right - btn_offset; + txt_area.y1 = header->coords.y1 + (lv_obj_get_height(header) - txt_size.y) / 2; + txt_area.y2 = txt_area.y1 + txt_size.y; + break; + case LV_TXT_FLAG_RIGHT: + txt_area.x1 = header->coords.x1; + txt_area.x2 = header->coords.x2 - header_right - btn_offset; + txt_area.y1 = header->coords.y1 + (lv_obj_get_height(header) - txt_size.y) / 2; + txt_area.y2 = txt_area.y1 + txt_size.y; + break; + case LV_TXT_FLAG_FIT || LV_TXT_FLAG_EXPAND: + txt_area.x1 = header->coords.x1; + txt_area.x2 = header->coords.x2; + txt_area.y1 = header->coords.y1 + (lv_obj_get_height(header) - txt_size.y) / 2; + txt_area.y2 = txt_area.y1 + txt_size.y; + break; + default: + txt_area.x1 = header->coords.x1 + header_left + btn_offset; + txt_area.x2 = txt_area.x1 + txt_size.x + btn_offset; + txt_area.y1 = header->coords.y1 + (lv_obj_get_height(header) - txt_size.y) / 2; + txt_area.y2 = txt_area.y1 + txt_size.y; + break; + } lv_draw_label(&txt_area, clip_area, &label_dsc, ext->title_txt, NULL); } else if(mode == LV_DESIGN_DRAW_POST) { diff --git a/src/lv_widgets/lv_win.h b/src/lv_widgets/lv_win.h index 06e67132d..3bf4bf71b 100644 --- a/src/lv_widgets/lv_win.h +++ b/src/lv_widgets/lv_win.h @@ -57,6 +57,7 @@ typedef struct { lv_obj_t * header; /*Pointer to the header container of the window*/ char * title_txt; /*Pointer to the title label of the window*/ lv_coord_t btn_w; /*Width of the control buttons*/ + uint8_t title_txt_align; /*Control the alignment of the header text*/ } lv_win_ext_t; /** Window parts. */ @@ -175,6 +176,13 @@ void lv_win_set_anim_time(lv_obj_t * win, uint16_t anim_time); */ void lv_win_set_drag(lv_obj_t * win, bool en); +/** + * Set alignment of title text in window header. + * @param win pointer to a window object + * @param alignment set the type of alignment with LV_TXT_FLAGS + */ +void lv_win_title_set_alignment(lv_obj_t * win, uint8_t alignment); + /*===================== * Getter functions *====================*/ @@ -254,6 +262,12 @@ static inline bool lv_win_get_drag(const lv_obj_t * win) return lv_obj_get_drag(win); } +/** + * Get the current alignment of title text in window header. + * @param win pointer to a window object + */ +uint8_t lv_win_title_get_alignment(lv_obj_t * win); + /*===================== * Other functions *====================*/ From 417e32b4df1b45f2682f8455da3ecde4087a8abc Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 11 Dec 2020 16:40:52 +0100 Subject: [PATCH 12/31] fix: add missing lv_txt_ap.h include to some C files --- src/lv_misc/lv_txt.c | 1 + src/lv_widgets/lv_table.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lv_misc/lv_txt.c b/src/lv_misc/lv_txt.c index 5d05c714e..4afdefd55 100644 --- a/src/lv_misc/lv_txt.c +++ b/src/lv_misc/lv_txt.c @@ -8,6 +8,7 @@ *********************/ #include #include "lv_txt.h" +#include "lv_txt_ap.h" #include "lv_math.h" #include "lv_log.h" #include "lv_debug.h" diff --git a/src/lv_widgets/lv_table.c b/src/lv_widgets/lv_table.c index 2f652ba1f..fb20980eb 100644 --- a/src/lv_widgets/lv_table.c +++ b/src/lv_widgets/lv_table.c @@ -9,12 +9,13 @@ #include "lv_table.h" #if LV_USE_TABLE != 0 -#include "../lv_misc/lv_debug.h" #include "../lv_core/lv_indev.h" +#include "../lv_misc/lv_debug.h" #include "../lv_misc/lv_txt.h" +#include "../lv_misc/lv_txt_ap.h" #include "../lv_misc/lv_math.h" -#include "../lv_draw/lv_draw_label.h" #include "../lv_misc/lv_printf.h" +#include "../lv_draw/lv_draw_label.h" #include "../lv_themes/lv_theme.h" /********************* From 9b579f3fadc4e3ec2c4c8c433442670888652e45 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 11 Dec 2020 16:42:15 +0100 Subject: [PATCH 13/31] fix(test): use sys/time.h only if built in test mode --- tests/lv_test_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lv_test_main.c b/tests/lv_test_main.c index f1fd224cc..e910f4891 100644 --- a/tests/lv_test_main.c +++ b/tests/lv_test_main.c @@ -1,11 +1,11 @@ #include "../lvgl.h" #include #include -#include #include "lv_test_core/lv_test_core.h" #include "lv_test_widgets/lv_test_label.h" #if LV_BUILD_TEST +#include static void hal_init(void); static void dummy_flush_cb(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p); From 9e72cb00005b4128ee060729a4f797e667680f51 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 15 Dec 2020 19:59:27 +0100 Subject: [PATCH 14/31] Release v7.8.1 --- lvgl.h | 2 +- src/lv_api_map.h | 2 +- src/lv_conf_internal.h | 6 +++--- src/lv_widgets/lv_dropdown.c | 2 +- src/lv_widgets/lv_tabview.c | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lvgl.h b/lvgl.h index 2583fc422..7defe1b73 100644 --- a/lvgl.h +++ b/lvgl.h @@ -17,7 +17,7 @@ extern "C" { #define LVGL_VERSION_MAJOR 7 #define LVGL_VERSION_MINOR 8 #define LVGL_VERSION_PATCH 1 -#define LVGL_VERSION_INFO "dev" +#define LVGL_VERSION_INFO "" /********************* * INCLUDES diff --git a/src/lv_api_map.h b/src/lv_api_map.h index f5f7a5402..f86a4c6d6 100644 --- a/src/lv_api_map.h +++ b/src/lv_api_map.h @@ -188,7 +188,7 @@ static inline lv_obj_t * lv_page_get_scrl(lv_obj_t * page) #if LV_USE_API_EXTENSION_V7 #if LV_USE_ROLLER -#define LV_ROLLER_MODE_INIFINITE LV_ROLLER_MODE_INFINITE +#define LV_ROLLER_MODE_INIFINITE LV_ROLLER_MODE_INFINITE #endif #if LV_USE_WIN diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index 5bf85131d..1ad907688 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -201,7 +201,7 @@ # endif #endif -/* Complier prefix for a big array declaration */ +/* Compiler prefix for a big array declaration */ #ifndef LV_MEM_ATTR # ifdef CONFIG_LV_MEM_ATTR # define LV_MEM_ATTR CONFIG_LV_MEM_ATTR @@ -330,7 +330,7 @@ #endif /* Long press time in milliseconds. - * Time to send `LV_EVENT_LONG_PRESSSED`) */ + * Time to send `LV_EVENT_LONG_PRESSED`) */ #ifndef LV_INDEV_DEF_LONG_PRESS_TIME # ifdef CONFIG_LV_INDEV_DEF_LONG_PRESS_TIME # define LV_INDEV_DEF_LONG_PRESS_TIME CONFIG_LV_INDEV_DEF_LONG_PRESS_TIME @@ -1322,7 +1322,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_widgets/lv_dropdown.c b/src/lv_widgets/lv_dropdown.c index 253ed1950..446206d69 100644 --- a/src/lv_widgets/lv_dropdown.c +++ b/src/lv_widgets/lv_dropdown.c @@ -356,7 +356,7 @@ void lv_dropdown_set_selected(lv_obj_t * ddlist, uint16_t sel_opt) ext->sel_opt_id = sel_opt < ext->option_cnt ? sel_opt : ext->option_cnt - 1; ext->sel_opt_id_orig = ext->sel_opt_id; - + lv_obj_invalidate(ddlist); } diff --git a/src/lv_widgets/lv_tabview.c b/src/lv_widgets/lv_tabview.c index 2cb2b6bc0..96200ec0a 100644 --- a/src/lv_widgets/lv_tabview.c +++ b/src/lv_widgets/lv_tabview.c @@ -166,7 +166,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy) lv_btnmatrix_set_map(ext->btns, ext->tab_name_ptr); lv_style_list_copy(lv_obj_get_style_list(tabview, LV_TABVIEW_PART_BG_SCROLLABLE), lv_obj_get_style_list(copy, - LV_TABVIEW_PART_BG_SCROLLABLE)); + LV_TABVIEW_PART_BG_SCROLLABLE)); lv_style_list_copy(lv_obj_get_style_list(tabview, LV_TABVIEW_PART_TAB_BG), lv_obj_get_style_list(copy, LV_TABVIEW_PART_TAB_BG)); lv_style_list_copy(lv_obj_get_style_list(tabview, LV_TABVIEW_PART_TAB_BTN), lv_obj_get_style_list(copy, @@ -616,7 +616,7 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p else if(info->part == LV_TABVIEW_PART_TAB_BTN) info->result = lv_obj_get_state(ext->btns, LV_BTNMATRIX_PART_BTN); else if(info->part == LV_TABVIEW_PART_INDIC) info->result = lv_obj_get_state(ext->indic, LV_OBJ_PART_MAIN); else if(info->part == LV_TABVIEW_PART_BG_SCROLLABLE) info->result = lv_obj_get_state(ext->content, - LV_PAGE_PART_SCROLLABLE); + LV_PAGE_PART_SCROLLABLE); return LV_RES_OK; } From 93d7bd4cf5c07a9f0c5bfa4b330aa99da5b317d3 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 20 Dec 2020 10:53:06 +0100 Subject: [PATCH 15/31] release script: update version in Kconfig --- scripts/release/com.py | 9 ++++++--- scripts/release/main.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/release/com.py b/scripts/release/com.py index 2bd77edd1..bb3fd7ddd 100755 --- a/scripts/release/com.py +++ b/scripts/release/com.py @@ -85,10 +85,10 @@ def update_version(ver): templ = fnmatch.filter(os.listdir('.'), '*_templ*.h') - if len(templ) > 0 and templ[0]: + if len(templ) > 0 and templ[0]: print("Updating version in " + templ[0]) - cmd("sed -i -r 's/v[0-9]+\.[0-9]+\.[0-9]+/"+ "v" + ver_num + "/' " + templ[0]) - + cmd("sed -i -r 's/v[0-9]+\.[0-9]+\.[0-9]+.*/"+ "v" + ver_num + "/' " + templ[0]) + if os.path.exists("library.json"): print("Updating version in library.json") cmd("sed -i -r 's/[0-9]+\.[0-9]+\.[0-9]+/"+ ver_num +"/' library.json") @@ -100,6 +100,9 @@ def update_version(ver): if path.exists("conf.py"): cmd("sed -i -r \"s/'v[0-9]+\.[0-9]+\.[0-9]+.*'/\'" + ver_str + "'/\" conf.py") + if path.exists("Kconfig"): + cmd("sed -i -r \"s/'v[0-9]+\.[0-9]+\.[0-9]+.*'/\'" + ver_str + "'/\" Kconfig") + if path.exists("lvgl.h"): define_set("./lvgl.h", "LVGL_VERSION_MAJOR", str(ver[0])) define_set("./lvgl.h", "LVGL_VERSION_MINOR", str(ver[1])) diff --git a/scripts/release/main.py b/scripts/release/main.py index 4dd2e1fac..a96d11fc3 100755 --- a/scripts/release/main.py +++ b/scripts/release/main.py @@ -55,7 +55,7 @@ if __name__ == '__main__': print("Invalid argument. Usage ./release.py bugfix | minor | major") exit(1) - os.chdir(workdir) + #os.chdir(workdir) clone_repos() release.make() for p in proj_list: From aac672e88b793900949b00e9716b4ef2f6a5400e Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 20 Dec 2020 10:54:40 +0100 Subject: [PATCH 16/31] fix(draw): free buffer used for arabic processing --- src/lv_draw/lv_draw_rect.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index 11be44f32..350178a93 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -1331,6 +1331,10 @@ static void draw_value_str(const lv_area_t * coords, const lv_area_t * clip, con label_dsc.opa = dsc->value_opa; lv_draw_label(&value_area, clip, &label_dsc, str, NULL); + +#if LV_USE_ARABIC_PERSIAN_CHARS + _lv_mem_buf_release(str); +#endif } #endif From 2bf91dbbb5391c8b37162e55a09b4a85ab597f80 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 20 Dec 2020 10:55:20 +0100 Subject: [PATCH 17/31] calendar: make get_day_of_week() public --- src/lv_widgets/lv_calendar.c | 42 ++++++++++++++++++------------------ src/lv_widgets/lv_calendar.h | 9 ++++++++ 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/lv_widgets/lv_calendar.c b/src/lv_widgets/lv_calendar.c index 9aa6f3381..db44152f7 100644 --- a/src/lv_widgets/lv_calendar.c +++ b/src/lv_widgets/lv_calendar.c @@ -365,6 +365,27 @@ const char ** lv_calendar_get_month_names(const lv_obj_t * calendar) return ext->month_names; } +/** + * Get the day of the week + * @param year a year + * @param month a month (1..12) + * @param day a day (1..31) + * @return [0..6] which means [Sun..Sat] or [Mon..Sun] depending on LV_CALENDAR_WEEK_STARTS_MONDAY + */ +uint8_t lv_calendar_get_day_of_week(uint32_t year, uint32_t month, uint32_t day) +{ + uint32_t a = month < 3 ? 1 : 0; + uint32_t b = year - a; + +#if LV_CALENDAR_WEEK_STARTS_MONDAY + uint32_t day_of_week = (day + (31 * (month - 2 + 12 * a) / 12) + b + (b / 4) - (b / 100) + (b / 400) - 1) % 7; +#else + uint32_t day_of_week = (day + (31 * (month - 2 + 12 * a) / 12) + b + (b / 4) - (b / 100) + (b / 400)) % 7; +#endif + + return day_of_week; +} + /*===================== * Other functions *====================*/ @@ -1067,25 +1088,4 @@ static uint8_t is_leap_year(uint32_t year) return (year % 4) || ((year % 100 == 0) && (year % 400)) ? 0 : 1; } -/** - * Get the day of the week - * @param year a year - * @param month a month - * @param day a day - * @return [0..6] which means [Sun..Sat] or [Mon..Sun] depending on LV_CALENDAR_WEEK_STARTS_MONDAY - */ -static uint8_t get_day_of_week(uint32_t year, uint32_t month, uint32_t day) -{ - uint32_t a = month < 3 ? 1 : 0; - uint32_t b = year - a; - -#if LV_CALENDAR_WEEK_STARTS_MONDAY - uint32_t day_of_week = (day + (31 * (month - 2 + 12 * a) / 12) + b + (b / 4) - (b / 100) + (b / 400) - 1) % 7; -#else - uint32_t day_of_week = (day + (31 * (month - 2 + 12 * a) / 12) + b + (b / 4) - (b / 100) + (b / 400)) % 7; -#endif - - return day_of_week; -} - #endif diff --git a/src/lv_widgets/lv_calendar.h b/src/lv_widgets/lv_calendar.h index 1e0f88cdc..66f2b24ca 100644 --- a/src/lv_widgets/lv_calendar.h +++ b/src/lv_widgets/lv_calendar.h @@ -182,6 +182,15 @@ const char ** lv_calendar_get_day_names(const lv_obj_t * calendar); */ const char ** lv_calendar_get_month_names(const lv_obj_t * calendar); +/** + * Get the day of the week + * @param year a year + * @param month a month (1..12) + * @param day a day (1..31) + * @return [0..6] which means [Sun..Sat] or [Mon..Sun] depending on LV_CALENDAR_WEEK_STARTS_MONDAY + */ +uint8_t lv_calendar_get_day_of_week(uint32_t year, uint32_t month, uint32_t day); + /*===================== * Other functions *====================*/ From b0fecc6bb27fdff0579c6f7b5cf72c7e0c3ea97d Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 20 Dec 2020 10:56:30 +0100 Subject: [PATCH 18/31] update CHANGELOG --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98f155cd0..4d7670681 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,10 @@ ### New features - feat(chart) add lv_chart_remove_series and lv_chart_hide_series - feat(img_cahce) allow disabling image cacheing - +- calendar: make get_day_of_week() public + ### Bugfixes +- fix(draw_rect) free buffer used for arabic processing ## v7.8.1 (Plannad at 15.12.2020) From cb021a425ad17447ceaeec2c22f9d5bb1f507272 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 20 Dec 2020 10:59:42 +0100 Subject: [PATCH 19/31] calendar: fix build error --- src/lv_widgets/lv_calendar.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/lv_widgets/lv_calendar.c b/src/lv_widgets/lv_calendar.c index db44152f7..5352e177d 100644 --- a/src/lv_widgets/lv_calendar.c +++ b/src/lv_widgets/lv_calendar.c @@ -44,7 +44,6 @@ static lv_coord_t get_day_names_height(lv_obj_t * calendar); static void draw_header(lv_obj_t * calendar, const lv_area_t * mask); static void draw_day_names(lv_obj_t * calendar, const lv_area_t * mask); static void draw_dates(lv_obj_t * calendar, const lv_area_t * clip_area); -static uint8_t get_day_of_week(uint32_t year, uint32_t month, uint32_t day); static bool is_highlighted(lv_obj_t * calendar, day_draw_state_t draw_state, int32_t year, int32_t month, int32_t day); static bool is_pressed(lv_obj_t * calendar, day_draw_state_t draw_state, int32_t year, int32_t month, int32_t day); static const char * get_day_name(lv_obj_t * calendar, uint8_t day); @@ -638,22 +637,22 @@ static bool calculate_touched_day(lv_obj_t * calendar, const lv_point_t * touche uint8_t i_pos = 0; i_pos = (y_pos * 7) + x_pos; lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar); - if(i_pos < get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1)) { + if(i_pos < lv_calendar_get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1)) { ext->pressed_date.year = ext->showed_date.year - (ext->showed_date.month == 1 ? 1 : 0); ext->pressed_date.month = ext->showed_date.month == 1 ? 12 : (ext->showed_date.month - 1); ext->pressed_date.day = get_month_length(ext->pressed_date.year, ext->pressed_date.month) - - get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) + 1 + i_pos; + lv_calendar_get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) + 1 + i_pos; } - else if(i_pos < (get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) + + else if(i_pos < (lv_calendar_get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) + get_month_length(ext->showed_date.year, ext->showed_date.month))) { ext->pressed_date.year = ext->showed_date.year; ext->pressed_date.month = ext->showed_date.month; - ext->pressed_date.day = i_pos + 1 - get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1); + ext->pressed_date.day = i_pos + 1 - lv_calendar_get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1); } else if(i_pos < 42) { ext->pressed_date.year = ext->showed_date.year + (ext->showed_date.month == 12 ? 1 : 0); ext->pressed_date.month = ext->showed_date.month == 12 ? 1 : (ext->showed_date.month + 1); - ext->pressed_date.day = i_pos + 1 - get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) - + ext->pressed_date.day = i_pos + 1 - lv_calendar_get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) - get_month_length(ext->showed_date.year, ext->showed_date.month); } return true; @@ -847,7 +846,7 @@ static void draw_dates(lv_obj_t * calendar, const lv_area_t * clip_area) lv_coord_t box_h = (days_h - 5 * date_inner) / 6; lv_coord_t box_size = LV_MATH_MIN(box_w, box_h); - uint8_t month_start_day = get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1); + uint8_t month_start_day = lv_calendar_get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1); day_draw_state_t draw_state; From 243145d8c93b20cce0354921061763ccb53ec4b7 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 20 Dec 2020 13:21:06 +0100 Subject: [PATCH 20/31] add arabic processin to to window title and lv_dropdown_add_option --- CHANGELOG.md | 2 ++ src/lv_widgets/lv_dropdown.c | 17 +++++++++++++---- src/lv_widgets/lv_win.c | 13 +++++++++++-- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d7670681..99609bfb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ ### Bugfixes - fix(draw_rect) free buffer used for arabic processing +- fix(win) arabic process the title of the window +- fix(dropdown) arabic process the option in lv_dropdown_add_option ## v7.8.1 (Plannad at 15.12.2020) diff --git a/src/lv_widgets/lv_dropdown.c b/src/lv_widgets/lv_dropdown.c index 446206d69..d0ebc0efd 100644 --- a/src/lv_widgets/lv_dropdown.c +++ b/src/lv_widgets/lv_dropdown.c @@ -303,7 +303,12 @@ void lv_dropdown_add_option(lv_obj_t * ddlist, const char * option, uint32_t pos /*Allocate space for the new option*/ size_t old_len = (ext->options == NULL) ? 0 : strlen(ext->options); - size_t ins_len = strlen(option); +#if LV_USE_ARABIC_PERSIAN_CHARS == 0 + size_t ins_len = strlen(option) + 1; +#else + size_t ins_len = _lv_txt_ap_calc_bytes_cnt(option) + 1; +#endif + size_t new_len = ins_len + old_len + 2; /* +2 for terminating NULL and possible \n */ ext->options = lv_mem_realloc(ext->options, new_len + 1); LV_ASSERT_MEM(ext->options); @@ -331,9 +336,13 @@ void lv_dropdown_add_option(lv_obj_t * ddlist, const char * option, uint32_t pos char * ins_buf = _lv_mem_buf_get(ins_len + 2); /* + 2 for terminating NULL and possible \n */ LV_ASSERT_MEM(ins_buf); if(ins_buf == NULL) return; - strcpy(ins_buf, option); - if(pos < ext->option_cnt) - strcat(ins_buf, "\n"); +#if LV_USE_ARABIC_PERSIAN_CHARS == 0 + strcpy(ins_buf, options); +#else + _lv_txt_ap_proc(option, ins_buf); +#endif + if(pos < ext->option_cnt) strcat(ins_buf, "\n"); + _lv_txt_ins(ext->options, _lv_txt_encoded_get_char_id(ext->options, insert_pos), ins_buf); _lv_mem_buf_release(ins_buf); diff --git a/src/lv_widgets/lv_win.c b/src/lv_widgets/lv_win.c index 3e4a5f3f8..e087e2d19 100644 --- a/src/lv_widgets/lv_win.c +++ b/src/lv_widgets/lv_win.c @@ -258,11 +258,20 @@ void lv_win_set_title(lv_obj_t * win, const char * title) lv_win_ext_t * ext = lv_obj_get_ext_attr(win); - ext->title_txt = lv_mem_realloc(ext->title_txt, strlen(title) + 1); +#if LV_USE_ARABIC_PERSIAN_CHARS == 0 + size_t len = strlen(title) + 1; +#else + size_t len = _lv_txt_ap_calc_bytes_cnt(title) + 1; +#endif + + ext->title_txt = lv_mem_realloc(ext->title_txt, len + 1); LV_ASSERT_MEM(ext->title_txt); if(ext->title_txt == NULL) return; - +#if LV_USE_ARABIC_PERSIAN_CHARS == 0 strcpy(ext->title_txt, title); +#else + _lv_txt_ap_proc(title, ext->title_txt); +#endif lv_obj_invalidate(ext->header); } From 1b83855c72fc9fbf8f4046cbdb22d4db48725d0f Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 20 Dec 2020 13:31:44 +0100 Subject: [PATCH 21/31] Create pull_request_template.md --- .github/pull_request_template.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 000000000..4d76e91c4 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,11 @@ + + +### Description of the feature of fix + +A clear and concise description of what the bug is. + + +### Chekpoints +- [ ] Follow the [styling guide](https://github.com/lvgl/lvgl/blob/master/docs/CODING_STYLE.md) +- [ ] Update CHANGELOG.md +- [ ] Update the docsumentation From cd69be12d1441c51afb1b40f05cb62eaefd1bbfe Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 20 Dec 2020 13:32:37 +0100 Subject: [PATCH 22/31] Update pull_request_template.md --- .github/pull_request_template.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 4d76e91c4..882f4644c 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,10 +1,7 @@ - - ### Description of the feature of fix A clear and concise description of what the bug is. - ### Chekpoints - [ ] Follow the [styling guide](https://github.com/lvgl/lvgl/blob/master/docs/CODING_STYLE.md) - [ ] Update CHANGELOG.md From 62d21734d9101ec285074b7cc0de9739b0c7cd46 Mon Sep 17 00:00:00 2001 From: Mattia Maldini Date: Sun, 20 Dec 2020 13:34:48 +0100 Subject: [PATCH 23/31] Improved ESP-IDF integration (#1961) * Removed LV_CONF_SKIP definition from CMake to avoid redefinition warnings; added more Kconfig options * Bumped up version and removed unnecessary default values * Added user data configuration to KConfig * Moved user data options to "Feature Usage" menu --- CMakeLists.txt | 24 +++++++++++++++++-- Kconfig | 62 +++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 81 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 114db196b..7f9caf709 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,10 +3,30 @@ if(ESP_PLATFORM) file(GLOB_RECURSE SOURCES src/*.c) idf_component_register(SRCS ${SOURCES} - INCLUDE_DIRS . src) + INCLUDE_DIRS . src + REQUIRES main) target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DLV_CONF_INCLUDE_SIMPLE") -target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DLV_CONF_SKIP") + +if (CONFIG_LV_MEM_CUSTOM) + if (CONFIG_LV_MEM_CUSTOM_ALLOC) + target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DLV_MEM_CUSTOM_ALLOC=${CONFIG_LV_MEM_CUSTOM_ALLOC}") + endif() + + if (CONFIG_LV_MEM_CUSTOM_FREE) + target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DLV_MEM_CUSTOM_FREE=${CONFIG_LV_MEM_CUSTOM_FREE}") + endif() +endif() + +if (CONFIG_LV_TICK_CUSTOM) + if (CONFIG_LV_TICK_CUSTOM_SYS_TIME_EXPR) + target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DLV_TICK_CUSTOM_SYS_TIME_EXPR=${CONFIG_LV_TICK_CUSTOM_SYS_TIME_EXPR}") + endif() +endif() + +if (CONFIG_LV_USER_DATA_FREE) + target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DLV_USER_DATA_FREE=${CONFIG_LV_USER_DATA_FREE}") +endif() if (CONFIG_LV_ATTRIBUTE_FAST_MEM_USE_IRAM) target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DLV_ATTRIBUTE_FAST_MEM=IRAM_ATTR") diff --git a/Kconfig b/Kconfig index 9eaf97a4a..adddb034e 100644 --- a/Kconfig +++ b/Kconfig @@ -1,4 +1,4 @@ -# Kconfig file for LVGL v7.7.1 +# Kconfig file for LVGL v7.8.1 menu "LVGL configuration" @@ -105,11 +105,38 @@ menu "LVGL configuration" displays. menu "Memory manager settings" + config LV_MEM_CUSTOM + bool + prompt "If true use custom malloc/free, otherwise use the built-in `lv_mem_alloc` and `lv_mem_free`" + + config LV_MEM_CUSTOM_INCLUDE + string + prompt "Header to include for the custom memory function" + default stdlib.h + depends on LV_MEM_CUSTOM + + config LV_MEM_CUSTOM_ALLOC + string + prompt "Wrapper to malloc" + default malloc + depends on LV_MEM_CUSTOM + + config LV_MEM_CUSTOM_FREE + string + prompt "Wrapper to free" + default free + depends on LV_MEM_CUSTOM + config LV_MEM_SIZE_BYTES int prompt "Size of the memory used by `lv_mem_alloc` in kilobytes (>= 2kB)" range 2 128 - default 32 + default 32 + depends on !LV_MEM_CUSTOM + + config LV_MEMCPY_MEMSET_STD + bool + prompt "Use the standard memcpy and memset instead of LVGL's own functions" endmenu menu "Indev device settings" @@ -204,6 +231,17 @@ menu "LVGL configuration" default y if !LV_CONF_MINIMAL config LV_USE_USER_DATA bool "Add a 'user_data' to drivers and objects." + config LV_USE_USER_DATA_FREE + bool "Free the user data field upon object deletion" + depends on LV_USE_USER_DATA + config LV_USER_DATA_FREE_INCLUDE + string "Header for user data free function" + default "something.h" + depends on LV_USE_USER_DATA_FREE + config LV_USER_DATA_FREE + string "Invoking for user data free function. It has the lv_obj_t pointer as single parameter." + default "(user_data_free)" + depends on LV_USE_USER_DATA_FREE config LV_USE_PERF_MONITOR bool "Show CPU usage and FPS count in the right bottom corner." config LV_USE_API_EXTENSION_V6 @@ -235,11 +273,29 @@ menu "LVGL configuration" LV_IMG_CACHE_DEF_SIZE must be >= 1 endmenu - menu "Compiler settings" + menu "Compiler Settings" config LV_BIG_ENDIAN_SYSTEM bool "For big endian systems set to 1" endmenu + menu "HAL Settings" + config LV_TICK_CUSTOM + bool + prompt "Use a custom tick source" + + config LV_TICK_CUSTOM_INCLUDE + string + prompt "Header for the system time function" + default Arduino.h + depends on LV_TICK_CUSTOM + + config LV_TICK_CUSTOM_SYS_TIME_EXPR + string + prompt "Expression evaluating to current system time in ms" + default "(millis())" + depends on LV_TICK_CUSTOM + endmenu + menu "Log Settings" config LV_USE_LOG bool "Enable the log module" From 3d22dc57229c19aa4648bf8238589bde7031f438 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 20 Dec 2020 13:39:00 +0100 Subject: [PATCH 24/31] dropdown: fix typo causing build error --- src/lv_widgets/lv_dropdown.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_widgets/lv_dropdown.c b/src/lv_widgets/lv_dropdown.c index d0ebc0efd..60f78d52c 100644 --- a/src/lv_widgets/lv_dropdown.c +++ b/src/lv_widgets/lv_dropdown.c @@ -337,7 +337,7 @@ void lv_dropdown_add_option(lv_obj_t * ddlist, const char * option, uint32_t pos LV_ASSERT_MEM(ins_buf); if(ins_buf == NULL) return; #if LV_USE_ARABIC_PERSIAN_CHARS == 0 - strcpy(ins_buf, options); + strcpy(ins_buf, option); #else _lv_txt_ap_proc(option, ins_buf); #endif From c4d978fa6f544a06e45db2df7cc84a777ce866e0 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 20 Dec 2020 15:36:28 +0100 Subject: [PATCH 25/31] fix(textarea): buffer overflow in password mode with UTF-8 characters fixes #1960 --- CHANGELOG.md | 1 + src/lv_widgets/lv_textarea.c | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99609bfb1..6d0fb278a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - fix(draw_rect) free buffer used for arabic processing - fix(win) arabic process the title of the window - fix(dropdown) arabic process the option in lv_dropdown_add_option +- fix(textarea) buffer overflow in password mode with UTF-8 characters ## v7.8.1 (Plannad at 15.12.2020) diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index 8b34e1ace..260905eaf 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -276,8 +276,7 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c) lv_textarea_clear_selection(ta); /*Clear selection*/ if(ext->pwd_mode != 0) { - - ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + 2); /*+2: the new char + \0 */ + ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + strlen(letter_buf) + 1); /*+2: the new char + \0 */ LV_ASSERT_MEM(ext->pwd_tmp); if(ext->pwd_tmp == NULL) return; From 43ed3eb1f498b7300ffb5741e6834877a26c059a Mon Sep 17 00:00:00 2001 From: Riccardo Date: Mon, 21 Dec 2020 16:13:42 +0100 Subject: [PATCH 26/31] lv_txt: support extended ascii codes in lv_txt_unicode_to_iso8859_1() (#1963) --- src/lv_misc/lv_txt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_misc/lv_txt.c b/src/lv_misc/lv_txt.c index 4afdefd55..619545367 100644 --- a/src/lv_misc/lv_txt.c +++ b/src/lv_misc/lv_txt.c @@ -794,7 +794,7 @@ static uint8_t lv_txt_iso8859_1_size(const char * str) */ static uint32_t lv_txt_unicode_to_iso8859_1(uint32_t letter_uni) { - if(letter_uni < 128) + if(letter_uni < 256) return letter_uni; else return ' '; From 091174069dddeb62cee11bc9f2299424944d03c6 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 21 Dec 2020 16:22:28 +0100 Subject: [PATCH 27/31] fix(textarea): cursor position after hiding character in password mode --- CHANGELOG.md | 1 + src/lv_widgets/lv_textarea.c | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d0fb278a..a1ebd47f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - fix(win) arabic process the title of the window - fix(dropdown) arabic process the option in lv_dropdown_add_option - fix(textarea) buffer overflow in password mode with UTF-8 characters +- fix(textarea) cursor position after hiding character in password mode ## v7.8.1 (Plannad at 15.12.2020) diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index 260905eaf..a207050ba 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -1670,6 +1670,7 @@ static void pwd_char_hider(lv_obj_t * ta) lv_label_set_text(ext->label, txt_tmp); _lv_mem_buf_release(txt_tmp); + refr_cursor_area(ta); } } From 07b6d93de4e6afaa743f8146812bccae2d4041c5 Mon Sep 17 00:00:00 2001 From: Andrey Date: Tue, 22 Dec 2020 12:44:17 +0300 Subject: [PATCH 28/31] lv_chart: Fix division by zero issue when all points are equal (#1962) * Fix division by zero issue when all points are equal As the title says, when all the points are equal, it attempts division by zero, and in some cases it can result in funny behavior. Slightly kludgy fix, but not a significant performance impact. * Actually fix the division by zero issue both ways Previous commit was slightly broken and only worked one way * Fix range setting instead of drawing * Missing y_tmp --- src/lv_widgets/lv_chart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lv_widgets/lv_chart.c b/src/lv_widgets/lv_chart.c index ceff11af2..73d85b3a0 100644 --- a/src/lv_widgets/lv_chart.c +++ b/src/lv_widgets/lv_chart.c @@ -333,7 +333,7 @@ void lv_chart_set_y_range(lv_obj_t * chart, lv_chart_axis_t axis, lv_coord_t ymi if(ext->ymin[axis] == ymin && ext->ymax[axis] == ymax) return; ext->ymin[axis] = ymin; - ext->ymax[axis] = ymax; + ext->ymax[axis] = (ymax == ymin ? ymax + 1 : ymax); lv_chart_refresh(chart); } @@ -1194,7 +1194,7 @@ static void draw_series_line(lv_obj_t * chart, const lv_area_t * series_area, co lv_coord_t p_act = start_point; lv_coord_t p_prev = start_point; int32_t y_tmp = (int32_t)((int32_t)ser->points[p_prev] - ext->ymin[ser->y_axis]) * h; - y_tmp = y_tmp / (ext->ymax[ser->y_axis] - ext->ymin[ser->y_axis]); + y_tmp = y_tmp / (ext->ymax[ser->y_axis] - ext->ymin[ser->y_axis]); p2.y = h - y_tmp + y_ofs; for(i = 0; i < ext->point_cnt; i++) { From cee779a56dde00107bb1dc1154fcc0c0f2b7f8e8 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mehrabian Date: Thu, 24 Dec 2020 00:30:02 +0330 Subject: [PATCH 29/31] Fix #1959: wrong glyph data --- src/lv_misc/lv_txt_ap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_misc/lv_txt_ap.c b/src/lv_misc/lv_txt_ap.c index 1a868ee2d..1bf68207d 100644 --- a/src/lv_misc/lv_txt_ap.c +++ b/src/lv_misc/lv_txt_ap.c @@ -69,7 +69,7 @@ const ap_chars_map_t ap_chars_map[] = { {36, 0xFEE6, 1, 2, -1, {1, 1}}, // ن {38, 0xFEEE, -1, 0, -1, {1, 0}}, // و {37, 0xFEEA, 1, 2, -1, {1, 1}}, // ه - {39, 0xFBFD, 1, 2, -1, {1, 1}}, // ي + {39, 0xFEF0, 0, 0, -1, {1, 0}}, // ى {40, 0xFEF2, 1, 2, -1, {1, 1}}, // ي {170, 0xFBFD, 1, 2, -1, {1, 1}}, // ی {7, 0xFE94, 1, 2, -1, {1, 0}}, // ة From 196bcb9b0efb30c4f12e88b72e6b20f2a9d0c362 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Thu, 24 Dec 2020 11:12:53 -0500 Subject: [PATCH 30/31] Update pull_request_template.md --- .github/pull_request_template.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 882f4644c..c53888a24 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,8 +1,8 @@ -### Description of the feature of fix +### Description of the feature or fix -A clear and concise description of what the bug is. +A clear and concise description of what the bug or new feature is. -### Chekpoints +### Checkpoints - [ ] Follow the [styling guide](https://github.com/lvgl/lvgl/blob/master/docs/CODING_STYLE.md) - [ ] Update CHANGELOG.md -- [ ] Update the docsumentation +- [ ] Update the documentation From 20d56ee6e97905f56eb71d30c9a391d4b4d7eb20 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Sun, 27 Dec 2020 05:30:59 -0500 Subject: [PATCH 31/31] fix(linemeter): draw first critical needle with correct color (#1978) * fix(linemeter): draw first critical needle with correct color * Update CHANGELOG.md --- CHANGELOG.md | 1 + src/lv_widgets/lv_linemeter.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1ebd47f5..60de130b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - fix(dropdown) arabic process the option in lv_dropdown_add_option - fix(textarea) buffer overflow in password mode with UTF-8 characters - fix(textarea) cursor position after hiding character in password mode +- fix(linemeter) draw critical lines with correct color ## v7.8.1 (Plannad at 15.12.2020) diff --git a/src/lv_widgets/lv_linemeter.c b/src/lv_widgets/lv_linemeter.c index 234fa33c0..0648b0f86 100644 --- a/src/lv_widgets/lv_linemeter.c +++ b/src/lv_widgets/lv_linemeter.c @@ -447,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; }