diff --git a/lv_conf_template.h b/lv_conf_template.h index 84b622d3cd..30df1144c2 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -56,7 +56,7 @@ /* Dot Per Inch: used to initialize default sizes. * E.g. a button with width = LV_DPI / 2 -> half inch wide * (Not so important, you can adjust it to modify default sizes and spaces)*/ -#define LV_DPI 100 /*[px]*/ +#define LV_DPI 130 /*[px]*/ /* The the real width of the display changes some default values: * default object sizes, layout of examples, etc. @@ -65,9 +65,9 @@ * The 4th is extra large which has no upper limit so not listed here * The upper limit of the categories are set below in 0.1 inch unit. */ -#define LV_DISP_SMALL_LIMIT 20 -#define LV_DISP_MEDIUM_LIMIT 45 -#define LV_DISP_LARGE_LIMIT 65 +#define LV_DISP_SMALL_LIMIT 30 +#define LV_DISP_MEDIUM_LIMIT 50 +#define LV_DISP_LARGE_LIMIT 70 /* Type of coordinates. Should be `int16_t` (or `int32_t` for extreme cases) */ typedef int16_t lv_coord_t; diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index f6e741260b..ba77fc14f2 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -86,7 +86,7 @@ * E.g. a button with width = LV_DPI / 2 -> half inch wide * (Not so important, you can adjust it to modify default sizes and spaces)*/ #ifndef LV_DPI -#define LV_DPI 100 /*[px]*/ +#define LV_DPI 130 /*[px]*/ #endif /* The the real width of the display changes some default values: @@ -97,13 +97,13 @@ * The upper limit of the categories are set below in 0.1 inch unit. */ #ifndef LV_DISP_SMALL_LIMIT -#define LV_DISP_SMALL_LIMIT 20 +#define LV_DISP_SMALL_LIMIT 30 #endif #ifndef LV_DISP_MEDIUM_LIMIT -#define LV_DISP_MEDIUM_LIMIT 45 +#define LV_DISP_MEDIUM_LIMIT 50 #endif #ifndef LV_DISP_LARGE_LIMIT -#define LV_DISP_LARGE_LIMIT 65 +#define LV_DISP_LARGE_LIMIT 70 #endif /* Type of coordinates. Should be `int16_t` (or `int32_t` for extreme cases) */ diff --git a/src/lv_core/lv_debug.c b/src/lv_core/lv_debug.c index 8f0191892f..5eb7e72019 100644 --- a/src/lv_core/lv_debug.c +++ b/src/lv_core/lv_debug.c @@ -160,7 +160,7 @@ void lv_debug_log_error(const char * msg, uint64_t value) char * bufp = buf; /*Add the function name*/ - memcpy(bufp, msg, msg_len); + lv_memcpy(bufp, msg, msg_len); bufp += msg_len; /*Add value in hey*/ diff --git a/src/lv_core/lv_disp.h b/src/lv_core/lv_disp.h index e095d8cafa..91c34d4bcd 100644 --- a/src/lv_core/lv_disp.h +++ b/src/lv_core/lv_disp.h @@ -152,7 +152,7 @@ static inline void lv_scr_load(lv_obj_t * scr) * 1 dip is 2 px on a 320 DPI screen * https://stackoverflow.com/questions/2025282/what-is-the-difference-between-px-dip-dp-and-sp */ -#define LV_DPX(n) LV_MATH_MAX(((LV_DPI * (n)) / 160), 1) +#define LV_DPX(n) LV_MATH_MAX(((LV_DPI * (n) + 80) / 160), 1) /*+80 for rounding*/ #ifdef __cplusplus } /* extern "C" */ diff --git a/src/lv_core/lv_group.c b/src/lv_core/lv_group.c index 4edbabf5d3..8f1a01f466 100644 --- a/src/lv_core/lv_group.c +++ b/src/lv_core/lv_group.c @@ -73,7 +73,7 @@ lv_group_t * lv_group_create(void) group->wrap = 1; #if LV_USE_USER_DATA - memset(&group->user_data, 0, sizeof(lv_group_user_data_t)); + lv_memset_00(&group->user_data, sizeof(lv_group_user_data_t)); #endif return group; @@ -303,28 +303,6 @@ lv_res_t lv_group_send_data(lv_group_t * group, uint32_t c) return res; } -/** - * Set a function for a group which will modify the object's style if it is in focus - * @param group pointer to a group - * @param style_mod_cb the style modifier function pointer - */ -void lv_group_set_style_mod_cb(lv_group_t * group, lv_group_style_mod_cb_t style_mod_cb) -{ - group->style_mod_cb = style_mod_cb; - if(group->obj_focus != NULL) lv_obj_invalidate(*group->obj_focus); -} - -/** - * Set a function for a group which will modify the object's style if it is in focus in edit mode - * @param group pointer to a group - * @param style_mod_func the style modifier function pointer - */ -void lv_group_set_style_mod_edit_cb(lv_group_t * group, lv_group_style_mod_cb_t style_mod_edit_cb) -{ - group->style_mod_edit_cb = style_mod_edit_cb; - if(group->obj_focus != NULL) lv_obj_invalidate(*group->obj_focus); -} - /** * Set a function for a group which will be called when a new object is focused * @param group pointer to a group @@ -342,6 +320,7 @@ void lv_group_set_focus_cb(lv_group_t * group, lv_group_focus_cb_t focus_cb) */ void lv_group_set_editing(lv_group_t * group, bool edit) { + if(group == NULL) return; uint8_t en_val = edit ? 1 : 0; if(en_val == group->editing) return; /*Do not set the same mode again*/ @@ -383,26 +362,6 @@ void lv_group_set_wrap(lv_group_t * group, bool en) group->wrap = en ? 1 : 0; } -/** - * Modify a style with the set 'style_mod' function. The input style remains unchanged. - * @param group pointer to group - * @param style pointer to a style to modify - * @return a copy of the input style but modified with the 'style_mod' function - */ -lv_style_t * lv_group_mod_style(lv_group_t * group, const lv_style_t * style) -{ - /*Load the current style. It will be modified by the callback*/ - lv_style_copy(&group->style_tmp, style); - - if(group->editing) { - if(group->style_mod_edit_cb) group->style_mod_edit_cb(group, &group->style_tmp); - } - else { - if(group->style_mod_cb) group->style_mod_cb(group, &group->style_tmp); - } - return &group->style_tmp; -} - /** * Get the focused object or NULL if there isn't one * @param group pointer to a group @@ -428,28 +387,6 @@ lv_group_user_data_t * lv_group_get_user_data(lv_group_t * group) } #endif -/** - * Get a the style modifier function of a group - * @param group pointer to a group - * @return pointer to the style modifier function - */ -lv_group_style_mod_cb_t lv_group_get_style_mod_cb(const lv_group_t * group) -{ - if(!group) return NULL; - return group->style_mod_cb; -} - -/** - * Get a the style modifier function of a group in edit mode - * @param group pointer to a group - * @return pointer to the style modifier function - */ -lv_group_style_mod_cb_t lv_group_get_style_mod_edit_cb(const lv_group_t * group) -{ - if(!group) return NULL; - return group->style_mod_edit_cb; -} - /** * Get the focus callback function of a group * @param group pointer to a group diff --git a/src/lv_core/lv_group.h b/src/lv_core/lv_group.h index 68dc237070..aa32b503a1 100644 --- a/src/lv_core/lv_group.h +++ b/src/lv_core/lv_group.h @@ -55,10 +55,7 @@ typedef struct _lv_group_t { lv_ll_t obj_ll; /**< Linked list to store the objects in the group */ lv_obj_t ** obj_focus; /**< The object in focus*/ - lv_group_style_mod_cb_t style_mod_cb; /**< A function to modifies the style of the focused object*/ - lv_group_style_mod_cb_t style_mod_edit_cb; /**< A function which modifies the style of the edited object*/ lv_group_focus_cb_t focus_cb; /**< A function to call when a new object is focused (optional)*/ - lv_style_t style_tmp; /**< Stores the modified style of the focused object */ #if LV_USE_USER_DATA lv_group_user_data_t user_data; #endif diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 76d7ca9540..bd67344f87 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -209,7 +209,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy) LV_ASSERT_MEM(new_obj); if(new_obj == NULL) return NULL; - memset(new_obj, 0x00, sizeof(lv_obj_t)); + lv_memset_00(new_obj, sizeof(lv_obj_t)); #if LV_USE_BIDI new_obj->base_dir = LV_BIDI_BASE_DIR_DEF; @@ -232,7 +232,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy) LV_ASSERT_MEM(new_obj); if(new_obj == NULL) return NULL; - memset(new_obj, 0x00, sizeof(lv_obj_t)); + lv_memset_00(new_obj, sizeof(lv_obj_t)); new_obj->parent = parent; @@ -265,7 +265,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy) new_obj->ext_draw_pad = 0; #if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL - memset(&new_obj->ext_click_pad, 0, sizeof(new_obj->ext_click_pad)); + lv_memset_00(&new_obj->ext_click_pad, sizeof(new_obj->ext_click_pad)); #elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY new_obj->ext_click_pad_hor = 0; new_obj->ext_click_pad_ver = 0; @@ -282,7 +282,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy) /*Init. user date*/ #if LV_USE_USER_DATA - memset(&new_obj->user_data, 0, sizeof(lv_obj_user_data_t)); + lv_memset_00(&new_obj->user_data, sizeof(lv_obj_user_data_t)); #endif @@ -328,7 +328,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy) /*Set user data*/ #if LV_USE_USER_DATA - memcpy(&new_obj->user_data, ©->user_data, sizeof(lv_obj_user_data_t)); + lv_memcpy(&new_obj->user_data, ©->user_data, sizeof(lv_obj_user_data_t)); #endif /*Copy realign*/ @@ -800,9 +800,35 @@ void lv_obj_set_height(lv_obj_t * obj, lv_coord_t h) lv_obj_set_size(obj, lv_obj_get_width(obj), h); } +/** + * Set the width reduced by the left and right padding. + * @param obj pointer to an object + * @param w the width without paddings + */ +void lv_obj_set_width_fit(const lv_obj_t * obj, lv_coord_t w) +{ + lv_style_int_t pleft = lv_obj_get_style_pad_left(obj, LV_OBJ_PART_MAIN); + lv_style_int_t pright = lv_obj_get_style_pad_right(obj, LV_OBJ_PART_MAIN); + + lv_obj_set_width(obj, w - pleft - pright); +} + +/** + * Set the height reduced by the top and bottom padding. + * @param obj pointer to an object + * @param h the height without paddings + */ +void lv_obj_set_height_fit(const lv_obj_t * obj, lv_coord_t h) +{ + lv_style_int_t ptop = lv_obj_get_style_pad_top(obj, LV_OBJ_PART_MAIN); + lv_style_int_t pbottom = lv_obj_get_style_pad_bottom(obj, LV_OBJ_PART_MAIN); + + lv_obj_set_width(obj, h - ptop - pbottom); +} + /** * Set the width of an object by taking the left and right margin into account. - * The object heigwidthht will be `obj_w = w - margon_left - margin_right` + * The object width will be `obj_w = w - margon_left - margin_right` * @param obj pointer to an object * @param w new height including margins */ @@ -834,10 +860,10 @@ void lv_obj_set_height_margin(lv_obj_t * obj, lv_coord_t h) * @param obj pointer to an object to align * @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it. * @param align type of alignment (see 'lv_align_t' enum) - * @param x_mod x coordinate shift after alignment - * @param y_mod y coordinate shift after alignment + * @param x_ofs x coordinate offset after alignment + * @param y_ofs y coordinate offset after alignment */ -void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod) +void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs) { LV_ASSERT_OBJ(obj, LV_OBJX_NAME); @@ -852,8 +878,8 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co lv_obj_t * par = lv_obj_get_parent(obj); lv_coord_t par_abs_x = par->coords.x1; lv_coord_t par_abs_y = par->coords.y1; - new_pos.x += x_mod; - new_pos.y += y_mod; + new_pos.x += x_ofs; + new_pos.y += y_ofs; new_pos.x -= par_abs_x; new_pos.y -= par_abs_y; @@ -862,8 +888,8 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co #if LV_USE_OBJ_REALIGN /*Save the last align parameters to use them in `lv_obj_realign`*/ obj->realign.align = align; - obj->realign.xofs = x_mod; - obj->realign.yofs = y_mod; + obj->realign.xofs = x_ofs; + obj->realign.yofs = y_ofs; obj->realign.base = base; obj->realign.origo_align = 0; #endif @@ -874,10 +900,10 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co * @param obj pointer to an object to align * @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it. * @param align type of alignment (see 'lv_align_t' enum) - * @param x_mod x coordinate shift after alignment - * @param y_mod y coordinate shift after alignment + * @param x_ofs x coordinate offset after alignment + * @param y_ofs y coordinate offset after alignment */ -void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod) +void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs) { LV_ASSERT_OBJ(obj, LV_OBJX_NAME); @@ -1005,8 +1031,8 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t base_abs_y = base->coords.y1; lv_coord_t par_abs_x = par->coords.x1; lv_coord_t par_abs_y = par->coords.y1; - new_x += x_mod + base_abs_x; - new_y += y_mod + base_abs_y; + new_x += x_ofs + base_abs_x; + new_y += y_ofs + base_abs_y; new_x -= par_abs_x; new_y -= par_abs_y; @@ -1015,8 +1041,8 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, #if LV_USE_OBJ_REALIGN /*Save the last align parameters to use them in `lv_obj_realign`*/ obj->realign.align = align; - obj->realign.xofs = x_mod; - obj->realign.yofs = y_mod; + obj->realign.xofs = x_ofs; + obj->realign.yofs = y_ofs; obj->realign.base = base; obj->realign.origo_align = 1; #endif @@ -1267,7 +1293,7 @@ bool _lv_obj_remove_style_local_prop(lv_obj_t * obj, uint8_t part, lv_style_prop /** * Notify an object (and its children) about its style is modified * @param obj pointer to an object - * @param prop `LV_STYLE_PROP_ALL` or an `LV_STYLE_...` property. It is used the optimize what needs to be refreshed. + * @param prop `LV_STYLE_PROP_ALL` or an `LV_STYLE_...` property. It is used to optimize what needs to be refreshed. */ void lv_obj_refresh_style(lv_obj_t * obj, lv_style_property_t prop) { @@ -2825,8 +2851,8 @@ void lv_obj_get_type(const lv_obj_t * obj, lv_obj_type_t * buf) lv_obj_type_t tmp; - memset(buf, 0, sizeof(lv_obj_type_t)); - memset(&tmp, 0, sizeof(lv_obj_type_t)); + lv_memset_00(buf, sizeof(lv_obj_type_t)); + lv_memset_00(&tmp, sizeof(lv_obj_type_t)); obj->signal_cb((lv_obj_t *)obj, LV_SIGNAL_GET_TYPE, &tmp); @@ -2877,7 +2903,7 @@ void lv_obj_set_user_data(lv_obj_t * obj, lv_obj_user_data_t data) { LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - memcpy(&obj->user_data, &data, sizeof(lv_obj_user_data_t)); + lv_memcpy(&obj->user_data, &data, sizeof(lv_obj_user_data_t)); } #endif diff --git a/src/lv_core/lv_obj.h b/src/lv_core/lv_obj.h index ce38eca208..385119a6e2 100644 --- a/src/lv_core/lv_obj.h +++ b/src/lv_core/lv_obj.h @@ -426,9 +426,23 @@ void lv_obj_set_width(lv_obj_t * obj, lv_coord_t w); */ void lv_obj_set_height(lv_obj_t * obj, lv_coord_t h); +/** + * Set the width reduced by the left and right padding. + * @param obj pointer to an object + * @param w the width without paddings + */ +void lv_obj_set_width_fit(const lv_obj_t * obj, lv_coord_t w); + +/** + * Set the height reduced by the top and bottom padding. + * @param obj pointer to an object + * @param h the height without paddings + */ +void lv_obj_set_height_fit(const lv_obj_t * obj, lv_coord_t h); + /** * Set the width of an object by taking the left and right margin into account. - * The object heigwidthht will be `obj_w = w - margon_left - margin_right` + * The object width will be `obj_w = w - margon_left - margin_right` * @param obj pointer to an object * @param w new height including margins */ @@ -447,20 +461,20 @@ void lv_obj_set_height_margin(lv_obj_t * obj, lv_coord_t h); * @param obj pointer to an object to align * @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it. * @param align type of alignment (see 'lv_align_t' enum) - * @param x_mod x coordinate shift after alignment - * @param y_mod y coordinate shift after alignment + * @param x_ofs x coordinate offset after alignment + * @param y_ofs y coordinate offset after alignment */ -void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod); +void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs); /** * Align an object to an other object. * @param obj pointer to an object to align * @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it. * @param align type of alignment (see 'lv_align_t' enum) - * @param x_mod x coordinate shift after alignment - * @param y_mod y coordinate shift after alignment + * @param x_ofs x coordinate offset after alignment + * @param y_ofs y coordinate offset after alignment */ -void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod); +void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs); /** * Realign the object based on the last `lv_obj_align` parameters. @@ -520,8 +534,9 @@ void lv_obj_clean_style_list(lv_obj_t * obj, uint8_t part); void lv_obj_reset_style_list(lv_obj_t * obj, uint8_t part); /** - * Notify an object about its style is modified + * Notify an object (and its children) about its style is modified * @param obj pointer to an object + * @param prop `LV_STYLE_PROP_ALL` or an `LV_STYLE_...` property. It is used to optimize what needs to be refreshed. */ void lv_obj_refresh_style(lv_obj_t * obj, lv_style_property_t prop); diff --git a/src/lv_core/lv_refr.c b/src/lv_core/lv_refr.c index addfff02ec..42e8583abf 100644 --- a/src/lv_core/lv_refr.c +++ b/src/lv_core/lv_refr.c @@ -225,7 +225,7 @@ void lv_disp_refr_task(lv_task_t * task) uint32_t line_length = lv_area_get_width(&disp_refr->inv_areas[a]) * sizeof(lv_color_t); for(y = disp_refr->inv_areas[a].y1; y <= disp_refr->inv_areas[a].y2; y++) { - memcpy(buf_act + start_offs, buf_ina + start_offs, line_length); + lv_memcpy(buf_act + start_offs, buf_ina + start_offs, line_length); start_offs += hres * sizeof(lv_color_t); } } diff --git a/src/lv_core/lv_style.c b/src/lv_core/lv_style.c index 64abf6784e..f264495d14 100644 --- a/src/lv_core/lv_style.c +++ b/src/lv_core/lv_style.c @@ -60,7 +60,7 @@ static lv_style_t * get_alloc_local_style(lv_style_list_t * list); */ void lv_style_init(lv_style_t * style) { - memset(style, 0x00, sizeof(lv_style_t)); + lv_memset_00(style, sizeof(lv_style_t)); #if LV_USE_ASSERT_STYLE style->sentinel = LV_DEBUG_STYLE_SENTINEL_VALUE; #endif @@ -82,7 +82,7 @@ void lv_style_copy(lv_style_t * style_dest, const lv_style_t * style_src) uint16_t size = lv_style_get_mem_size(style_src); style_dest->map = lv_mem_alloc(size); - memcpy(style_dest->map, style_src->map, size); + lv_memcpy(style_dest->map, style_src->map, size); } /** @@ -135,7 +135,7 @@ bool lv_style_remove_prop(lv_style_t * style, lv_style_property_t prop) */ void lv_style_list_init(lv_style_list_t * list) { - memset(list, 0x00, sizeof(lv_style_list_t)); + lv_memset_00(list, sizeof(lv_style_list_t)); #if LV_USE_ASSERT_STYLE list->sentinel = LV_DEBUG_STYLE_LIST_SENTINEL_VALUE; #endif @@ -159,24 +159,24 @@ void lv_style_list_copy(lv_style_list_t * list_dest, const lv_style_list_t * lis if(list_src->has_local == 0) { if(list_src->has_trans) { list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 1) * sizeof(lv_style_t *)); - memcpy(list_dest->style_list, list_src->style_list + 1, (list_src->style_cnt - 1) * sizeof(lv_style_t *)); + lv_memcpy(list_dest->style_list, list_src->style_list + 1, (list_src->style_cnt - 1) * sizeof(lv_style_t *)); list_dest->style_cnt = list_src->style_cnt - 1; } else { list_dest->style_list = lv_mem_alloc(list_src->style_cnt * sizeof(lv_style_t *)); - memcpy(list_dest->style_list, list_src->style_list, list_src->style_cnt * sizeof(lv_style_t *)); + lv_memcpy(list_dest->style_list, list_src->style_list, list_src->style_cnt * sizeof(lv_style_t *)); list_dest->style_cnt = list_src->style_cnt; } } else { if(list_src->has_trans) { list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 2) * sizeof(lv_style_t *)); - memcpy(list_dest->style_list, list_src->style_list + 2, (list_src->style_cnt - 2) * sizeof(lv_style_t *)); + lv_memcpy(list_dest->style_list, list_src->style_list + 2, (list_src->style_cnt - 2) * sizeof(lv_style_t *)); list_dest->style_cnt = list_src->style_cnt - 2; } else { list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 1) * sizeof(lv_style_t *)); - memcpy(list_dest->style_list, list_src->style_list + 1, (list_src->style_cnt - 1) * sizeof(lv_style_t *)); + lv_memcpy(list_dest->style_list, list_src->style_list + 1, (list_src->style_cnt - 1) * sizeof(lv_style_t *)); list_dest->style_cnt = list_src->style_cnt - 1; } @@ -373,7 +373,7 @@ void _lv_style_set_int(lv_style_t * style, lv_style_property_t prop, lv_style_in attr_goal.full = (prop >> 8) & 0xFFU; if(attr_found.bits.state == attr_goal.bits.state) { - memcpy(style->map + id + sizeof(lv_style_property_t), &value, sizeof(lv_style_int_t)); + lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &value, sizeof(lv_style_int_t)); return; } } @@ -390,9 +390,9 @@ void _lv_style_set_int(lv_style_t * style, lv_style_property_t prop, lv_style_in LV_ASSERT_MEM(style->map); if(style == NULL) return; - memcpy(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t)); - memcpy(style->map + size - sizeof(lv_style_int_t) - end_mark_size, &value, sizeof(lv_style_int_t)); - memcpy(style->map + size - end_mark_size, &end_mark, sizeof(end_mark)); + lv_memcpy_small(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t)); + lv_memcpy_small(style->map + size - sizeof(lv_style_int_t) - end_mark_size, &value, sizeof(lv_style_int_t)); + lv_memcpy_small(style->map + size - end_mark_size, &end_mark, sizeof(end_mark)); } /** @@ -419,7 +419,7 @@ void _lv_style_set_color(lv_style_t * style, lv_style_property_t prop, lv_color_ attr_goal.full = (prop >> 8) & 0xFFU; if(attr_found.bits.state == attr_goal.bits.state) { - memcpy(style->map + id + sizeof(lv_style_property_t), &color, sizeof(lv_color_t)); + lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &color, sizeof(lv_color_t)); return; } } @@ -437,9 +437,9 @@ void _lv_style_set_color(lv_style_t * style, lv_style_property_t prop, lv_color_ LV_ASSERT_MEM(style->map); if(style == NULL) return; - memcpy(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t)); - memcpy(style->map + size - sizeof(lv_color_t) - end_mark_size, &color, sizeof(lv_color_t)); - memcpy(style->map + size - end_mark_size, &end_mark, sizeof(end_mark)); + lv_memcpy_small(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t)); + lv_memcpy_small(style->map + size - sizeof(lv_color_t) - end_mark_size, &color, sizeof(lv_color_t)); + lv_memcpy_small(style->map + size - end_mark_size, &end_mark, sizeof(end_mark)); } /** @@ -466,7 +466,7 @@ void _lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t op attr_goal.full = (prop >> 8) & 0xFFU; if(attr_found.bits.state == attr_goal.bits.state) { - memcpy(style->map + id + sizeof(lv_style_property_t), &opa, sizeof(lv_opa_t)); + lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &opa, sizeof(lv_opa_t)); return; } } @@ -484,9 +484,9 @@ void _lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t op LV_ASSERT_MEM(style->map); if(style == NULL) return; - memcpy(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t)); - memcpy(style->map + size - sizeof(lv_opa_t) - end_mark_size, &opa, sizeof(lv_opa_t)); - memcpy(style->map + size - end_mark_size, &end_mark, sizeof(end_mark)); + lv_memcpy_small(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t)); + lv_memcpy_small(style->map + size - sizeof(lv_opa_t) - end_mark_size, &opa, sizeof(lv_opa_t)); + lv_memcpy_small(style->map + size - end_mark_size, &end_mark, sizeof(end_mark)); } /** @@ -513,7 +513,7 @@ void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, _lv_style_f attr_goal.full = (prop >> 8) & 0xFFU; if(attr_found.bits.state == attr_goal.bits.state) { - memcpy(style->map + id + sizeof(lv_style_property_t), &p, sizeof(_lv_style_fptr_dptr_t)); + lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &p, sizeof(_lv_style_fptr_dptr_t)); return; } } @@ -531,9 +531,9 @@ void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, _lv_style_f LV_ASSERT_MEM(style->map); if(style == NULL) return; - memcpy(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t)); - memcpy(style->map + size - sizeof(_lv_style_fptr_dptr_t) - end_mark_size, &p, sizeof(_lv_style_fptr_dptr_t)); - memcpy(style->map + size - end_mark_size, &end_mark, sizeof(end_mark)); + lv_memcpy_small(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t)); + lv_memcpy_small(style->map + size - sizeof(_lv_style_fptr_dptr_t) - end_mark_size, &p, sizeof(_lv_style_fptr_dptr_t)); + lv_memcpy_small(style->map + size - end_mark_size, &end_mark, sizeof(end_mark)); } /** @@ -559,7 +559,7 @@ int16_t _lv_style_get_int(const lv_style_t * style, lv_style_property_t prop, vo return -1; } else { - memcpy(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_style_int_t)); + 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]; @@ -596,7 +596,7 @@ int16_t _lv_style_get_opa(const lv_style_t * style, lv_style_property_t prop, vo return -1; } else { - memcpy(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_opa_t)); + 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]; @@ -630,7 +630,7 @@ int16_t _lv_style_get_color(const lv_style_t * style, lv_style_property_t prop, return -1; } else { - memcpy(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_color_t)); + 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]; @@ -665,7 +665,7 @@ int16_t _lv_style_get_ptr(const lv_style_t * style, lv_style_property_t prop, vo return -1; } else { - memcpy(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(_lv_style_fptr_dptr_t)); + lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(_lv_style_fptr_dptr_t)); lv_style_attr_t attr_act; attr_act.full = style->map[id + 1]; diff --git a/src/lv_draw/lv_draw_img.c b/src/lv_draw/lv_draw_img.c index 294e33f97b..e9ab8f584f 100644 --- a/src/lv_draw/lv_draw_img.c +++ b/src/lv_draw/lv_draw_img.c @@ -48,7 +48,7 @@ static void show_error(const lv_area_t * coords, const lv_area_t * clip_area, co void lv_draw_img_dsc_init(lv_draw_img_dsc_t * dsc) { - memset(dsc, 0x00, sizeof(lv_draw_img_dsc_t)); + lv_memset_00(dsc, sizeof(lv_draw_img_dsc_t)); dsc->recolor = LV_COLOR_BLACK; dsc->opa = LV_OPA_COVER; dsc->zoom = LV_IMG_ZOOM_NONE; diff --git a/src/lv_draw/lv_draw_label.c b/src/lv_draw/lv_draw_label.c index a7e7bf2edc..53d9975d2c 100644 --- a/src/lv_draw/lv_draw_label.c +++ b/src/lv_draw/lv_draw_label.c @@ -82,7 +82,7 @@ static const uint8_t bpp8_opa_table[256] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc) { - memset(dsc, 0x00, sizeof(lv_draw_label_dsc_t)); + lv_memset_00(dsc, sizeof(lv_draw_label_dsc_t)); dsc->opa = LV_OPA_COVER; dsc->color = LV_COLOR_BLACK; dsc->font = LV_THEME_DEFAULT_FONT_NORMAL; @@ -275,7 +275,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab /*Get the parameter*/ if(i - par_start == LABEL_RECOLOR_PAR_LENGTH + 1) { char buf[LABEL_RECOLOR_PAR_LENGTH + 1]; - memcpy(buf, &bidi_txt[par_start], LABEL_RECOLOR_PAR_LENGTH); + lv_memcpy_small(buf, &bidi_txt[par_start], LABEL_RECOLOR_PAR_LENGTH); buf[LABEL_RECOLOR_PAR_LENGTH] = '\0'; int r, g, b; r = (hex_char_to_num(buf[0]) << 4) + hex_char_to_num(buf[1]); diff --git a/src/lv_draw/lv_draw_line.c b/src/lv_draw/lv_draw_line.c index 803bb3dd41..b842979ba9 100644 --- a/src/lv_draw/lv_draw_line.c +++ b/src/lv_draw/lv_draw_line.c @@ -45,7 +45,7 @@ static void draw_line_ver(const lv_point_t * point1, const lv_point_t * point2, void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc) { - memset(dsc, 0x00, sizeof(lv_draw_line_dsc_t)); + lv_memset_00(dsc, sizeof(lv_draw_line_dsc_t)); dsc->width = 1; dsc->opa = LV_OPA_COVER; dsc->color = LV_COLOR_BLACK; diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index d8fcc9316e..377490b342 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -59,7 +59,7 @@ static int32_t sh_cache_r = -1; void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc) { - memset(dsc, 0x00, sizeof(lv_draw_rect_dsc_t)); + lv_memset_00(dsc, sizeof(lv_draw_rect_dsc_t)); dsc->bg_color = LV_COLOR_WHITE; dsc->bg_grad_color = LV_COLOR_BLACK; dsc->border_color = LV_COLOR_BLACK; diff --git a/src/lv_draw/lv_img_buf.c b/src/lv_draw/lv_img_buf.c index 5a02f5f46b..b82fbe5afb 100644 --- a/src/lv_draw/lv_img_buf.c +++ b/src/lv_draw/lv_img_buf.c @@ -59,7 +59,7 @@ lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) { uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3; uint32_t px = dsc->header.w * y * px_size + x * px_size; - memcpy(&p_color, &buf_u8[px], sizeof(lv_color_t)); + lv_memcpy_small(&p_color, &buf_u8[px], sizeof(lv_color_t)); #if LV_COLOR_SIZE == 32 p_color.ch.alpha = 0xFF; /*Only the color should be get so use a deafult alpha value*/ #endif @@ -246,12 +246,12 @@ void lv_img_buf_set_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_ if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR || dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) { uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3; uint32_t px = dsc->header.w * y * px_size + x * px_size; - memcpy(&buf_u8[px], &c, px_size); + lv_memcpy_small(&buf_u8[px], &c, px_size); } else if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) { uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3; uint32_t px = dsc->header.w * y * px_size + x * px_size; - memcpy(&buf_u8[px], &c, px_size - 1); /*-1 to not overwrite the alpha value*/ + lv_memcpy_small(&buf_u8[px], &c, px_size - 1); /*-1 to not overwrite the alpha value*/ } else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT) { buf_u8 += sizeof(lv_color32_t) * 2; /*Skip the palette*/ @@ -319,7 +319,7 @@ void lv_img_buf_set_palette(lv_img_dsc_t * dsc, uint8_t id, lv_color_t c) lv_color32_t c32; c32.full = lv_color_to32(c); uint8_t * buf = (uint8_t *)dsc->data; - memcpy(&buf[id * sizeof(c32)], &c32, sizeof(c32)); + lv_memcpy_small(&buf[id * sizeof(c32)], &c32, sizeof(c32)); } /** @@ -507,12 +507,12 @@ bool lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_t x, lv_coord_t px_size = LV_COLOR_SIZE >> 3; pxi = dsc->cfg.src_w * ys_int * px_size + xs_int * px_size; - memcpy(&dsc->res.color, &src_u8[pxi], px_size); + lv_memcpy_small(&dsc->res.color, &src_u8[pxi], px_size); } else { px_size = LV_IMG_PX_SIZE_ALPHA_BYTE; pxi = dsc->cfg.src_w * ys_int * px_size + xs_int * px_size; - memcpy(&dsc->res.color, &src_u8[pxi], px_size - 1); + lv_memcpy_small(&dsc->res.color, &src_u8[pxi], px_size - 1); dsc->res.opa = src_u8[pxi + px_size - 1]; } } @@ -669,9 +669,9 @@ static inline bool transform_anti_alias(lv_img_transform_dsc_t * dsc) lv_opa_t a11 = 0; if(dsc->tmp.native_color) { - memcpy(&c01, &src_u8[dsc->tmp.pxi + dsc->tmp.px_size * xn], sizeof(lv_color_t)); - memcpy(&c10, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn], sizeof(lv_color_t)); - memcpy(&c11, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn + dsc->tmp.px_size * xn], + lv_memcpy_small(&c01, &src_u8[dsc->tmp.pxi + dsc->tmp.px_size * xn], sizeof(lv_color_t)); + lv_memcpy_small(&c10, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn], sizeof(lv_color_t)); + lv_memcpy_small(&c11, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn + dsc->tmp.px_size * xn], sizeof(lv_color_t)); if(dsc->tmp.has_alpha) { a10 = src_u8[dsc->tmp.pxi + dsc->tmp.px_size * xn + dsc->tmp.px_size - 1]; diff --git a/src/lv_draw/lv_img_cache.c b/src/lv_draw/lv_img_cache.c index eab868aaca..ff1dff9f8e 100644 --- a/src/lv_draw/lv_img_cache.c +++ b/src/lv_draw/lv_img_cache.c @@ -130,8 +130,8 @@ lv_img_cache_entry_t * lv_img_cache_open(const void * src, lv_color_t 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); - memset(&cached_src->dec_dsc, 0, sizeof(lv_img_decoder_dsc_t)); - memset(cached_src, 0, sizeof(lv_img_cache_entry_t)); + 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; } @@ -175,8 +175,8 @@ void lv_img_cache_set_size(uint16_t new_entry_cnt) /*Clean the cache*/ uint16_t i; for(i = 0; i < entry_cnt; i++) { - memset(&LV_GC_ROOT(_lv_img_cache_array)[i].dec_dsc, 0, sizeof(lv_img_decoder_dsc_t)); - memset(&LV_GC_ROOT(_lv_img_cache_array)[i], 0, sizeof(lv_img_cache_entry_t)); + 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)); } } @@ -197,8 +197,8 @@ void lv_img_cache_invalidate_src(const void * src) lv_img_decoder_close(&cache[i].dec_dsc); } - memset(&cache[i].dec_dsc, 0, sizeof(lv_img_decoder_dsc_t)); - memset(&cache[i], 0, sizeof(lv_img_cache_entry_t)); + lv_memset_00(&cache[i].dec_dsc, sizeof(lv_img_decoder_dsc_t)); + lv_memset_00(&cache[i], sizeof(lv_img_cache_entry_t)); } } } diff --git a/src/lv_draw/lv_img_decoder.c b/src/lv_draw/lv_img_decoder.c index 74171a8928..45633001c6 100644 --- a/src/lv_draw/lv_img_decoder.c +++ b/src/lv_draw/lv_img_decoder.c @@ -151,7 +151,7 @@ lv_res_t lv_img_decoder_open(lv_img_decoder_dsc_t * dsc, const void * src, lv_co } if(res == LV_RES_INV) { - memset(dsc, 0, sizeof(lv_img_decoder_dsc_t)); + lv_memset_00(dsc, sizeof(lv_img_decoder_dsc_t)); } return res; @@ -201,7 +201,7 @@ lv_img_decoder_t * lv_img_decoder_create(void) LV_ASSERT_MEM(decoder); if(decoder == NULL) return NULL; - memset(decoder, 0, sizeof(lv_img_decoder_t)); + lv_memset_00(decoder, sizeof(lv_img_decoder_t)); return decoder; } @@ -341,7 +341,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder LV_LOG_ERROR("img_decoder_built_in_open: out of memory"); return LV_RES_INV; } - memset(dsc->user_data, 0, sizeof(lv_img_decoder_built_in_data_t)); + lv_memset_00(dsc->user_data, sizeof(lv_img_decoder_built_in_data_t)); } lv_img_decoder_built_in_data_t * user_data = dsc->user_data; @@ -353,7 +353,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder return LV_RES_INV; } - memcpy(user_data->f, &f, sizeof(f)); + lv_memcpy_small(user_data->f, &f, sizeof(f)); #else LV_LOG_WARN("Image built-in decoder cannot read file because LV_USE_FILESYSTEM = 0"); @@ -399,7 +399,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder lv_img_decoder_built_in_close(decoder, dsc); return LV_RES_INV; } - memset(dsc->user_data, 0, sizeof(lv_img_decoder_built_in_data_t)); + lv_memset_00(dsc->user_data, sizeof(lv_img_decoder_built_in_data_t)); } lv_img_decoder_built_in_data_t * user_data = dsc->user_data; diff --git a/src/lv_font/lv_font.mk b/src/lv_font/lv_font.mk index 458ae9bd8a..f861104aac 100644 --- a/src/lv_font/lv_font.mk +++ b/src/lv_font/lv_font.mk @@ -6,7 +6,7 @@ CSRCS += lv_font_montserrat_16.c CSRCS += lv_font_montserrat_18.c CSRCS += lv_font_montserrat_20.c CSRCS += lv_font_montserrat_22.c -CSRCS += lv_font_montserrat_14.c +CSRCS += lv_font_montserrat_24.c CSRCS += lv_font_montserrat_26.c CSRCS += lv_font_montserrat_28.c CSRCS += lv_font_montserrat_30.c diff --git a/src/lv_hal/lv_hal_disp.c b/src/lv_hal/lv_hal_disp.c index 92f629919e..757293fce1 100644 --- a/src/lv_hal/lv_hal_disp.c +++ b/src/lv_hal/lv_hal_disp.c @@ -56,7 +56,7 @@ static lv_disp_t * disp_def; */ void lv_disp_drv_init(lv_disp_drv_t * driver) { - memset(driver, 0, sizeof(lv_disp_drv_t)); + lv_memset_00(driver, sizeof(lv_disp_drv_t)); driver->flush_cb = NULL; driver->hor_res = LV_HOR_RES_MAX; @@ -103,7 +103,7 @@ void lv_disp_drv_init(lv_disp_drv_t * driver) */ void lv_disp_buf_init(lv_disp_buf_t * disp_buf, void * buf1, void * buf2, uint32_t size_in_px_cnt) { - memset(disp_buf, 0, sizeof(lv_disp_buf_t)); + lv_memset_00(disp_buf, sizeof(lv_disp_buf_t)); disp_buf->buf1 = buf1; disp_buf->buf2 = buf2; @@ -125,9 +125,9 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver) return NULL; } - memcpy(&disp->driver, driver, sizeof(lv_disp_drv_t)); - memset(&disp->inv_area_joined, 0, sizeof(disp->inv_area_joined)); - memset(&disp->inv_areas, 0, sizeof(disp->inv_areas)); + lv_memcpy(&disp->driver, driver, sizeof(lv_disp_drv_t)); + lv_memset_00(&disp->inv_area_joined, sizeof(disp->inv_area_joined)); + lv_memset_00(&disp->inv_areas, sizeof(disp->inv_areas)); lv_ll_init(&disp->scr_ll, sizeof(lv_obj_t)); disp->last_activity_time = 0; diff --git a/src/lv_hal/lv_hal_indev.c b/src/lv_hal/lv_hal_indev.c index 57fef191ee..8b2159d250 100644 --- a/src/lv_hal/lv_hal_indev.c +++ b/src/lv_hal/lv_hal_indev.c @@ -51,7 +51,7 @@ */ void lv_indev_drv_init(lv_indev_drv_t * driver) { - memset(driver, 0, sizeof(lv_indev_drv_t)); + lv_memset_00(driver, sizeof(lv_indev_drv_t)); driver->type = LV_INDEV_TYPE_NONE; driver->drag_limit = LV_INDEV_DEF_DRAG_LIMIT; @@ -84,8 +84,8 @@ lv_indev_t * lv_indev_drv_register(lv_indev_drv_t * driver) return NULL; } - memset(indev, 0, sizeof(lv_indev_t)); - memcpy(&indev->driver, driver, sizeof(lv_indev_drv_t)); + lv_memset_00(indev, sizeof(lv_indev_t)); + lv_memcpy(&indev->driver, driver, sizeof(lv_indev_drv_t)); indev->proc.reset_query = 1; indev->cursor = NULL; @@ -131,7 +131,7 @@ bool lv_indev_read(lv_indev_t * indev, lv_indev_data_t * data) { bool cont = false; - memset(data, 0, sizeof(lv_indev_data_t)); + lv_memset_00(data, sizeof(lv_indev_data_t)); /* For touchpad sometimes users don't the last pressed coordinate on release. * So be sure a coordinates are initialized to the last point */ diff --git a/src/lv_misc/lv_anim.c b/src/lv_misc/lv_anim.c index cb46da69eb..5eb33197de 100644 --- a/src/lv_misc/lv_anim.c +++ b/src/lv_misc/lv_anim.c @@ -77,7 +77,7 @@ void lv_anim_core_init(void) */ void lv_anim_init(lv_anim_t * a) { - memset(a, 0, sizeof(lv_anim_t)); + lv_memset_00(a, sizeof(lv_anim_t)); a->time = 500; a->start = 0; a->end = 100; @@ -107,7 +107,7 @@ void lv_anim_start(lv_anim_t * a) /*Initialize the animation descriptor*/ a->time_orig = a->time; - memcpy(new_anim, a, sizeof(lv_anim_t)); + lv_memcpy(new_anim, a, sizeof(lv_anim_t)); /*Set the start value*/ if(new_anim->early_apply) { @@ -502,7 +502,7 @@ static bool anim_ready_handler(lv_anim_t * a) /*Create copy from the animation and delete the animation from the list. * This way the `ready_cb` will see the animations like it's animation is ready deleted*/ lv_anim_t a_tmp; - memcpy(&a_tmp, a, sizeof(lv_anim_t)); + lv_memcpy(&a_tmp, a, sizeof(lv_anim_t)); lv_ll_remove(&LV_GC_ROOT(_lv_anim_ll), a); lv_mem_free(a); /*Flag that the list has changed */ diff --git a/src/lv_misc/lv_area.h b/src/lv_misc/lv_area.h index aa6de6fa60..17f7b03747 100644 --- a/src/lv_misc/lv_area.h +++ b/src/lv_misc/lv_area.h @@ -17,6 +17,7 @@ extern "C" { #include #include #include +#include "lv_mem.h" /********************* * DEFINES @@ -98,7 +99,7 @@ void lv_area_set(lv_area_t * area_p, lv_coord_t x1, lv_coord_t y1, lv_coord_t x2 */ inline static void lv_area_copy(lv_area_t * dest, const lv_area_t * src) { - memcpy(dest, src, sizeof(lv_area_t)); + lv_memcpy_small(dest, src, sizeof(lv_area_t)); } /** diff --git a/src/lv_misc/lv_bidi.c b/src/lv_misc/lv_bidi.c index 4b959f8a54..370d11a74e 100644 --- a/src/lv_misc/lv_bidi.c +++ b/src/lv_misc/lv_bidi.c @@ -311,7 +311,7 @@ void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len if(rd) { if(base_dir == LV_BIDI_DIR_LTR) { if(str_out) { - memcpy(&str_out[wr], str_in, rd); + lv_memcpy(&str_out[wr], str_in, rd); wr += rd; } if(pos_conv_out) { @@ -334,7 +334,7 @@ void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len if(base_dir == LV_BIDI_DIR_LTR) { if(run_dir == LV_BIDI_DIR_LTR) { - if(str_out) memcpy(&str_out[wr], &str_in[rd], run_len); + if(str_out) lv_memcpy(&str_out[wr], &str_in[rd], run_len); if(pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_run_len, pos_conv_rd); } else rtl_reverse(str_out ? &str_out[wr] : NULL, &str_in[rd], run_len, pos_conv_out ? &pos_conv_out[pos_conv_wr] : NULL, @@ -346,7 +346,7 @@ void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len wr -= run_len; pos_conv_wr -= pos_conv_run_len; if(run_dir == LV_BIDI_DIR_LTR) { - if(str_out) memcpy(&str_out[wr], &str_in[rd], run_len); + if(str_out) lv_memcpy(&str_out[wr], &str_in[rd], run_len); if(pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_run_len, pos_conv_rd); } else rtl_reverse(str_out ? &str_out[wr] : NULL, &str_in[rd], run_len, pos_conv_out ? &pos_conv_out[pos_conv_wr] : NULL, @@ -523,7 +523,7 @@ static void rtl_reverse(char * dest, const char * src, uint32_t len, uint16_t * pos_conv_first_weak = 0; } - if(dest) memcpy(&dest[wr], &src[first_weak], last_weak - first_weak + 1); + if(dest) lv_memcpy(&dest[wr], &src[first_weak], last_weak - first_weak + 1); if(pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_last_weak - pos_conv_first_weak + 1, pos_conv_rd_base + pos_conv_first_weak); wr += last_weak - first_weak + 1; @@ -543,7 +543,7 @@ static void rtl_reverse(char * dest, const char * src, uint32_t len, uint16_t * } /*Just store the letter*/ else { - if(dest) memcpy(&dest[wr], &src[i], letter_size); + if(dest) lv_memcpy(&dest[wr], &src[i], letter_size); if(pos_conv_out) pos_conv_out[pos_conv_wr] = SET_RTL_POS(pos_conv_rd_base + pos_conv_i, true); wr += letter_size; pos_conv_wr++; diff --git a/src/lv_misc/lv_fs.c b/src/lv_misc/lv_fs.c index 7a156a638b..5070d5d7ba 100644 --- a/src/lv_misc/lv_fs.c +++ b/src/lv_misc/lv_fs.c @@ -475,7 +475,7 @@ lv_fs_res_t lv_fs_free_space(char letter, uint32_t * total_p, uint32_t * free_p) */ void lv_fs_drv_init(lv_fs_drv_t * drv) { - memset(drv, 0, sizeof(lv_fs_drv_t)); + lv_memset_00(drv, sizeof(lv_fs_drv_t)); } /** @@ -491,7 +491,7 @@ void lv_fs_drv_register(lv_fs_drv_t * drv_p) LV_ASSERT_MEM(new_drv); if(new_drv == NULL) return; - memcpy(new_drv, drv_p, sizeof(lv_fs_drv_t)); + lv_memcpy(new_drv, drv_p, sizeof(lv_fs_drv_t)); } /** diff --git a/src/lv_misc/lv_gc.c b/src/lv_misc/lv_gc.c index 0d568ec4ad..2ce1fa0508 100644 --- a/src/lv_misc/lv_gc.c +++ b/src/lv_misc/lv_gc.c @@ -44,7 +44,7 @@ void lv_gc_clear_roots(void) { -#define LV_CLEAR_ROOT(root_type, root_name) memset(&LV_GC_ROOT(root_name), 0, sizeof(LV_GC_ROOT(root_name))); +#define LV_CLEAR_ROOT(root_type, root_name) lv_memset_00(&LV_GC_ROOT(root_name), sizeof(LV_GC_ROOT(root_name))); LV_ITERATE_ROOTS(LV_CLEAR_ROOT) } diff --git a/src/lv_misc/lv_ll.c b/src/lv_misc/lv_ll.c index c53afe7137..c48fb67d89 100644 --- a/src/lv_misc/lv_ll.c +++ b/src/lv_misc/lv_ll.c @@ -299,7 +299,7 @@ void * lv_ll_get_next(const lv_ll_t * ll_p, const void * n_act) if(ll_p != NULL) { const lv_ll_node_t * n_act_d = n_act; - memcpy(&next, n_act_d + LL_NEXT_P_OFFSET(ll_p), sizeof(void *)); + lv_memcpy_small(&next, n_act_d + LL_NEXT_P_OFFSET(ll_p), sizeof(void *)); } return next; @@ -317,7 +317,7 @@ void * lv_ll_get_prev(const lv_ll_t * ll_p, const void * n_act) if(ll_p != NULL) { const lv_ll_node_t * n_act_d = n_act; - memcpy(&prev, n_act_d + LL_PREV_P_OFFSET(ll_p), sizeof(void *)); + lv_memcpy_small(&prev, n_act_d + LL_PREV_P_OFFSET(ll_p), sizeof(void *)); } return prev; @@ -404,9 +404,9 @@ static void node_set_prev(lv_ll_t * ll_p, lv_ll_node_t * act, lv_ll_node_t * pre uint32_t node_p_size = sizeof(lv_ll_node_t *); if(prev) - memcpy(act + LL_PREV_P_OFFSET(ll_p), &prev, node_p_size); + lv_memcpy_small(act + LL_PREV_P_OFFSET(ll_p), &prev, node_p_size); else - memset(act + LL_PREV_P_OFFSET(ll_p), 0, node_p_size); + lv_memset_00(act + LL_PREV_P_OFFSET(ll_p), node_p_size); } /** @@ -421,7 +421,7 @@ static void node_set_next(lv_ll_t * ll_p, lv_ll_node_t * act, lv_ll_node_t * nex uint32_t node_p_size = sizeof(lv_ll_node_t *); if(next) - memcpy(act + LL_NEXT_P_OFFSET(ll_p), &next, node_p_size); + lv_memcpy_small(act + LL_NEXT_P_OFFSET(ll_p), &next, node_p_size); else - memset(act + LL_NEXT_P_OFFSET(ll_p), 0, node_p_size); + lv_memset_00(act + LL_NEXT_P_OFFSET(ll_p), node_p_size); } diff --git a/src/lv_misc/lv_mem.c b/src/lv_misc/lv_mem.c index 7f2037371a..55a481983a 100644 --- a/src/lv_misc/lv_mem.c +++ b/src/lv_misc/lv_mem.c @@ -312,7 +312,7 @@ void * lv_mem_realloc(void * data_p, size_t new_size) if(data_p != NULL) { /*Copy the old data to the new. Use the smaller size*/ if(old_size != 0) { - memcpy(new_p, data_p, LV_MATH_MIN(new_size, old_size)); + lv_memcpy(new_p, data_p, LV_MATH_MIN(new_size, old_size)); lv_mem_free(data_p); } } @@ -530,7 +530,6 @@ void lv_mem_buf_free_all(void) /** * Same as `memcpy` but optimized for 4 byte operation. - * `dst` and `src` should be word aligned else normal `memcpy` will be used * @param dst pointer to the destination buffer * @param src pointer to the source buffer * @param len number of byte to copy diff --git a/src/lv_misc/lv_mem.h b/src/lv_misc/lv_mem.h index ea95111269..a4fdaa0289 100644 --- a/src/lv_misc/lv_mem.h +++ b/src/lv_misc/lv_mem.h @@ -135,13 +135,31 @@ void lv_mem_buf_free_all(void); /** * Same as `memcpy` but optimized for 4 byte operation. - * `dst` and `src` should be word aligned else normal `memcpy` will be used * @param dst pointer to the destination buffer * @param src pointer to the source buffer * @param len number of byte to copy */ void * lv_memcpy(void * dst, const void * src, size_t len); +/** + * Same as `memcpy` but optimized to copy only a few bytes. + * @param dst pointer to the destination buffer + * @param src pointer to the source buffer + * @param len number of byte to copy + */ +static inline void * lv_memcpy_small(void * dst, const void * src, size_t len) +{ + uint8_t * d8 = dst; + const uint8_t * s8 = src; + + while(len) { + *d8 = *s8; d8++; s8++; + len--; + } + + return dst; +} + /** * Same as `memset` but optimized for 4 byte operation. * `dst` should be word aligned else normal `memcpy` will be used diff --git a/src/lv_misc/lv_txt.c b/src/lv_misc/lv_txt.c index 34bb7f9e9b..a72e2002eb 100644 --- a/src/lv_misc/lv_txt.c +++ b/src/lv_misc/lv_txt.c @@ -445,7 +445,7 @@ void lv_txt_ins(char * txt_buf, uint32_t pos, const char * ins_txt) } /* Copy the text into the new space*/ - memcpy(txt_buf + pos, ins_txt, ins_len); + lv_memcpy_small(txt_buf + pos, ins_txt, ins_len); } /** @@ -537,7 +537,7 @@ static uint32_t lv_txt_utf8_conv_wc(uint32_t c) if((c & 0x80) != 0) { uint32_t swapped; uint8_t c8[4]; - memcpy(c8, &c, 4); + lv_memcpy_small(c8, &c, 4); swapped = (c8[0] << 24) + (c8[1] << 16) + (c8[2] << 8) + (c8[3]); uint8_t i; for(i = 0; i < 4; i++) { diff --git a/src/lv_themes/lv_theme_material.c b/src/lv_themes/lv_theme_material.c index 2b9762b686..bc49997ef9 100644 --- a/src/lv_themes/lv_theme_material.c +++ b/src/lv_themes/lv_theme_material.c @@ -63,7 +63,7 @@ #define COLOR_BG_SEC_TEXT_DIS (IS_LIGHT ? lv_color_hex(0xaaaaaa) : lv_color_hex(0xa5a8ad)) #define TRANSITION_TIME 150 -#define BORDER_WIDTH LV_DPX(3) +#define BORDER_WIDTH LV_DPX(2) #define IS_LIGHT (theme.flags & LV_THEME_MATERIAL_FLAG_LIGHT) /********************** @@ -200,6 +200,7 @@ static void basic_init(void) lv_style_set_bg_color(&bg, LV_STATE_DEFAULT, COLOR_BG); lv_style_set_border_color(&bg, LV_STATE_DEFAULT, COLOR_BG_BORDER); lv_style_set_border_color(&bg, LV_STATE_FOCUSED, theme.color_primary); + lv_style_set_border_color(&bg, LV_STATE_EDITED, theme.color_secondary); lv_style_set_border_width(&bg, LV_STATE_DEFAULT, BORDER_WIDTH); lv_style_set_border_post(&bg, LV_STATE_DEFAULT, true); lv_style_set_text_font(&bg, LV_STATE_DEFAULT, theme.font_normal); @@ -289,6 +290,7 @@ static void basic_init(void) lv_style_set_outline_opa(&btn, LV_STATE_DEFAULT, LV_OPA_0); lv_style_set_outline_opa(&btn, LV_STATE_FOCUSED, LV_OPA_50); lv_style_set_outline_color(&btn, LV_STATE_DEFAULT, theme.color_primary); + lv_style_set_outline_color(&btn, LV_STATE_EDITED, theme.color_secondary); lv_style_set_transition_time(&btn, LV_STATE_DEFAULT, TRANSITION_TIME); lv_style_set_transition_prop_4(&btn, LV_STATE_DEFAULT, LV_STYLE_BORDER_OPA); lv_style_set_transition_prop_5(&btn, LV_STATE_DEFAULT, LV_STYLE_BG_COLOR); @@ -337,6 +339,7 @@ static void bar_init(void) lv_style_set_bg_color(&bar_bg, LV_STATE_DEFAULT, COLOR_BG_SEC); lv_style_set_value_color(&bar_bg, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x31404f) : LV_COLOR_WHITE); lv_style_set_outline_color(&bar_bg, LV_STATE_DEFAULT, theme.color_primary); + lv_style_set_outline_color(&bar_bg, LV_STATE_EDITED, theme.color_secondary); lv_style_set_outline_opa(&bar_bg, LV_STATE_DEFAULT, LV_OPA_TRANSP); lv_style_set_outline_opa(&bar_bg, LV_STATE_FOCUSED, LV_OPA_50); lv_style_set_outline_width(&bar_bg, LV_STATE_DEFAULT, 3); @@ -570,6 +573,7 @@ static void cpicker_init(void) lv_style_set_border_width(&cpicker_indic, LV_STATE_DEFAULT, 2); lv_style_set_border_color(&cpicker_indic, LV_STATE_DEFAULT, LV_COLOR_GRAY); lv_style_set_border_color(&cpicker_indic, LV_STATE_FOCUSED, theme.color_primary); + lv_style_set_border_color(&cpicker_indic, LV_STATE_EDITED, theme.color_secondary); lv_style_set_pad_left(&cpicker_indic, LV_STATE_DEFAULT,LV_DPX(13)); lv_style_set_pad_right(&cpicker_indic, LV_STATE_DEFAULT, LV_DPX(13)); lv_style_set_pad_top(&cpicker_indic, LV_STATE_DEFAULT, LV_DPX(13)); @@ -612,6 +616,7 @@ static void keyboard_init(void) lv_style_set_border_width(&kb_bg, LV_STATE_DEFAULT, LV_DPX(4)); lv_style_set_border_side(&kb_bg, LV_STATE_DEFAULT, LV_BORDER_SIDE_TOP); lv_style_set_border_color(&kb_bg, LV_STATE_DEFAULT, IS_LIGHT ? COLOR_BG_TEXT : LV_COLOR_BLACK); + lv_style_set_border_color(&kb_bg, LV_STATE_EDITED, theme.color_secondary); lv_style_set_pad_left(&kb_bg, LV_STATE_DEFAULT, LV_DPX(10)); lv_style_set_pad_right(&kb_bg, LV_STATE_DEFAULT, LV_DPX(10)); lv_style_set_pad_top(&kb_bg, LV_STATE_DEFAULT, LV_DPX(10)); @@ -774,10 +779,12 @@ static void tabview_init(void) lv_style_set_pad_top(&tabview_btns, LV_STATE_DEFAULT, LV_DPX(20)); lv_style_set_pad_bottom(&tabview_btns, LV_STATE_DEFAULT, LV_DPX(20)); lv_style_set_text_color(&tabview_btns, LV_STATE_FOCUSED, theme.color_primary); + lv_style_set_text_color(&tabview_btns, LV_STATE_EDITED, theme.color_secondary); style_init_reset(&tabview_indic); lv_style_set_bg_opa(&tabview_indic, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_color(&tabview_indic, LV_STATE_DEFAULT, theme.color_primary); + lv_style_set_bg_color(&tabview_indic, LV_STATE_EDITED, theme.color_secondary); lv_style_set_size(&tabview_indic, LV_STATE_DEFAULT, LV_DPX(5)); lv_style_set_radius(&tabview_indic, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); diff --git a/src/lv_widgets/lv_btnmatrix.c b/src/lv_widgets/lv_btnmatrix.c index ef2570b287..0e4a8bd60e 100644 --- a/src/lv_widgets/lv_btnmatrix.c +++ b/src/lv_widgets/lv_btnmatrix.c @@ -275,7 +275,7 @@ void lv_btnmatrix_set_ctrl_map(lv_obj_t * btnm, const lv_btnmatrix_ctrl_t ctrl_m LV_ASSERT_OBJ(btnm, LV_OBJX_NAME); lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm); - memcpy(ext->ctrl_bits, ctrl_map, sizeof(lv_btnmatrix_ctrl_t) * ext->btn_cnt); + lv_memcpy(ext->ctrl_bits, ctrl_map, sizeof(lv_btnmatrix_ctrl_t) * ext->btn_cnt); lv_btnmatrix_set_map(btnm, ext->map_p); } @@ -497,7 +497,7 @@ uint16_t lv_btnmatrix_get_focused_btn(const lv_obj_t * btnm) LV_ASSERT_OBJ(btnm, LV_OBJX_NAME); lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm); - return ext->btn_id_pr; + return ext->btn_id_focused; } /** @@ -612,7 +612,6 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl lv_draw_rect_dsc_t draw_rect_tmp_dsc; lv_draw_label_dsc_t draw_label_tmp_dsc; - /*The state changes without re-caching the styles, disable the use of cache*/ lv_state_t state_ori = btnm->state; btnm->state = LV_STATE_DEFAULT; @@ -689,7 +688,10 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl btnm->state = LV_STATE_DEFAULT; if(tgl_state) btnm->state = LV_STATE_CHECKED; if(ext->btn_id_pr == btn_i) btnm->state |= LV_STATE_PRESSED; - if(ext->btn_id_focused == btn_i) btnm->state |= LV_STATE_FOCUSED; + if(ext->btn_id_focused == btn_i) { + btnm->state |= LV_STATE_FOCUSED; + if(state_ori & LV_STATE_EDITED) btnm->state |= LV_STATE_EDITED; + } lv_draw_rect_dsc_init(&draw_rect_tmp_dsc); lv_draw_label_dsc_init(&draw_label_tmp_dsc); @@ -1079,7 +1081,7 @@ static void allocate_btn_areas_and_controls(const lv_obj_t * btnm, const char ** LV_ASSERT_MEM(ext->ctrl_bits); if(ext->button_areas == NULL || ext->ctrl_bits == NULL) btn_cnt = 0; - memset(ext->ctrl_bits, 0, sizeof(lv_btnmatrix_ctrl_t) * btn_cnt); + lv_memset_00(ext->ctrl_bits, sizeof(lv_btnmatrix_ctrl_t) * btn_cnt); ext->btn_cnt = btn_cnt; } diff --git a/src/lv_widgets/lv_canvas.c b/src/lv_widgets/lv_canvas.c index 4da3152a82..12f2b7b40f 100644 --- a/src/lv_widgets/lv_canvas.c +++ b/src/lv_widgets/lv_canvas.c @@ -253,7 +253,7 @@ void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t x, l uint8_t * to_copy8 = (uint8_t *)to_copy; lv_coord_t i; for(i = 0; i < h; i++) { - memcpy((void *)&ext->dsc.data[px], to_copy8, w * px_size); + lv_memcpy((void *)&ext->dsc.data[px], to_copy8, w * px_size); px += ext->dsc.header.w * px_size; to_copy8 += w * px_size; } @@ -425,7 +425,7 @@ void lv_canvas_blur_hor(lv_obj_t * canvas, const lv_area_t * area, uint16_t r) lv_color_t c; lv_opa_t opa = LV_OPA_TRANSP; - memcpy(line_buf, &ext->dsc.data[y * line_w], line_w); + lv_memcpy(line_buf, &ext->dsc.data[y * line_w], line_w); for(x = a.x1 - r_back; x <= a.x1 + r_front; x++) { diff --git a/src/lv_widgets/lv_chart.c b/src/lv_widgets/lv_chart.c index 25539ac7b7..924e2e3943 100644 --- a/src/lv_widgets/lv_chart.c +++ b/src/lv_widgets/lv_chart.c @@ -108,9 +108,9 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy) ext->point_cnt = LV_CHART_PNUM_DEF; ext->type = LV_CHART_TYPE_LINE; ext->update_mode = LV_CHART_UPDATE_MODE_SHIFT; - memset(&ext->x_axis, 0, sizeof(ext->x_axis)); - memset(&ext->y_axis, 0, sizeof(ext->y_axis)); - memset(&ext->secondary_y_axis, 0, sizeof(ext->secondary_y_axis)); + lv_memset_00(&ext->x_axis, sizeof(ext->x_axis)); + lv_memset_00(&ext->y_axis, sizeof(ext->y_axis)); + lv_memset_00(&ext->secondary_y_axis, sizeof(ext->secondary_y_axis)); ext->x_axis.major_tick_len = LV_CHART_TICK_LENGTH_AUTO; ext->x_axis.minor_tick_len = LV_CHART_TICK_LENGTH_AUTO; ext->y_axis.major_tick_len = LV_CHART_TICK_LENGTH_AUTO; @@ -147,9 +147,9 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy) ext->hdiv_cnt = ext_copy->hdiv_cnt; ext->vdiv_cnt = ext_copy->vdiv_cnt; ext->point_cnt = ext_copy->point_cnt; - memcpy(&ext->x_axis, &ext_copy->x_axis, sizeof(lv_chart_axis_cfg_t)); - memcpy(&ext->y_axis, &ext_copy->y_axis, sizeof(lv_chart_axis_cfg_t)); - memcpy(&ext->secondary_y_axis, &ext_copy->secondary_y_axis, sizeof(lv_chart_axis_cfg_t)); + lv_memcpy(&ext->x_axis, &ext_copy->x_axis, sizeof(lv_chart_axis_cfg_t)); + lv_memcpy(&ext->y_axis, &ext_copy->y_axis, sizeof(lv_chart_axis_cfg_t)); + lv_memcpy(&ext->secondary_y_axis, &ext_copy->secondary_y_axis, sizeof(lv_chart_axis_cfg_t)); /*Refresh the style with new signal function*/ lv_obj_refresh_style(chart, LV_STYLE_PROP_ALL); diff --git a/src/lv_widgets/lv_dropdown.c b/src/lv_widgets/lv_dropdown.c index 8db9cb3741..265651e611 100644 --- a/src/lv_widgets/lv_dropdown.c +++ b/src/lv_widgets/lv_dropdown.c @@ -123,6 +123,7 @@ lv_obj_t * lv_dropdown_create(lv_obj_t * par, const lv_obj_t * copy) /*Init the new drop down list drop down list*/ if(copy == NULL) { + lv_obj_set_width(ddlist, LV_DPX(150)); lv_dropdown_set_static_options(ddlist, "Option 1\nOption 2\nOption 3"); lv_theme_apply(ddlist, LV_THEME_DROPDOWN); } @@ -902,13 +903,20 @@ static lv_res_t lv_dropdown_signal(lv_obj_t * ddlist, lv_signal_t sign, void * p lv_dropdown_close(ddlist); } else if(sign == LV_SIGNAL_RELEASED) { - if(lv_indev_is_dragging(lv_indev_get_act()) == false) { + lv_indev_t * indev = lv_indev_get_act(); + if(lv_indev_is_dragging(indev) == false) { if(ext->page) { lv_dropdown_close(ddlist); if(ext->sel_opt_id_orig != ext->sel_opt_id) { ext->sel_opt_id_orig = ext->sel_opt_id; lv_obj_invalidate(ddlist); } +#if LV_USE_GROUP + lv_indev_type_t indev_type = lv_indev_get_type(indev); + if(indev_type == LV_INDEV_TYPE_ENCODER) { + lv_group_set_editing(lv_obj_get_group(ddlist), false); + } +#endif } else { lv_dropdown_open(ddlist); diff --git a/src/lv_widgets/lv_imgbtn.c b/src/lv_widgets/lv_imgbtn.c index 57dc75a6cc..f86fd72b94 100644 --- a/src/lv_widgets/lv_imgbtn.c +++ b/src/lv_widgets/lv_imgbtn.c @@ -73,10 +73,10 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy) if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(imgbtn); /*Initialize the allocated 'ext' */ - memset((void *)ext->img_src_mid, 0, sizeof(ext->img_src_mid)); + lv_memset_00((void *)ext->img_src_mid, sizeof(ext->img_src_mid)); #if LV_IMGBTN_TILED - memset(ext->img_src_left, 0, sizeof(ext->img_src_left)); - memset(ext->img_src_right, 0, sizeof(ext->img_src_right)); + lv_memset_00(ext->img_src_left, sizeof(ext->img_src_left)); + lv_memset_00(ext->img_src_right, sizeof(ext->img_src_right)); #endif ext->tiled = 0; @@ -93,10 +93,10 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy) /*Copy an existing image button*/ else { lv_imgbtn_ext_t * copy_ext = lv_obj_get_ext_attr(copy); - memcpy((void *)ext->img_src_mid, copy_ext->img_src_mid, sizeof(ext->img_src_mid)); + lv_memcpy((void *)ext->img_src_mid, copy_ext->img_src_mid, sizeof(ext->img_src_mid)); #if LV_IMGBTN_TILED - memcpy((void *)ext->img_src_left, copy_ext->img_src_left, sizeof(ext->img_src_left)); - memcpy((void *)ext->img_src_right, copy_ext->img_src_right, sizeof(ext->img_src_right)); + lv_memcpy((void *)ext->img_src_left, copy_ext->img_src_left, sizeof(ext->img_src_left)); + lv_memcpy((void *)ext->img_src_right, copy_ext->img_src_right, sizeof(ext->img_src_right)); #endif ext->tiled = copy_ext->tiled; /*Refresh the style with new signal function*/ diff --git a/src/lv_widgets/lv_label.c b/src/lv_widgets/lv_label.c index 8b9973db08..3061f8f809 100644 --- a/src/lv_widgets/lv_label.c +++ b/src/lv_widgets/lv_label.c @@ -147,7 +147,7 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy) ext->text = lv_mem_realloc(ext->text, lv_mem_get_size(copy_ext->text)); LV_ASSERT_MEM(ext->text); if(ext->text == NULL) return NULL; - memcpy(ext->text, copy_ext->text, lv_mem_get_size(copy_ext->text)); + lv_memcpy(ext->text, copy_ext->text, lv_mem_get_size(copy_ext->text)); } if(copy_ext->dot_tmp_alloc && copy_ext->dot.tmp_ptr) { @@ -155,7 +155,7 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy) lv_label_set_dot_tmp(new_label, ext->dot.tmp_ptr, len); } else { - memcpy(ext->dot.tmp, copy_ext->dot.tmp, sizeof(ext->dot.tmp)); + lv_memcpy(ext->dot.tmp, copy_ext->dot.tmp, sizeof(ext->dot.tmp)); } ext->dot_tmp_alloc = copy_ext->dot_tmp_alloc; ext->dot_end = copy_ext->dot_end; @@ -1450,14 +1450,14 @@ static bool lv_label_set_dot_tmp(lv_obj_t * label, char * data, uint16_t len) LV_LOG_ERROR("Failed to allocate memory for dot_tmp_ptr"); return false; } - memcpy(ext->dot.tmp_ptr, data, len); + lv_memcpy(ext->dot.tmp_ptr, data, len); ext->dot.tmp_ptr[len] = '\0'; ext->dot_tmp_alloc = true; } else { /* Characters can be directly stored in object */ ext->dot_tmp_alloc = false; - memcpy(ext->dot.tmp, data, len); + lv_memcpy(ext->dot.tmp, data, len); } return true; } diff --git a/src/lv_widgets/lv_msgbox.c b/src/lv_widgets/lv_msgbox.c index 280a3deacd..aa410464e0 100644 --- a/src/lv_widgets/lv_msgbox.c +++ b/src/lv_widgets/lv_msgbox.c @@ -162,6 +162,13 @@ void lv_msgbox_add_btns(lv_obj_t * mbox, const char * btn_map[]) lv_obj_set_event_cb(ext->btnm, lv_msgbox_btnm_event_cb); if(lv_obj_is_focused(mbox)) { + lv_state_t state = lv_obj_get_state(mbox, LV_MSGBOX_PART_BG); + if(state & LV_STATE_EDITED) { + lv_obj_set_state(ext->btnm, LV_STATE_FOCUSED | LV_STATE_EDITED); + } else { + lv_obj_set_state(ext->btnm, LV_STATE_FOCUSED); + } + lv_btnmatrix_set_focused_btn(ext->btnm, 0); } @@ -312,10 +319,14 @@ uint16_t lv_msgbox_get_active_btn(lv_obj_t * mbox) LV_ASSERT_OBJ(mbox, LV_OBJX_NAME); lv_msgbox_ext_t * ext = lv_obj_get_ext_attr(mbox); - if(ext->btnm) - return lv_btnmatrix_get_active_btn(ext->btnm); - else - return LV_BTNMATRIX_BTN_NONE; + if(ext->btnm == NULL) return LV_BTNMATRIX_BTN_NONE; + + uint16_t id = lv_btnmatrix_get_active_btn(ext->btnm); + if(id == LV_BTNMATRIX_BTN_NONE) { + id = lv_btnmatrix_get_focused_btn(ext->btnm); + } + + return id; } /** @@ -442,7 +453,7 @@ static lv_res_t lv_msgbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param } else if(sign == LV_SIGNAL_RELEASED) { if(ext->btnm) { - uint32_t btn_id = lv_btnmatrix_get_active_btn(ext->btnm); + uint32_t btn_id = lv_btnmatrix_get_focused_btn(ext->btnm); if(btn_id != LV_BTNMATRIX_BTN_NONE) lv_event_send(mbox, LV_EVENT_VALUE_CHANGED, &btn_id); } } @@ -454,20 +465,33 @@ static lv_res_t lv_msgbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param /* The button matrix with ENCODER input supposes it's in a group but in this case it isn't * (Only the message box's container) So so some actions here instead*/ - if(sign == LV_SIGNAL_FOCUS) { #if LV_USE_GROUP + if(sign == LV_SIGNAL_FOCUS) { lv_indev_t * indev = lv_indev_get_act(); lv_indev_type_t indev_type = lv_indev_get_type(indev); if(indev_type == LV_INDEV_TYPE_ENCODER) { /*In navigation mode don't select any button but in edit mode select the fist*/ - lv_btnmatrix_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btnm); - if(lv_group_get_editing(lv_obj_get_group(mbox))) - btnm_ext->btn_id_pr = 0; - else - btnm_ext->btn_id_pr = LV_BTNMATRIX_BTN_NONE; + if(lv_group_get_editing(lv_obj_get_group(mbox))) lv_btnmatrix_set_focused_btn(ext->btnm, 0); + else lv_btnmatrix_set_focused_btn(ext->btnm, LV_BTNMATRIX_BTN_NONE); } -#endif } + + if(ext->btnm && (sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS)) { + lv_state_t state = lv_obj_get_state(mbox, LV_MSGBOX_PART_BG); + if(state & LV_STATE_FOCUSED) { + lv_obj_set_state(ext->btnm, LV_STATE_FOCUSED); + } else { + lv_obj_clear_state(ext->btnm, LV_STATE_FOCUSED); + + } + if(state & LV_STATE_EDITED) { + lv_obj_set_state(ext->btnm, LV_STATE_EDITED); + } else { + lv_obj_clear_state(ext->btnm, LV_STATE_EDITED); + + } + } +#endif } return res; diff --git a/src/lv_widgets/lv_objmask.c b/src/lv_widgets/lv_objmask.c index b9ee162383..bd877dd74f 100644 --- a/src/lv_widgets/lv_objmask.c +++ b/src/lv_widgets/lv_objmask.c @@ -121,7 +121,7 @@ lv_objmask_mask_t * lv_objmask_add_mask(lv_obj_t * objmask, void * param) LV_ASSERT_MEM(m->param); if(m->param == NULL) return NULL; - memcpy(m->param, param, param_size); + lv_memcpy(m->param, param, param_size); lv_obj_invalidate(objmask); diff --git a/src/lv_widgets/lv_roller.c b/src/lv_widgets/lv_roller.c index 31ce0daaf0..495dd31aa3 100644 --- a/src/lv_widgets/lv_roller.c +++ b/src/lv_widgets/lv_roller.c @@ -479,8 +479,10 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par } /* Include the ancient signal function */ - res = ancestor_signal(roller, sign, param); - if(res != LV_RES_OK) return res; + if(sign != LV_SIGNAL_CONTROL) { /*Don't let the page to scroll on keys*/ + res = ancestor_signal(roller, sign, param); + if(res != LV_RES_OK) return res; + } if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME); diff --git a/src/lv_widgets/lv_spinbox.c b/src/lv_widgets/lv_spinbox.c index 671d469636..c871ee567a 100644 --- a/src/lv_widgets/lv_spinbox.c +++ b/src/lv_widgets/lv_spinbox.c @@ -514,7 +514,7 @@ static void lv_spinbox_updatevalue(lv_obj_t * spinbox) lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox); char buf[LV_SPINBOX_MAX_DIGIT_COUNT + 8]; - memset(buf, 0, sizeof(buf)); + lv_memset_00(buf, sizeof(buf)); char * buf_p = buf; uint8_t cur_shift_left = 0; diff --git a/src/lv_widgets/lv_table.c b/src/lv_widgets/lv_table.c index 42d0436957..481f00ef73 100644 --- a/src/lv_widgets/lv_table.c +++ b/src/lv_widgets/lv_table.c @@ -199,7 +199,7 @@ void lv_table_set_row_cnt(lv_obj_t * table, uint16_t row_cnt) if(old_row_cnt < row_cnt) { uint16_t old_cell_cnt = old_row_cnt * ext->col_cnt; uint32_t new_cell_cnt = ext->col_cnt * ext->row_cnt; - memset(&ext->cell_data[old_cell_cnt], 0, (new_cell_cnt - old_cell_cnt) * sizeof(ext->cell_data[0])); + lv_memset_00(&ext->cell_data[old_cell_cnt], (new_cell_cnt - old_cell_cnt) * sizeof(ext->cell_data[0])); } } else { @@ -237,7 +237,7 @@ void lv_table_set_col_cnt(lv_obj_t * table, uint16_t col_cnt) if(old_col_cnt < col_cnt) { uint16_t old_cell_cnt = old_col_cnt * ext->row_cnt; uint32_t new_cell_cnt = ext->col_cnt * ext->row_cnt; - memset(&ext->cell_data[old_cell_cnt], 0, (new_cell_cnt - old_cell_cnt) * sizeof(ext->cell_data[0])); + lv_memset_00(&ext->cell_data[old_cell_cnt], (new_cell_cnt - old_cell_cnt) * sizeof(ext->cell_data[0])); } } diff --git a/src/lv_widgets/lv_tabview.c b/src/lv_widgets/lv_tabview.c index a3553ab8ad..3dfd7c2b8e 100644 --- a/src/lv_widgets/lv_tabview.c +++ b/src/lv_widgets/lv_tabview.c @@ -652,17 +652,34 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p /* The button matrix is not in a group (the tab view is in it) but it should handle the * group signals. So propagate the related signals to the button matrix manually*/ - if(ext->btns) { - ext->btns->signal_cb(ext->btns, sign, param); + ext->btns->signal_cb(ext->btns, sign, param); + + /*Make the active tab's button focused*/ + if(sign == LV_SIGNAL_FOCUS) { + lv_btnmatrix_set_focused_btn(ext->btns, ext->tab_cur); + } + + if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS) { + lv_state_t state = lv_obj_get_state(tabview, LV_TABVIEW_PART_BG); + if(state & LV_STATE_FOCUSED) { + lv_obj_set_state(ext->btns, LV_STATE_FOCUSED); + lv_obj_set_state(ext->indic, LV_STATE_FOCUSED); + } else { + lv_obj_clear_state(ext->btns, LV_STATE_FOCUSED); + lv_obj_clear_state(ext->indic, LV_STATE_FOCUSED); + + } + if(state & LV_STATE_EDITED) { + lv_obj_set_state(ext->btns, LV_STATE_EDITED); + lv_obj_set_state(ext->indic, LV_STATE_EDITED); + } else { + lv_obj_clear_state(ext->btns, LV_STATE_EDITED); + lv_obj_clear_state(ext->indic, LV_STATE_EDITED); - /*Make the active tab's button focused*/ - if(sign == LV_SIGNAL_FOCUS) { - lv_btnmatrix_set_focused_btn(ext->btns, ext->tab_cur); } } } - return res; } @@ -796,6 +813,12 @@ static void tab_btnm_event_cb(lv_obj_t * tab_btnm, lv_event_t event) lv_res_t res = LV_RES_OK; if(id_prev != id_new) res = lv_event_send(tabview, LV_EVENT_VALUE_CHANGED, &id_new); +#if LV_USE_GROUP + if(lv_indev_get_type(lv_indev_get_act()) == LV_INDEV_TYPE_ENCODER) { + lv_group_set_editing(lv_obj_get_group(tabview), false); + } +#endif + if(res != LV_RES_OK) return; } diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index 1c5da595f0..4193c97a7c 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -181,7 +181,7 @@ lv_obj_t * lv_textarea_create(lv_obj_t * par, const lv_obj_t * copy) LV_ASSERT_MEM(ext->pwd_tmp); if(ext->pwd_tmp == NULL) return NULL; - memcpy(ext->pwd_tmp, copy_ext->pwd_tmp, len); + lv_memcpy(ext->pwd_tmp, copy_ext->pwd_tmp, len); } if(copy_ext->one_line) lv_textarea_set_one_line(ta, true); @@ -1351,7 +1351,7 @@ static lv_design_res_t lv_textarea_scrollable_design(lv_obj_t * scrl, const lv_a lv_draw_rect(&cur_area, clip_area, &cur_dsc); char letter_buf[8] = {0}; - memcpy(letter_buf, &txt[ext->cursor.txt_byte_pos], lv_txt_encoded_size(&txt[ext->cursor.txt_byte_pos])); + lv_memcpy(letter_buf, &txt[ext->cursor.txt_byte_pos], lv_txt_encoded_size(&txt[ext->cursor.txt_byte_pos])); if(cur_dsc.bg_opa == LV_OPA_COVER) { lv_style_int_t left = lv_obj_get_style_pad_left(ta, LV_TEXTAREA_PART_CURSOR); @@ -1637,7 +1637,7 @@ static void pwd_char_hider(lv_obj_t * ta) char * txt_tmp = lv_mem_buf_get(enc_len * bullet_len + 1); uint16_t i; for(i = 0; i < enc_len; i++) { - memcpy(&txt_tmp[i * bullet_len], bullet, bullet_len); + lv_memcpy(&txt_tmp[i * bullet_len], bullet, bullet_len); } txt_tmp[i * bullet_len] = '\0';