From f9512f55cc35371af2cf4779b3d98990d3b44f61 Mon Sep 17 00:00:00 2001 From: Deon Marais Date: Sat, 20 Jun 2020 09:08:59 +0200 Subject: [PATCH 01/19] Add missing lv_font_montserrat_34 if you do not mind me asking, and on matters of fonts why was Roboto changed to Montserrat when V7 was released ? --- src/lv_font/lv_font.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lv_font/lv_font.h b/src/lv_font/lv_font.h index cb90329bf..b319158c1 100644 --- a/src/lv_font/lv_font.h +++ b/src/lv_font/lv_font.h @@ -171,6 +171,10 @@ LV_FONT_DECLARE(lv_font_montserrat_30) LV_FONT_DECLARE(lv_font_montserrat_32) #endif +#if LV_FONT_MONTSERRAT_34 +LV_FONT_DECLARE(lv_font_montserrat_34) +#endif + #if LV_FONT_MONTSERRAT_36 LV_FONT_DECLARE(lv_font_montserrat_36) #endif From 20c46ca640690ec15e7273319cb6254cf6cbd938 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 23 Jun 2020 11:11:45 +0200 Subject: [PATCH 02/19] In lv_init test if the the strings are UTF-8 encoded --- CHANGELOG.md | 1 + src/lv_core/lv_obj.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e749bce9..1a9151416 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Add lv_btnmatrix_set/get_align capability - DMA2D: Remove dependency on ST CubeMX HAL - Added `max_used` propriety to `lv_mem_monitor_t` struct +- In `lv_init` test if the the strings are UTF-8 encoded. ### Bugfixes - None diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 211a14559..109f7eb2f 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -168,6 +168,14 @@ void lv_init(void) _lv_img_decoder_init(); lv_img_cache_set_size(LV_IMG_CACHE_DEF_SIZE); + /*Test if the IDE has UTF-8 encoding*/ + char * txt = "Á"; + + uint8_t * txt_u8 = (uint8_t *) txt; + if(txt_u8[0] != 0xc3 || txt_u8[1] != 0x81 || txt_u8[2] != 0x00) { + LV_LOG_WARN("The strings has no UTF-8 encoding. Some characters won't be displayed.") + } + lv_initialized = true; LV_LOG_INFO("lv_init ready"); } From c0223977d133d1ec41e2a364e41175f859dc97d6 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 23 Jun 2020 11:44:06 +0200 Subject: [PATCH 03/19] roller: fix misaligned option after setting new options --- src/lv_widgets/lv_roller.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lv_widgets/lv_roller.c b/src/lv_widgets/lv_roller.c index 342d85a42..8a366fd79 100644 --- a/src/lv_widgets/lv_roller.c +++ b/src/lv_widgets/lv_roller.c @@ -188,9 +188,9 @@ void lv_roller_set_options(lv_obj_t * roller, const char * options, lv_roller_mo ext->sel_opt_id_ori = ext->sel_opt_id; - // refr_width(roller); - // refr_height(roller); - refr_position(roller, LV_ANIM_OFF); + refr_height(roller); + refr_width(roller); +// refr_position(roller, LV_ANIM_OFF); } /** From 916f5b343a947ffb702adbfdbc5f165160c28554 Mon Sep 17 00:00:00 2001 From: jbamaral Date: Tue, 23 Jun 2020 09:30:33 -0300 Subject: [PATCH 04/19] Improve big endian support (#1599) --- CHANGELOG.md | 1 + src/lv_core/lv_obj.c | 17 ++- src/lv_core/lv_style.c | 205 +++++++++++++++++++++++----------- src/lv_core/lv_style.h | 11 +- src/lv_font/lv_font_fmt_txt.c | 6 +- 5 files changed, 154 insertions(+), 86 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a9151416..e5ff0aaa6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## v7.1.0 (planned on 07.07.2020) *Available in the `master` branch* +- Change some lv_style_t methods to support big endian hardware. ### New features - Add `focus_parent` attribute to `lv_obj` diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 109f7eb2f..2a1874a9e 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -2449,7 +2449,7 @@ lv_style_int_t _lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_styl lv_style_property_t prop_ori = prop; lv_style_attr_t attr; - attr.full = prop_ori >> 8; + attr = prop_ori >> 8; lv_style_int_t value_act; lv_res_t res = LV_RES_INV; @@ -2463,7 +2463,7 @@ lv_style_int_t _lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_styl res = _lv_style_list_get_int(dsc, prop, &value_act); if(res == LV_RES_OK) return value_act; - if(attr.bits.inherit == 0) break; + if(LV_STYLE_ATTR_GET_INHERIT(attr) == 0) break; /*If not found, check the `MAIN` style first*/ if(part != LV_OBJ_PART_MAIN) { @@ -2512,7 +2512,7 @@ lv_color_t _lv_obj_get_style_color(const lv_obj_t * obj, uint8_t part, lv_style_ lv_style_property_t prop_ori = prop; lv_style_attr_t attr; - attr.full = prop_ori >> 8; + attr = prop_ori >> 8; lv_color_t value_act; lv_res_t res = LV_RES_INV; @@ -2526,7 +2526,7 @@ lv_color_t _lv_obj_get_style_color(const lv_obj_t * obj, uint8_t part, lv_style_ res = _lv_style_list_get_color(dsc, prop, &value_act); if(res == LV_RES_OK) return value_act; - if(attr.bits.inherit == 0) break; + if(LV_STYLE_ATTR_GET_INHERIT(attr) == 0) break; /*If not found, check the `MAIN` style first*/ if(part != LV_OBJ_PART_MAIN) { @@ -2568,7 +2568,7 @@ lv_opa_t _lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t part, lv_style_prop lv_style_property_t prop_ori = prop; lv_style_attr_t attr; - attr.full = prop_ori >> 8; + attr = prop_ori >> 8; lv_opa_t value_act; lv_res_t res = LV_RES_INV; @@ -2582,7 +2582,7 @@ lv_opa_t _lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t part, lv_style_prop res = _lv_style_list_get_opa(dsc, prop, &value_act); if(res == LV_RES_OK) return value_act; - if(attr.bits.inherit == 0) break; + if(LV_STYLE_ATTR_GET_INHERIT(attr) == 0) break; /*If not found, check the `MAIN` style first*/ if(part != LV_OBJ_PART_MAIN) { @@ -2625,7 +2625,7 @@ const void * _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_ lv_style_property_t prop_ori = prop; lv_style_attr_t attr; - attr.full = prop_ori >> 8; + attr = prop_ori >> 8; const void * value_act; lv_res_t res = LV_RES_INV; @@ -2639,7 +2639,7 @@ const void * _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_ res = _lv_style_list_get_ptr(dsc, prop, &value_act); if(res == LV_RES_OK) return value_act; - if(attr.bits.inherit == 0) break; + if(LV_STYLE_ATTR_GET_INHERIT(attr) == 0) break; /*If not found, check the `MAIN` style first*/ if(part != LV_OBJ_PART_MAIN) { @@ -4145,4 +4145,3 @@ static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_fin return false; } - diff --git a/src/lv_core/lv_style.c b/src/lv_core/lv_style.c index b07954f4d..8d4f10531 100644 --- a/src/lv_core/lv_style.c +++ b/src/lv_core/lv_style.c @@ -36,6 +36,12 @@ **********************/ LV_ATTRIBUTE_FAST_MEM static inline int32_t get_property_index(const lv_style_t * style, lv_style_property_t prop); static lv_style_t * get_alloc_local_style(lv_style_list_t * list); +static inline void style_resize(lv_style_t *style, size_t sz); +static inline lv_style_property_t get_style_prop(const lv_style_t *style, size_t idx); +static inline uint8_t get_style_prop_id(const lv_style_t *style, size_t idx); +static inline uint8_t get_style_prop_attr(const lv_style_t *style, size_t idx); +static inline size_t get_prop_size(uint8_t prop_id); +static inline size_t get_next_prop_index(uint8_t prop_id, size_t id); /********************** * GLOABAL VARIABLES @@ -102,16 +108,12 @@ bool lv_style_remove_prop(lv_style_t * style, lv_style_property_t prop) lv_style_attr_t attr_found; lv_style_attr_t attr_goal; - attr_found.full = *(style->map + id + 1); - attr_goal.full = (prop >> 8) & 0xFFU; + attr_found = get_style_prop_attr(style, id); + attr_goal = (prop >> 8) & 0xFFU; - if(attr_found.bits.state == attr_goal.bits.state) { + if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) { uint32_t map_size = _lv_style_get_mem_size(style); - uint8_t prop_size = sizeof(lv_style_property_t); - if((prop & 0xF) < LV_STYLE_ID_COLOR) prop_size += sizeof(lv_style_int_t); - else if((prop & 0xF) < LV_STYLE_ID_OPA) prop_size += sizeof(lv_color_t); - else if((prop & 0xF) < LV_STYLE_ID_PTR) prop_size += sizeof(lv_opa_t); - else prop_size += sizeof(const void *); + uint8_t prop_size = get_prop_size(prop); /*Move the props to fill the space of the property to delete*/ uint32_t i; @@ -119,7 +121,7 @@ bool lv_style_remove_prop(lv_style_t * style, lv_style_property_t prop) style->map[i] = style->map[i + prop_size]; } - style->map = lv_mem_realloc(style->map, map_size - prop_size); + style_resize(style, map_size - prop_size); return true; } @@ -335,14 +337,9 @@ uint16_t _lv_style_get_mem_size(const lv_style_t * style) if(style->map == NULL) return 0; size_t i = 0; - while(style->map[i] != _LV_STYLE_CLOSEING_PROP) { - /*Go to the next property*/ - if((style->map[i] & 0xF) < LV_STYLE_ID_COLOR) i += sizeof(lv_style_int_t); - else if((style->map[i] & 0xF) < LV_STYLE_ID_OPA) i += sizeof(lv_color_t); - else if((style->map[i] & 0xF) < LV_STYLE_ID_PTR) i += sizeof(lv_opa_t); - else i += sizeof(const void *); - - i += sizeof(lv_style_property_t); + uint8_t prop_id; + while((prop_id = get_style_prop_id(style, i)) != _LV_STYLE_CLOSEING_PROP) { + i = get_next_prop_index(prop_id, i); } return i + sizeof(lv_style_property_t); @@ -368,10 +365,10 @@ void _lv_style_set_int(lv_style_t * style, lv_style_property_t prop, lv_style_in lv_style_attr_t attr_found; lv_style_attr_t attr_goal; - attr_found.full = *(style->map + id + 1); - attr_goal.full = (prop >> 8) & 0xFFU; + attr_found = get_style_prop_attr(style, id); + attr_goal = (prop >> 8) & 0xFFU; - if(attr_found.bits.state == attr_goal.bits.state) { + if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) { _lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &value, sizeof(lv_style_int_t)); return; } @@ -385,7 +382,7 @@ void _lv_style_set_int(lv_style_t * style, lv_style_property_t prop, lv_style_in uint16_t size = _lv_style_get_mem_size(style); if(size == 0) size += end_mark_size; size += sizeof(lv_style_property_t) + sizeof(lv_style_int_t); - style->map = lv_mem_realloc(style->map, size); + style_resize(style, size); LV_ASSERT_MEM(style->map); if(style == NULL) return; @@ -414,10 +411,10 @@ void _lv_style_set_color(lv_style_t * style, lv_style_property_t prop, lv_color_ lv_style_attr_t attr_found; lv_style_attr_t attr_goal; - attr_found.full = *(style->map + id + 1); - attr_goal.full = (prop >> 8) & 0xFFU; + attr_found = get_style_prop_attr(style, id); + attr_goal = (prop >> 8) & 0xFFU; - if(attr_found.bits.state == attr_goal.bits.state) { + if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) { _lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &color, sizeof(lv_color_t)); return; } @@ -432,7 +429,7 @@ void _lv_style_set_color(lv_style_t * style, lv_style_property_t prop, lv_color_ if(size == 0) size += end_mark_size; size += sizeof(lv_style_property_t) + sizeof(lv_color_t); - style->map = lv_mem_realloc(style->map, size); + style_resize(style, size); LV_ASSERT_MEM(style->map); if(style == NULL) return; @@ -461,10 +458,10 @@ void _lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t op lv_style_attr_t attr_found; lv_style_attr_t attr_goal; - attr_found.full = *(style->map + id + 1); - attr_goal.full = (prop >> 8) & 0xFFU; + attr_found = get_style_prop_attr(style, id); + attr_goal = (prop >> 8) & 0xFFU; - if(attr_found.bits.state == attr_goal.bits.state) { + if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) { _lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &opa, sizeof(lv_opa_t)); return; } @@ -479,7 +476,7 @@ void _lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t op if(size == 0) size += end_mark_size; size += sizeof(lv_style_property_t) + sizeof(lv_opa_t); - style->map = lv_mem_realloc(style->map, size); + style_resize(style, size); LV_ASSERT_MEM(style->map); if(style == NULL) return; @@ -508,10 +505,10 @@ void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void lv_style_attr_t attr_found; lv_style_attr_t attr_goal; - attr_found.full = *(style->map + id + 1); - attr_goal.full = (prop >> 8) & 0xFFU; + attr_found = get_style_prop_attr(style, id); + attr_goal = (prop >> 8) & 0xFFU; - if(attr_found.bits.state == attr_goal.bits.state) { + if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) { _lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &p, sizeof(const void *)); return; } @@ -526,7 +523,7 @@ void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void if(size == 0) size += end_mark_size; size += sizeof(lv_style_property_t) + sizeof(const void *); - style->map = lv_mem_realloc(style->map, size); + style_resize(style, size); LV_ASSERT_MEM(style->map); if(style == NULL) return; @@ -560,12 +557,12 @@ int16_t _lv_style_get_int(const lv_style_t * style, lv_style_property_t prop, vo else { _lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_style_int_t)); lv_style_attr_t attr_act; - attr_act.full = style->map[id + 1]; + attr_act = get_style_prop_attr(style, id + 1); lv_style_attr_t attr_goal; - attr_goal.full = (prop >> 8) & 0xFF; + attr_goal = (prop >> 8) & 0xFF; - return attr_act.bits.state & attr_goal.bits.state; + return LV_STYLE_ATTR_GET_STATE(attr_act) & LV_STYLE_ATTR_GET_STATE(attr_goal); } } @@ -597,12 +594,12 @@ int16_t _lv_style_get_opa(const lv_style_t * style, lv_style_property_t prop, vo else { _lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_opa_t)); lv_style_attr_t attr_act; - attr_act.full = style->map[id + 1]; + attr_act = get_style_prop_attr(style, id); lv_style_attr_t attr_goal; - attr_goal.full = (prop >> 8) & 0xFF; + attr_goal = (prop >> 8) & 0xFF; - return attr_act.bits.state & attr_goal.bits.state; + return LV_STYLE_ATTR_GET_STATE(attr_act) & LV_STYLE_ATTR_GET_STATE(attr_goal); } } @@ -631,12 +628,12 @@ int16_t _lv_style_get_color(const lv_style_t * style, lv_style_property_t prop, else { _lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_color_t)); lv_style_attr_t attr_act; - attr_act.full = style->map[id + 1]; + attr_act = get_style_prop_attr(style, id); lv_style_attr_t attr_goal; - attr_goal.full = (prop >> 8) & 0xFF; + attr_goal = (prop >> 8) & 0xFF; - return attr_act.bits.state & attr_goal.bits.state; + return LV_STYLE_ATTR_GET_STATE(attr_act) & LV_STYLE_ATTR_GET_STATE(attr_goal); } } @@ -666,12 +663,12 @@ int16_t _lv_style_get_ptr(const lv_style_t * style, lv_style_property_t prop, vo else { _lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(const void *)); lv_style_attr_t attr_act; - attr_act.full = style->map[id + 1]; + attr_act = get_style_prop_attr(style, id); lv_style_attr_t attr_goal; - attr_goal.full = (prop >> 8) & 0xFF; + attr_goal = (prop >> 8) & 0xFF; - return attr_act.bits.state & attr_goal.bits.state; + return LV_STYLE_ATTR_GET_STATE(attr_act) & LV_STYLE_ATTR_GET_STATE(attr_goal); } } @@ -819,8 +816,8 @@ lv_res_t _lv_style_list_get_int(lv_style_list_t * list, lv_style_property_t prop if(list->style_list == NULL) return LV_RES_INV; lv_style_attr_t attr; - attr.full = prop >> 8; - int16_t weight_goal = attr.full; + attr = prop >> 8; + int16_t weight_goal = attr; int16_t weight = -1; @@ -871,8 +868,8 @@ lv_res_t _lv_style_list_get_color(lv_style_list_t * list, lv_style_property_t pr if(list->style_list == NULL) return LV_RES_INV; lv_style_attr_t attr; - attr.full = prop >> 8; - int16_t weight_goal = attr.full; + attr = prop >> 8; + int16_t weight_goal = attr; int16_t weight = -1; @@ -921,8 +918,8 @@ lv_res_t _lv_style_list_get_opa(lv_style_list_t * list, lv_style_property_t prop if(list->style_list == NULL) return LV_RES_INV; lv_style_attr_t attr; - attr.full = prop >> 8; - int16_t weight_goal = attr.full; + attr = prop >> 8; + int16_t weight_goal = attr; int16_t weight = -1; @@ -971,8 +968,8 @@ lv_res_t _lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop if(list->style_list == NULL) return LV_RES_INV; lv_style_attr_t attr; - attr.full = prop >> 8; - int16_t weight_goal = attr.full; + attr = prop >> 8; + int16_t weight_goal = attr; int16_t weight = -1; @@ -1061,40 +1058,36 @@ LV_ATTRIBUTE_FAST_MEM static inline int32_t get_property_index(const lv_style_t uint8_t id_to_find = prop & 0xFF; lv_style_attr_t attr; - attr.full = (prop >> 8) & 0xFF; + attr = (prop >> 8) & 0xFF; int16_t weight = -1; int16_t id_guess = -1; size_t i = 0; - while(style->map[i] != _LV_STYLE_CLOSEING_PROP) { - if(style->map[i] == id_to_find) { + + uint8_t prop_id; + while((prop_id = get_style_prop_id(style, i)) != _LV_STYLE_CLOSEING_PROP) { + if(prop_id == id_to_find) { lv_style_attr_t attr_i; - attr_i.full = style->map[i + 1]; + attr_i = get_style_prop_attr(style, i); /*If the state perfectly matches return this property*/ - if(attr_i.bits.state == attr.bits.state) { + if(LV_STYLE_ATTR_GET_STATE(attr_i) == LV_STYLE_ATTR_GET_STATE(attr)) { return i; } /* Be sure the property not specifies other state than the requested. * E.g. For HOVER+PRESS, HOVER only is OK, but HOVER+FOCUS not*/ - else if((attr_i.bits.state & (~attr.bits.state)) == 0) { + else if((LV_STYLE_ATTR_GET_STATE(attr_i) & (~LV_STYLE_ATTR_GET_STATE(attr))) == 0) { /* Use this property if it describes better the requested state than the current candidate. * E.g. for HOVER+FOCUS+PRESS prefer HOVER+FOCUS over FOCUS*/ - if(attr_i.bits.state > weight) { - weight = attr_i.bits.state; + if(LV_STYLE_ATTR_GET_STATE(attr_i) > weight) { + weight = LV_STYLE_ATTR_GET_STATE(attr_i); id_guess = i; } } } - /*Go to the next property*/ - if((style->map[i] & 0xF) < LV_STYLE_ID_COLOR) i += sizeof(lv_style_int_t); - else if((style->map[i] & 0xF) < LV_STYLE_ID_OPA) i += sizeof(lv_color_t); - else if((style->map[i] & 0xF) < LV_STYLE_ID_PTR) i += sizeof(lv_opa_t); - else i += sizeof(const void *); - - i += sizeof(lv_style_property_t); + i = get_next_prop_index(prop_id, i); } return id_guess; @@ -1125,3 +1118,79 @@ static lv_style_t * get_alloc_local_style(lv_style_list_t * list) return local_style; } + +/** + * Resizes a style map. Useful entry point for debugging. + * @param style pointer to the style to be resized. + * @param size new size + */ +static inline void style_resize(lv_style_t *style, size_t sz) +{ + style->map = lv_mem_realloc(style->map, sz); +} + +/** + * Get style property in index. + * @param style pointer to style. + * @param idx index of the style in style->map + * @return property in style->map + idx + */ +static inline lv_style_property_t get_style_prop(const lv_style_t *style, size_t idx) +{ + lv_style_property_t prop; + uint8_t *prop_p = (uint8_t*)∝ + prop_p[0] = style->map[idx]; + prop_p[1] = style->map[idx + 1]; + return prop; +} + +/** + * Get style property id in index. + * @param style pointer to style. + * @param idx index of the style in style->map + * @return id of property in style->map + idx + */ +static inline uint8_t get_style_prop_id(const lv_style_t *style, size_t idx) +{ + return get_style_prop(style, idx) & 0xFF; +} + +/** + * Get style property attributes for index. + * @param style pointer to style. + * @param idx index of the style in style->map + * @return attribute of property in style->map + idx + */ +static inline uint8_t get_style_prop_attr(const lv_style_t *style, size_t idx) +{ + return ((get_style_prop(style, idx) >> 8) & 0xFFU); +} + + +/** + * Get property size. + * @param prop_id property id. + * @param idx index of the style in style->map + * @return attribute of property in style->map + idx + */ +static inline size_t get_prop_size(uint8_t prop_id) +{ + prop_id &= 0xF; + size_t size = sizeof(lv_style_property_t); + if(prop_id < LV_STYLE_ID_COLOR) size += sizeof(lv_style_int_t); + else if(prop_id < LV_STYLE_ID_OPA) size += sizeof(lv_color_t); + else if(prop_id < LV_STYLE_ID_PTR) size += sizeof(lv_opa_t); + else size += sizeof(const void *); + return size; +} + +/** + * Get next property index, given current property and index. + * @param prop_id property id. + * @param idx index of the style in style->map + * @return index of next property in style->map + */ +static inline size_t get_next_prop_index(uint8_t prop_id, size_t idx) +{ + return idx + get_prop_size(prop_id); +} diff --git a/src/lv_core/lv_style.h b/src/lv_core/lv_style.h index c17ee5ff8..aff4759e3 100644 --- a/src/lv_core/lv_style.h +++ b/src/lv_core/lv_style.h @@ -81,13 +81,10 @@ enum { typedef uint8_t lv_text_decor_t; -typedef union { - struct { - uint8_t state : 7; /* To which state the property refers to*/ - uint8_t inherit : 1; /*1: The property can be inherited*/ - } bits; - uint8_t full; -} lv_style_attr_t; +typedef uint8_t lv_style_attr_t; + +#define LV_STYLE_ATTR_GET_INHERIT(f) ((f)&0xA0) +#define LV_STYLE_ATTR_GET_STATE(f) ((f)&0x3F) #define LV_STYLE_ID_VALUE 0x0 /*max 9 pcs*/ #define LV_STYLE_ID_COLOR 0x9 /*max 3 pcs*/ diff --git a/src/lv_font/lv_font_fmt_txt.c b/src/lv_font/lv_font_fmt_txt.c index fe8e55793..731ada0e6 100644 --- a/src/lv_font/lv_font_fmt_txt.c +++ b/src/lv_font/lv_font_fmt_txt.c @@ -214,7 +214,8 @@ static uint32_t get_glyph_dsc_id(const lv_font_t * font, uint32_t letter) glyph_id = fdsc->cmaps[i].glyph_id_start + gid_ofs_8[rcp]; } else if(fdsc->cmaps[i].type == LV_FONT_FMT_TXT_CMAP_SPARSE_TINY) { - uint8_t * p = _lv_utils_bsearch(&rcp, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length, + uint16_t key = rcp; + uint8_t * p = _lv_utils_bsearch(&key, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length, sizeof(fdsc->cmaps[i].unicode_list[0]), unicode_list_compare); if(p) { @@ -224,7 +225,8 @@ static uint32_t get_glyph_dsc_id(const lv_font_t * font, uint32_t letter) } } else if(fdsc->cmaps[i].type == LV_FONT_FMT_TXT_CMAP_SPARSE_FULL) { - uint8_t * p = _lv_utils_bsearch(&rcp, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length, + uint16_t key = rcp; + uint8_t * p = _lv_utils_bsearch(&key, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length, sizeof(fdsc->cmaps[i].unicode_list[0]), unicode_list_compare); if(p) { From 8864cd87ee30201915fe0672e0ab91106128efa9 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 24 Jun 2020 10:02:45 +0200 Subject: [PATCH 05/19] lv_img: fix invalidation area when angle or zoom changes --- CHANGELOG.md | 3 ++- src/lv_widgets/lv_img.c | 10 ++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5ff0aaa6..21b5dd2e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,10 +13,11 @@ - In `lv_init` test if the the strings are UTF-8 encoded. ### Bugfixes -- None +- `lv_img` fix invalidation area when angle or zoom changes ## v7.0.2 (16.06.2020) +### Bugfixes - `lv_textarea` fix wrong cursor position when clicked after the last character - Change all text related indices from 16-bit to 32-bit integers throughout whole library. #1545 - Fix gestures diff --git a/src/lv_widgets/lv_img.c b/src/lv_widgets/lv_img.c index 08e7c2321..3acb7cab3 100644 --- a/src/lv_widgets/lv_img.c +++ b/src/lv_widgets/lv_img.c @@ -340,10 +340,9 @@ void lv_img_set_angle(lv_obj_t * img, int16_t angle) transf_zoom = (transf_zoom * ext->zoom) >> 8; lv_style_int_t transf_angle = lv_obj_get_style_transform_angle(img, LV_IMG_PART_MAIN); - transf_angle += ext->angle; lv_area_t a; - _lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle, transf_zoom, &ext->pivot); + _lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle + ext->angle, transf_zoom, &ext->pivot); a.x1 += img->coords.x1; a.y1 += img->coords.y1; a.x2 += img->coords.x1; @@ -353,7 +352,7 @@ void lv_img_set_angle(lv_obj_t * img, int16_t angle) ext->angle = angle; lv_obj_refresh_ext_draw_pad(img); - _lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle, transf_zoom, &ext->pivot); + _lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle + ext->angle, transf_zoom, &ext->pivot); a.x1 += img->coords.x1; a.y1 += img->coords.y1; a.x2 += img->coords.x1; @@ -379,13 +378,12 @@ void lv_img_set_zoom(lv_obj_t * img, uint16_t zoom) if(zoom == 0) zoom = 1; lv_style_int_t transf_zoom = lv_obj_get_style_transform_zoom(img, LV_IMG_PART_MAIN); - transf_zoom = (transf_zoom * ext->zoom) >> 8; lv_style_int_t transf_angle = lv_obj_get_style_transform_angle(img, LV_IMG_PART_MAIN); transf_angle += ext->angle; lv_area_t a; - _lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle, transf_zoom, &ext->pivot); + _lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle, (transf_zoom * ext->zoom) >> 8, &ext->pivot); a.x1 += img->coords.x1; a.y1 += img->coords.y1; a.x2 += img->coords.x1; @@ -395,7 +393,7 @@ void lv_img_set_zoom(lv_obj_t * img, uint16_t zoom) ext->zoom = zoom; lv_obj_refresh_ext_draw_pad(img); - _lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle, transf_zoom, &ext->pivot); + _lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle, (transf_zoom * ext->zoom) >> 8, &ext->pivot); a.x1 += img->coords.x1; a.y1 += img->coords.y1; a.x2 += img->coords.x1; From 4c629ec23fe9660956757565c8c1ab2646f86971 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 24 Jun 2020 10:04:30 +0200 Subject: [PATCH 06/19] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21b5dd2e8..a74983ffd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ ### Bugfixes - `lv_img` fix invalidation area when angle or zoom changes +- Update the style handling to support Big endian MCUs ## v7.0.2 (16.06.2020) From 9561aa767d63f8fe5fdbee9d12571569a94038fd Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 24 Jun 2020 10:45:32 +0200 Subject: [PATCH 07/19] style: minor fix on getting style attributes + formatting --- src/lv_core/lv_style.c | 2 +- src/lv_core/lv_style.h | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lv_core/lv_style.c b/src/lv_core/lv_style.c index 8d4f10531..1be4e3dbe 100644 --- a/src/lv_core/lv_style.c +++ b/src/lv_core/lv_style.c @@ -557,7 +557,7 @@ int16_t _lv_style_get_int(const lv_style_t * style, lv_style_property_t prop, vo else { _lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_style_int_t)); lv_style_attr_t attr_act; - attr_act = get_style_prop_attr(style, id + 1); + attr_act = get_style_prop_attr(style, id); lv_style_attr_t attr_goal; attr_goal = (prop >> 8) & 0xFF; diff --git a/src/lv_core/lv_style.h b/src/lv_core/lv_style.h index aff4759e3..5909299b6 100644 --- a/src/lv_core/lv_style.h +++ b/src/lv_core/lv_style.h @@ -83,8 +83,8 @@ typedef uint8_t lv_text_decor_t; typedef uint8_t lv_style_attr_t; -#define LV_STYLE_ATTR_GET_INHERIT(f) ((f)&0xA0) -#define LV_STYLE_ATTR_GET_STATE(f) ((f)&0x3F) +#define LV_STYLE_ATTR_GET_INHERIT(f) ((f)&0x80) +#define LV_STYLE_ATTR_GET_STATE(f) ((f)&0x7F) #define LV_STYLE_ID_VALUE 0x0 /*max 9 pcs*/ #define LV_STYLE_ID_COLOR 0x9 /*max 3 pcs*/ @@ -99,7 +99,7 @@ enum { LV_STYLE_PROP_INIT(LV_STYLE_TRANSFORM_WIDTH, 0x0, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_TRANSFORM_HEIGHT, 0x0, LV_STYLE_ID_VALUE + 5, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_TRANSFORM_ANGLE, 0x0, LV_STYLE_ID_VALUE + 6, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_TRANSFORM_ZOOM, 0x0, LV_STYLE_ID_VALUE + 7, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_TRANSFORM_ZOOM, 0x0, LV_STYLE_ID_VALUE + 7, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_OPA_SCALE, 0x0, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT), LV_STYLE_PROP_INIT(LV_STYLE_PAD_TOP, 0x1, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), @@ -134,8 +134,8 @@ enum { LV_STYLE_PROP_INIT(LV_STYLE_OUTLINE_OPA, 0x4, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_WIDTH, 0x5, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OFS_X, 0x5, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OFS_Y, 0x5, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OFS_X, 0x5, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OFS_Y, 0x5, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_SPREAD, 0x5, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_BLEND_MODE, 0x5, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_COLOR, 0x5, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE), @@ -191,12 +191,12 @@ enum { LV_STYLE_PROP_INIT(LV_STYLE_TRANSITION_PROP_6, 0xB, LV_STYLE_ID_VALUE + 7, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_TRANSITION_PATH, 0xB, LV_STYLE_ID_PTR + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCALE_WIDTH, 0xC, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_SCALE_WIDTH, 0xC, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SCALE_BORDER_WIDTH, 0xC, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_BORDER_WIDTH, 0xC, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_LINE_WIDTH, 0xC, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCALE_GRAD_COLOR, 0xC, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_COLOR, 0xC, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_LINE_WIDTH, 0xC, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_SCALE_GRAD_COLOR, 0xC, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_COLOR, 0xC, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_NONE), }; typedef uint16_t lv_style_property_t; From be19e91e91649af2552fabd156173d6f10062964 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 24 Jun 2020 11:24:07 +0200 Subject: [PATCH 08/19] fix focusing/defocusing for pages --- src/lv_core/lv_indev.c | 13 +++++++------ src/lv_core/lv_obj.c | 2 -- src/lv_widgets/lv_page.c | 14 ++++++++++---- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/lv_core/lv_indev.c b/src/lv_core/lv_indev.c index cc2c608b6..a491c0996 100644 --- a/src/lv_core/lv_indev.c +++ b/src/lv_core/lv_indev.c @@ -1183,11 +1183,6 @@ static void indev_click_focus(lv_indev_proc_t * proc) } /*The object are not in the same group (in different group or one in not a group)*/ else { - /*Focus to the act. its group*/ - if(g_act) { - lv_group_focus_obj(indev_obj_act); - if(indev_reset_check(proc)) return; - } /*If the prev. obj. is not in a group then defocus it.*/ if(g_prev == NULL && proc->types.pointer.last_pressed) { lv_signal_send(proc->types.pointer.last_pressed, LV_SIGNAL_DEFOCUS, NULL); @@ -1213,12 +1208,18 @@ static void indev_click_focus(lv_indev_proc_t * proc) if(indev_reset_check(proc)) return; } } + } + /*Focus to the act. in its group*/ + if(g_act) { + lv_group_focus_obj(indev_obj_act); + if(indev_reset_check(proc)) return; + } else { lv_signal_send(indev_obj_act, LV_SIGNAL_FOCUS, NULL); if(indev_reset_check(proc)) return; lv_event_send(indev_obj_act, LV_EVENT_FOCUSED, NULL); if(indev_reset_check(proc)) return; - } + } } #else if(proc->types.pointer.last_pressed) { diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 2a1874a9e..8c4276e94 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -3752,7 +3752,6 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param) else if(sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) { lv_obj_clear_state(obj, LV_STATE_PRESSED); } -#if LV_USE_GROUP else if(sign == LV_SIGNAL_FOCUS) { if(lv_group_get_editing(lv_obj_get_group(obj))) { uint8_t state = LV_STATE_FOCUSED; @@ -3779,7 +3778,6 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param) lv_obj_clear_state(obj, LV_STATE_FOCUSED | LV_STATE_EDITED); } -#endif else if(sign == LV_SIGNAL_CLEANUP) { lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); } diff --git a/src/lv_widgets/lv_page.c b/src/lv_widgets/lv_page.c index 31a1fef13..f8141c320 100644 --- a/src/lv_widgets/lv_page.c +++ b/src/lv_widgets/lv_page.c @@ -1054,10 +1054,16 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi } } else if(sign == LV_SIGNAL_DEFOCUS) { - res = lv_signal_send(page, LV_SIGNAL_DEFOCUS, NULL); - if(res != LV_RES_OK) return res; - res = lv_event_send(page, LV_EVENT_DEFOCUSED, NULL); - if(res != LV_RES_OK) return res; + bool in_group = false; +#if LV_USE_GROUP + in_group = lv_obj_get_group(page) ? true : false; +#endif + if(in_group == false) { + res = lv_signal_send(page, LV_SIGNAL_DEFOCUS, NULL); + if(res != LV_RES_OK) return res; + res = lv_event_send(page, LV_EVENT_DEFOCUSED, NULL); + if(res != LV_RES_OK) return res; + } } else if(sign == LV_SIGNAL_CLEANUP) { page_ext->scrl = NULL; From 42f79763e156a0e0e341db05cfd25e85817df688 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 24 Jun 2020 11:28:51 +0200 Subject: [PATCH 09/19] fix build error --- src/lv_core/lv_obj.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 8c4276e94..8e935b3b2 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -3753,7 +3753,11 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param) lv_obj_clear_state(obj, LV_STATE_PRESSED); } else if(sign == LV_SIGNAL_FOCUS) { - if(lv_group_get_editing(lv_obj_get_group(obj))) { + bool editing = false; +#if LV_USE_GROUP + editing = lv_group_get_editing(lv_obj_get_group(obj)); +#endif + if(editing) { uint8_t state = LV_STATE_FOCUSED; state |= LV_STATE_EDITED; From 63aba1b3de0fa233b09e80d465665c219d82d0ae Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 24 Jun 2020 11:36:35 +0200 Subject: [PATCH 10/19] lv_textarea fix cursor alignment with empty textarea when the text alignment is center or right --- src/lv_widgets/lv_label.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/lv_widgets/lv_label.c b/src/lv_widgets/lv_label.c index 1a71a37de..da8b6d308 100644 --- a/src/lv_widgets/lv_label.c +++ b/src/lv_widgets/lv_label.c @@ -572,10 +572,21 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint32_t char_id, lv_point_ LV_ASSERT_NULL(pos); const char * txt = lv_label_get_text(label); + lv_label_align_t align = lv_label_get_align(label); if(txt[0] == '\0') { - pos->x = 0; pos->y = 0; + switch(align) { + case LV_LABEL_ALIGN_LEFT: + pos->x = 0; + break; + case LV_LABEL_ALIGN_RIGHT: + pos->x = lv_obj_get_width(label); + break; + case LV_LABEL_ALIGN_CENTER: + pos->x = lv_obj_get_width(label) / 2; + break; + } return; } @@ -597,7 +608,6 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint32_t char_id, lv_point_ if(ext->expand != 0) flag |= LV_TXT_FLAG_EXPAND; if(ext->long_mode == LV_LABEL_LONG_EXPAND) flag |= LV_TXT_FLAG_FIT; - lv_label_align_t align = lv_label_get_align(label); if(align == LV_LABEL_ALIGN_CENTER) flag |= LV_TXT_FLAG_CENTER; if(align == LV_LABEL_ALIGN_RIGHT) flag |= LV_TXT_FLAG_RIGHT; From 2550368d30fba4f7ce1d934468d413741625d484 Mon Sep 17 00:00:00 2001 From: jbamaral Date: Tue, 23 Jun 2020 19:16:36 -0300 Subject: [PATCH 11/19] fix image demos on big endian systems --- CHANGELOG.md | 1 + lv_conf_template.h | 4 ++++ src/lv_draw/lv_img_buf.h | 22 +++++++++++++++++++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a74983ffd..783475036 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## v7.1.0 (planned on 07.07.2020) *Available in the `master` branch* - Change some lv_style_t methods to support big endian hardware. +- Add LV_BIG_ENDIAN_SYSTEM flag to lv_conf.h in order to fix displaying images on big endian systems. ### New features - Add `focus_parent` attribute to `lv_obj` diff --git a/lv_conf_template.h b/lv_conf_template.h index de2287cf4..f4cd80800 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -222,6 +222,10 @@ typedef void * lv_img_decoder_user_data_t; /*===================== * Compiler settings *====================*/ + +/* For big endian systems set to 1 */ +#define LV_BIG_ENDIAN_SYSTEM 0 + /* Define a custom attribute to `lv_tick_inc` function */ #define LV_ATTRIBUTE_TICK_INC diff --git a/src/lv_draw/lv_img_buf.h b/src/lv_draw/lv_img_buf.h index a8722cf42..4b6db2b87 100644 --- a/src/lv_draw/lv_img_buf.h +++ b/src/lv_draw/lv_img_buf.h @@ -102,10 +102,26 @@ typedef uint8_t lv_img_cf_t; /** * LVGL image header */ +/* The first 8 bit is very important to distinguish the different source types. + * For more info see `lv_img_get_src_type()` in lv_img.c + * On big endian systems the order is reversed so cf and always_zero must be at + * the end of the struct. + * */ +#if LV_BIG_ENDIAN_SYSTEM +typedef struct { + + uint32_t h : 11; /*Height of the image map*/ + uint32_t w : 11; /*Width of the image map*/ + uint32_t reserved : 2; /*Reserved to be used later*/ + uint32_t always_zero : 3; /*It the upper bits of the first byte. Always zero to look like a + non-printable character*/ + uint32_t cf : 5; /* Color format: See `lv_img_color_format_t`*/ + + +} lv_img_header_t; +#else typedef struct { - /* The first 8 bit is very important to distinguish the different source types. - * For more info see `lv_img_get_src_type()` in lv_img.c */ uint32_t cf : 5; /* Color format: See `lv_img_color_format_t`*/ uint32_t always_zero : 3; /*It the upper bits of the first byte. Always zero to look like a non-printable character*/ @@ -115,7 +131,7 @@ typedef struct { uint32_t w : 11; /*Width of the image map*/ uint32_t h : 11; /*Height of the image map*/ } lv_img_header_t; - +#endif /** Image header it is compatible with * the result from image converter utility*/ From 5f6c7743adc2b3204cadf66f0ccc097c4555efd1 Mon Sep 17 00:00:00 2001 From: jbamaral Date: Wed, 24 Jun 2020 08:38:44 -0300 Subject: [PATCH 12/19] update internal configuration --- src/lv_conf_internal.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index da8f7d8d1..70feabb8d 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -266,6 +266,11 @@ #ifndef LV_USE_GPU_STM32_DMA2D #define LV_USE_GPU_STM32_DMA2D 0 #endif +/*If enabling LV_USE_GPU_STM32_DMA2D, LV_GPU_DMA2D_CMSIS_INCLUDE must be defined to include path of CMSIS header of target processor +e.g. "stm32f769xx.h" or "stm32f429xx.h" */ +#ifndef LV_GPU_DMA2D_CMSIS_INCLUDE +#define LV_GPU_DMA2D_CMSIS_INCLUDE +#endif /* 1: Enable file system (might be required for images */ #ifndef LV_USE_FILESYSTEM @@ -319,6 +324,12 @@ /*===================== * Compiler settings *====================*/ + +/* For big endian systems set to 1 */ +#ifndef LV_BIG_ENDIAN_SYSTEM +#define LV_BIG_ENDIAN_SYSTEM 0 +#endif + /* Define a custom attribute to `lv_tick_inc` function */ #ifndef LV_ATTRIBUTE_TICK_INC #define LV_ATTRIBUTE_TICK_INC @@ -474,7 +485,7 @@ /* The built-in fonts contains the ASCII range and some Symbols with 4 bit-per-pixel. * The symbols are available via `LV_SYMBOL_...` defines - * More info about fonts: https://docs.lvgl.com/#Fonts + * More info about fonts: https://docs.lvgl.io/v7/en/html/overview/font.html * To create a new font go to: https://lvgl.com/ttf-font-to-c-array */ @@ -684,14 +695,14 @@ #define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3 #endif -/* The control character to use for signaling text recoloring. */ +/* The control character to use for signalling text recoloring. */ #ifndef LV_TXT_COLOR_CMD #define LV_TXT_COLOR_CMD "#" #endif /* Support bidirectional texts. * Allows mixing Left-to-Right and Right-to-Left texts. - * The direction will be processed according to the Unicode Bidirectional Algorithm: + * The direction will be processed according to the Unicode Bidirectioanl Algorithm: * https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ #ifndef LV_USE_BIDI #define LV_USE_BIDI 0 From 1733508e9a03b1140fa3527dd611b2687ee6f004 Mon Sep 17 00:00:00 2001 From: jbamaral Date: Wed, 24 Jun 2020 10:01:42 -0300 Subject: [PATCH 13/19] move bug logs to their right position in changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 783475036..6bc4dda0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,6 @@ ## v7.1.0 (planned on 07.07.2020) *Available in the `master` branch* -- Change some lv_style_t methods to support big endian hardware. -- Add LV_BIG_ENDIAN_SYSTEM flag to lv_conf.h in order to fix displaying images on big endian systems. ### New features - Add `focus_parent` attribute to `lv_obj` @@ -16,6 +14,8 @@ ### Bugfixes - `lv_img` fix invalidation area when angle or zoom changes - Update the style handling to support Big endian MCUs +- Change some methods to support big endian hardware. +- Add LV_BIG_ENDIAN_SYSTEM flag to lv_conf.h in order to fix displaying images on big endian systems. ## v7.0.2 (16.06.2020) From b77d484a2773d072922acce611c8307740cac14b Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Wed, 24 Jun 2020 12:25:16 -0400 Subject: [PATCH 14/19] Fix #1610: don't assert an expected null pointer --- src/lv_widgets/lv_list.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lv_widgets/lv_list.c b/src/lv_widgets/lv_list.c index afcafecbb..d7b502db1 100644 --- a/src/lv_widgets/lv_list.c +++ b/src/lv_widgets/lv_list.c @@ -462,7 +462,6 @@ lv_obj_t * lv_list_get_next_btn(const lv_obj_t * list, lv_obj_t * prev_btn) */ int32_t lv_list_get_btn_index(const lv_obj_t * list, const lv_obj_t * btn) { - LV_ASSERT_OBJ(list, LV_OBJX_NAME); LV_ASSERT_OBJ(btn, "lv_btn"); int index = 0; @@ -470,6 +469,8 @@ int32_t lv_list_get_btn_index(const lv_obj_t * list, const lv_obj_t * btn) /* no list provided, assuming btn is part of a list */ list = lv_obj_get_parent(lv_obj_get_parent(btn)); } + LV_ASSERT_OBJ(list, LV_OBJX_NAME); + lv_obj_t * e = lv_list_get_next_btn(list, NULL); while(e != NULL) { if(e == btn) { From 859f72eb842a6692df3e62d9888936f82c721078 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 25 Jun 2020 06:19:42 +0200 Subject: [PATCH 15/19] add user_data to themes --- CHANGELOG.md | 1 + src/lv_themes/lv_theme.h | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a74983ffd..56dbb54ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - DMA2D: Remove dependency on ST CubeMX HAL - Added `max_used` propriety to `lv_mem_monitor_t` struct - In `lv_init` test if the the strings are UTF-8 encoded. +- Add `user_data` to themes ### Bugfixes - `lv_img` fix invalidation area when angle or zoom changes diff --git a/src/lv_themes/lv_theme.h b/src/lv_themes/lv_theme.h index 7b4f65b3d..d01b5d160 100644 --- a/src/lv_themes/lv_theme.h +++ b/src/lv_themes/lv_theme.h @@ -155,6 +155,7 @@ typedef struct { const lv_font_t * font_subtitle; const lv_font_t * font_title; uint32_t flags; + lv_theme_user_data_t user_data; } lv_theme_t; /********************** From 52cca1dd9b953d5d4116d825ea0ed49152217801 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 25 Jun 2020 06:38:17 +0200 Subject: [PATCH 16/19] use void * as theme user data for backward compatibility --- src/lv_themes/lv_theme.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_themes/lv_theme.h b/src/lv_themes/lv_theme.h index d01b5d160..35e644c0e 100644 --- a/src/lv_themes/lv_theme.h +++ b/src/lv_themes/lv_theme.h @@ -155,7 +155,7 @@ typedef struct { const lv_font_t * font_subtitle; const lv_font_t * font_title; uint32_t flags; - lv_theme_user_data_t user_data; + void * user_data; } lv_theme_t; /********************** From 3761db65e08c06a0b943d9f7521d2ae760abf2fa Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Thu, 25 Jun 2020 07:32:45 -0400 Subject: [PATCH 17/19] Fix spelling issue --- src/lv_conf_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index 70feabb8d..8b389a355 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -702,7 +702,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 #define LV_USE_BIDI 0 From ac7527fecfa18c1ebd467b1cf16b3f19a148d5e9 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 26 Jun 2020 09:39:19 +0200 Subject: [PATCH 18/19] minor optimization in lv_obj_init_draw_img_dsc --- src/lv_core/lv_obj.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 8e935b3b2..9259d3325 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -3298,8 +3298,9 @@ void lv_obj_init_draw_img_dsc(lv_obj_t * obj, uint8_t part, lv_draw_img_dsc_t * draw_dsc->pivot.y = lv_area_get_height(&obj->coords) / 2; draw_dsc->recolor_opa = lv_obj_get_style_image_recolor_opa(obj, part); - draw_dsc->recolor = lv_obj_get_style_image_recolor(obj, part); - + if(draw_dsc->recolor_opa > 0) { + draw_dsc->recolor = lv_obj_get_style_image_recolor(obj, part); + } #if LV_USE_BLEND_MODES draw_dsc->blend_mode = lv_obj_get_style_image_blend_mode(obj, part); #endif From 6056bc3b956cf56b9aba9f01f317927398567b5f Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 26 Jun 2020 14:35:30 +0200 Subject: [PATCH 19/19] clraify the tricky loop in lv_tick_get --- src/lv_hal/lv_hal_tick.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lv_hal/lv_hal_tick.c b/src/lv_hal/lv_hal_tick.c index a62ed7383..afdceb077 100644 --- a/src/lv_hal/lv_hal_tick.c +++ b/src/lv_hal/lv_hal_tick.c @@ -29,7 +29,7 @@ * STATIC VARIABLES **********************/ static uint32_t sys_time = 0; -static volatile uint8_t tick_irq_flag; +static volatile uint32_t tick_irq_flag; /********************** * MACROS @@ -56,12 +56,17 @@ LV_ATTRIBUTE_TICK_INC void lv_tick_inc(uint32_t tick_period) uint32_t lv_tick_get(void) { #if LV_TICK_CUSTOM == 0 + + /* If `lv_tick_inc` is called from an interrupt while `sys_time` is read + * the result might be corrupted. + * This loop detects if `lv_tick_inc` was called while reading `sys_time`. + * If `tick_irq_flag` was cleared in `lv_tick_inc` try to read again + * until `tick_irq_flag` remains `1`. */ uint32_t result; do { tick_irq_flag = 1; result = sys_time; - } while(!tick_irq_flag); /*'lv_tick_inc()' clears this flag which can be in an interrupt. - Continue until make a non interrupted cycle */ + } while(!tick_irq_flag); /*Continue until see a non interrupted cycle */ return result; #else