From 4479a22696f21a2531c1475ff3970e878cb82801 Mon Sep 17 00:00:00 2001 From: Johannes Bauer Date: Mon, 23 Sep 2019 16:11:41 +0200 Subject: [PATCH 1/7] Fixed outdated filename in README.md (#1201) Template header file has been renamed from lv_conf_templ.h to lv_conf_template.h; reflect that change in the README.md. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d07a5b680..2881caf85 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ You can use the [Simulators](https://docs.littlevgl.com/en/html/get-started/pc-s 1. [Download](https://littlevgl.com/download) or [Clone](https://github.com/littlevgl/lvgl) the library 2. Copy the `lvgl` folder into your project -3. Copy `lvgl/lv_conf_templ.h` as `lv_conf.h` next to the `lvgl` folder and set at least `LV_HOR_RES_MAX`, `LV_VER_RES_MAX` and `LV_COLOR_DEPTH`. +3. Copy `lvgl/lv_conf_template.h` as `lv_conf.h` next to the `lvgl` folder and set at least `LV_HOR_RES_MAX`, `LV_VER_RES_MAX` and `LV_COLOR_DEPTH`. 4. Include `lvgl/lvgl.h` where you need to use LittlevGL related functions. 5. Call `lv_tick_inc(x)` every `x` milliseconds **in a Timer or Task** (`x` should be between 1 and 10). It is required for the internal timing of LittlevGL. 6. Call `lv_init()` From 3aac71b16e4f4c9bda982153dc7a819ded8683bd Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 27 Sep 2019 09:10:26 +0200 Subject: [PATCH 2/7] lv_btnm: fix row positions --- src/lv_objx/lv_btnm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_objx/lv_btnm.c b/src/lv_objx/lv_btnm.c index cf3b882ae..3c517d1f3 100644 --- a/src/lv_objx/lv_btnm.c +++ b/src/lv_objx/lv_btnm.c @@ -241,7 +241,7 @@ void lv_btnm_set_map(const lv_obj_t * btnm, const char * map[]) btn_i++; } } - act_y += btn_h + style_bg->body.padding.inner; + act_y += btn_h + style_bg->body.padding.inner + 1; if(strlen(map_p_tmp[btn_cnt]) == 0) break; /*Break on end of map*/ map_p_tmp = &map_p_tmp[btn_cnt + 1]; /*Set the map to the next line*/ From a35a79ba4ef78f5b131f504e9274cd2eb076101b Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 30 Sep 2019 06:21:18 +0200 Subject: [PATCH 3/7] lv_img: fix caching when image source changes --- src/lv_objx/lv_img.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lv_objx/lv_img.c b/src/lv_objx/lv_img.c index 3b034d392..648a18683 100644 --- a/src/lv_objx/lv_img.c +++ b/src/lv_objx/lv_img.c @@ -159,15 +159,20 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img) } else if(src_type == LV_IMG_SRC_FILE || src_type == LV_IMG_SRC_SYMBOL) { /* If the new and the old src are the same then it was only a refresh.*/ if(ext->src != src_img) { - /*If memory was allocated because of the previous `src_type` then free it*/ + const void * old_src = NULL; + /* If memory was allocated because of the previous `src_type` then save its pointer and free after allocation. + * It's important to allocate first to be sure the new data will be on a new address. + * Else `img_cache` wouldn't see the change in source.*/ if(ext->src_type == LV_IMG_SRC_FILE || ext->src_type == LV_IMG_SRC_SYMBOL) { - lv_mem_free(ext->src); + old_src = ext->src; } char * new_str = lv_mem_alloc(strlen(src_img) + 1); lv_mem_assert(new_str); if(new_str == NULL) return; strcpy(new_str, src_img); ext->src = new_str; + + if(old_src) lv_mem_free(old_src); } } From a5de64f93c5bd74cd8ae3230d21ae2974dbff597 Mon Sep 17 00:00:00 2001 From: HappyTime <939763442@qq.com> Date: Mon, 30 Sep 2019 16:56:47 +0800 Subject: [PATCH 4/7] fixed comment error. --- src/lv_hal/lv_hal_disp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_hal/lv_hal_disp.c b/src/lv_hal/lv_hal_disp.c index 9e97e6b37..41211eee4 100644 --- a/src/lv_hal/lv_hal_disp.c +++ b/src/lv_hal/lv_hal_disp.c @@ -137,7 +137,7 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver) disp->act_scr = lv_obj_create(NULL, NULL); /*Create a default screen on the display*/ disp->top_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/ - disp->sys_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/ + disp->sys_layer = lv_obj_create(NULL, NULL); /*Create sys layer on the display*/ lv_obj_set_style(disp->top_layer, &lv_style_transp); lv_obj_set_style(disp->sys_layer, &lv_style_transp); From c190374c79945733415cec2e2c4937a63227d3da Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 30 Sep 2019 11:56:38 +0200 Subject: [PATCH 5/7] img_cache: store the filename instead of its pointer --- src/lv_draw/lv_img_cache.c | 12 +++++++++++- src/lv_draw/lv_img_decoder.c | 14 +++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/lv_draw/lv_img_cache.c b/src/lv_draw/lv_img_cache.c index eab900c8e..64da19bdf 100644 --- a/src/lv_draw/lv_img_cache.c +++ b/src/lv_draw/lv_img_cache.c @@ -7,6 +7,8 @@ * INCLUDES *********************/ #include "lv_img_cache.h" +#include "lv_img_decoder.h" +#include "lv_draw_img.h" #include "../lv_hal/lv_hal_tick.h" #include "../lv_misc/lv_gc.h" @@ -79,7 +81,15 @@ lv_img_cache_entry_t * lv_img_cache_open(const void * src, const lv_style_t * st /*Is the image cached?*/ lv_img_cache_entry_t * cached_src = NULL; for(i = 0; i < entry_cnt; i++) { - if(cache[i].dec_dsc.src == src) { + bool match = false; + lv_img_src_t src_type = lv_img_src_get_type(cache[i].dec_dsc.src); + if(src_type == LV_IMG_SRC_VARIABLE) { + if(cache[i].dec_dsc.src == src) match = true; + } else if(src_type == LV_IMG_SRC_FILE) { + if(strcmp(cache[i].dec_dsc.src, src) == 0) match = true; + } + + if(match) { /* If opened increment its life. * Image difficult to open should live longer to keep avoid frequent their recaching. * Therefore increase `life` with `time_to_open`*/ diff --git a/src/lv_draw/lv_img_decoder.c b/src/lv_draw/lv_img_decoder.c index 730739c16..ae71818cc 100644 --- a/src/lv_draw/lv_img_decoder.c +++ b/src/lv_draw/lv_img_decoder.c @@ -118,10 +118,17 @@ lv_res_t lv_img_decoder_get_info(const char * src, lv_img_header_t * header) lv_res_t lv_img_decoder_open(lv_img_decoder_dsc_t * dsc, const void * src, const lv_style_t * style) { dsc->style = style; - dsc->src = src; dsc->src_type = lv_img_src_get_type(src); dsc->user_data = NULL; + if(dsc->src_type == LV_IMG_SRC_FILE) { + uint16_t fnlen = strlen(src); + dsc->src = lv_mem_alloc(fnlen + 1); + strcpy((char *)dsc->src, src); + } else { + dsc->src = src; + } + lv_res_t res = LV_RES_INV; lv_img_decoder_t * d; @@ -175,6 +182,11 @@ void lv_img_decoder_close(lv_img_decoder_dsc_t * dsc) { if(dsc->decoder) { if(dsc->decoder->close_cb) dsc->decoder->close_cb(dsc->decoder, dsc); + + if(dsc->src_type == LV_IMG_SRC_FILE) { + lv_mem_free(dsc->src); + dsc->src = NULL; + } } } From 6d52976a168856246f64b56311b9c50ae2a44834 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 3 Oct 2019 05:48:38 +0200 Subject: [PATCH 6/7] update (re-generate) lv_font_unscii_8 --- src/lv_font/lv_font_unscii_8.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/lv_font/lv_font_unscii_8.c b/src/lv_font/lv_font_unscii_8.c index e86727cf9..ec41576ba 100644 --- a/src/lv_font/lv_font_unscii_8.c +++ b/src/lv_font/lv_font_unscii_8.c @@ -1,4 +1,4 @@ -#include "../../lvgl.h" +#include "lvgl/lvgl.h" /******************************************************************************* * Size: 8 px @@ -311,7 +311,7 @@ static LV_ATTRIBUTE_LARGE_CONST const uint8_t gylph_bitmap[] = { * GLYPH DESCRIPTION *--------------------*/ -static lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = { +static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = { {.bitmap_index = 0, .adv_w = 0, .box_h = 0, .box_w = 0, .ofs_x = 0, .ofs_y = 0} /* id = 0 reserved */, {.bitmap_index = 0, .adv_w = 128, .box_h = 0, .box_w = 0, .ofs_x = 0, .ofs_y = 0}, {.bitmap_index = 0, .adv_w = 128, .box_h = 7, .box_w = 1, .ofs_x = 3, .ofs_y = -1}, @@ -460,4 +460,3 @@ lv_font_t lv_font_unscii_8 = { }; #endif /*#if LV_FONT_UNSCII_8*/ - From dab042fe061bed54443b38e02da3fcdc22e865db Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 3 Oct 2019 05:54:21 +0200 Subject: [PATCH 7/7] fix lv_font_unscii_8 include --- src/lv_font/lv_font_unscii_8.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_font/lv_font_unscii_8.c b/src/lv_font/lv_font_unscii_8.c index ec41576ba..1b96823e8 100644 --- a/src/lv_font/lv_font_unscii_8.c +++ b/src/lv_font/lv_font_unscii_8.c @@ -1,4 +1,4 @@ -#include "lvgl/lvgl.h" +#include "../../lvgl.h" /******************************************************************************* * Size: 8 px