replace all memcpy with lv_memcpy

This commit is contained in:
Gabor Kiss-Vamosi
2020-04-23 15:27:51 +02:00
parent c149e5de54
commit 479d31e5a7
27 changed files with 159 additions and 94 deletions

View File

@@ -159,7 +159,7 @@ void lv_debug_log_error(const char * msg, uint64_t value)
char * bufp = buf; char * bufp = buf;
/*Add the function name*/ /*Add the function name*/
memcpy(bufp, msg, msg_len); lv_memcpy(bufp, msg, msg_len);
bufp += msg_len; bufp += msg_len;
/*Add value in hey*/ /*Add value in hey*/

View File

@@ -328,7 +328,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
/*Set user data*/ /*Set user data*/
#if LV_USE_USER_DATA #if LV_USE_USER_DATA
memcpy(&new_obj->user_data, &copy->user_data, sizeof(lv_obj_user_data_t)); lv_memcpy(&new_obj->user_data, &copy->user_data, sizeof(lv_obj_user_data_t));
#endif #endif
/*Copy realign*/ /*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); 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. * 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 obj pointer to an object
* @param w new height including margins * @param w new height including margins
*/ */
@@ -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 * Notify an object (and its children) about its style is modified
* @param obj pointer to an object * @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) void lv_obj_refresh_style(lv_obj_t * obj, lv_style_property_t prop)
{ {
@@ -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); 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 #endif

View File

@@ -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); 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. * 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 obj pointer to an object
* @param w new height including margins * @param w new height including margins
*/ */
@@ -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); 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 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); void lv_obj_refresh_style(lv_obj_t * obj, lv_style_property_t prop);

View File

@@ -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); 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++) { 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); start_offs += hres * sizeof(lv_color_t);
} }
} }

View File

@@ -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); uint16_t size = lv_style_get_mem_size(style_src);
style_dest->map = lv_mem_alloc(size); style_dest->map = lv_mem_alloc(size);
memcpy(style_dest->map, style_src->map, size); lv_memcpy(style_dest->map, style_src->map, size);
} }
/** /**
@@ -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_local == 0) {
if(list_src->has_trans) { if(list_src->has_trans) {
list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 1) * sizeof(lv_style_t *)); 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; list_dest->style_cnt = list_src->style_cnt - 1;
} }
else { else {
list_dest->style_list = lv_mem_alloc(list_src->style_cnt * sizeof(lv_style_t *)); 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; list_dest->style_cnt = list_src->style_cnt;
} }
} }
else { else {
if(list_src->has_trans) { if(list_src->has_trans) {
list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 2) * sizeof(lv_style_t *)); 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; list_dest->style_cnt = list_src->style_cnt - 2;
} }
else { else {
list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 1) * sizeof(lv_style_t *)); 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; 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; attr_goal.full = (prop >> 8) & 0xFFU;
if(attr_found.bits.state == attr_goal.bits.state) { 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; 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); LV_ASSERT_MEM(style->map);
if(style == NULL) return; if(style == NULL) return;
memcpy(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t)); lv_memcpy_small(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)); lv_memcpy_small(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 - 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; attr_goal.full = (prop >> 8) & 0xFFU;
if(attr_found.bits.state == attr_goal.bits.state) { 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; 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); LV_ASSERT_MEM(style->map);
if(style == NULL) return; if(style == NULL) return;
memcpy(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t)); lv_memcpy_small(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)); lv_memcpy_small(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 - 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; attr_goal.full = (prop >> 8) & 0xFFU;
if(attr_found.bits.state == attr_goal.bits.state) { 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; 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); LV_ASSERT_MEM(style->map);
if(style == NULL) return; if(style == NULL) return;
memcpy(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t)); lv_memcpy_small(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)); lv_memcpy_small(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 - 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; attr_goal.full = (prop >> 8) & 0xFFU;
if(attr_found.bits.state == attr_goal.bits.state) { 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; 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); LV_ASSERT_MEM(style->map);
if(style == NULL) return; if(style == NULL) return;
memcpy(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t)); lv_memcpy_small(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)); lv_memcpy_small(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 - 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; return -1;
} }
else { 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; lv_style_attr_t attr_act;
attr_act.full = style->map[id + 1]; 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; return -1;
} }
else { 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; lv_style_attr_t attr_act;
attr_act.full = style->map[id + 1]; 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; return -1;
} }
else { 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; lv_style_attr_t attr_act;
attr_act.full = style->map[id + 1]; 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; return -1;
} }
else { 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; lv_style_attr_t attr_act;
attr_act.full = style->map[id + 1]; attr_act.full = style->map[id + 1];

View File

@@ -275,7 +275,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
/*Get the parameter*/ /*Get the parameter*/
if(i - par_start == LABEL_RECOLOR_PAR_LENGTH + 1) { if(i - par_start == LABEL_RECOLOR_PAR_LENGTH + 1) {
char buf[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'; buf[LABEL_RECOLOR_PAR_LENGTH] = '\0';
int r, g, b; int r, g, b;
r = (hex_char_to_num(buf[0]) << 4) + hex_char_to_num(buf[1]); r = (hex_char_to_num(buf[0]) << 4) + hex_char_to_num(buf[1]);

View File

@@ -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) { dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) {
uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3; 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; 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 #if LV_COLOR_SIZE == 32
p_color.ch.alpha = 0xFF; /*Only the color should be get so use a deafult alpha value*/ p_color.ch.alpha = 0xFF; /*Only the color should be get so use a deafult alpha value*/
#endif #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) { 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; 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; 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) { 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; 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; 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) { else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT) {
buf_u8 += sizeof(lv_color32_t) * 2; /*Skip the palette*/ 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; lv_color32_t c32;
c32.full = lv_color_to32(c); c32.full = lv_color_to32(c);
uint8_t * buf = (uint8_t *)dsc->data; 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; px_size = LV_COLOR_SIZE >> 3;
pxi = dsc->cfg.src_w * ys_int * px_size + xs_int * px_size; 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 { else {
px_size = LV_IMG_PX_SIZE_ALPHA_BYTE; px_size = LV_IMG_PX_SIZE_ALPHA_BYTE;
pxi = dsc->cfg.src_w * ys_int * px_size + xs_int * px_size; 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]; 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; lv_opa_t a11 = 0;
if(dsc->tmp.native_color) { if(dsc->tmp.native_color) {
memcpy(&c01, &src_u8[dsc->tmp.pxi + dsc->tmp.px_size * xn], sizeof(lv_color_t)); lv_memcpy_small(&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)); lv_memcpy_small(&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(&c11, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn + dsc->tmp.px_size * xn],
sizeof(lv_color_t)); sizeof(lv_color_t));
if(dsc->tmp.has_alpha) { if(dsc->tmp.has_alpha) {
a10 = src_u8[dsc->tmp.pxi + dsc->tmp.px_size * xn + dsc->tmp.px_size - 1]; a10 = src_u8[dsc->tmp.pxi + dsc->tmp.px_size * xn + dsc->tmp.px_size - 1];

View File

@@ -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; return LV_RES_INV;
} }
memcpy(user_data->f, &f, sizeof(f)); lv_memcpy_small(user_data->f, &f, sizeof(f));
#else #else
LV_LOG_WARN("Image built-in decoder cannot read file because LV_USE_FILESYSTEM = 0"); LV_LOG_WARN("Image built-in decoder cannot read file because LV_USE_FILESYSTEM = 0");

View File

@@ -125,9 +125,9 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
return NULL; return NULL;
} }
memcpy(&disp->driver, driver, sizeof(lv_disp_drv_t)); lv_memcpy(&disp->driver, driver, sizeof(lv_disp_drv_t));
memset(&disp->inv_area_joined, 0, sizeof(disp->inv_area_joined)); lv_memset_00(&disp->inv_area_joined, sizeof(disp->inv_area_joined));
memset(&disp->inv_areas, 0, sizeof(disp->inv_areas)); lv_memset_00(&disp->inv_areas, sizeof(disp->inv_areas));
lv_ll_init(&disp->scr_ll, sizeof(lv_obj_t)); lv_ll_init(&disp->scr_ll, sizeof(lv_obj_t));
disp->last_activity_time = 0; disp->last_activity_time = 0;

View File

@@ -84,8 +84,8 @@ lv_indev_t * lv_indev_drv_register(lv_indev_drv_t * driver)
return NULL; return NULL;
} }
memset(indev, 0, sizeof(lv_indev_t)); lv_memset_00(indev, sizeof(lv_indev_t));
memcpy(&indev->driver, driver, sizeof(lv_indev_drv_t)); lv_memcpy(&indev->driver, driver, sizeof(lv_indev_drv_t));
indev->proc.reset_query = 1; indev->proc.reset_query = 1;
indev->cursor = NULL; indev->cursor = NULL;

View File

@@ -107,7 +107,7 @@ void lv_anim_start(lv_anim_t * a)
/*Initialize the animation descriptor*/ /*Initialize the animation descriptor*/
a->time_orig = a->time; 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*/ /*Set the start value*/
if(new_anim->early_apply) { 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. /*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*/ * This way the `ready_cb` will see the animations like it's animation is ready deleted*/
lv_anim_t a_tmp; 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_ll_remove(&LV_GC_ROOT(_lv_anim_ll), a);
lv_mem_free(a); lv_mem_free(a);
/*Flag that the list has changed */ /*Flag that the list has changed */

View File

@@ -17,6 +17,7 @@ extern "C" {
#include <string.h> #include <string.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include "lv_mem.h"
/********************* /*********************
* DEFINES * 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) 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));
} }
/** /**

View File

@@ -311,7 +311,7 @@ void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len
if(rd) { if(rd) {
if(base_dir == LV_BIDI_DIR_LTR) { if(base_dir == LV_BIDI_DIR_LTR) {
if(str_out) { if(str_out) {
memcpy(&str_out[wr], str_in, rd); lv_memcpy(&str_out[wr], str_in, rd);
wr += rd; wr += rd;
} }
if(pos_conv_out) { 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(base_dir == LV_BIDI_DIR_LTR) {
if(run_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); 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, 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; wr -= run_len;
pos_conv_wr -= pos_conv_run_len; pos_conv_wr -= pos_conv_run_len;
if(run_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); 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, 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; 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, 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); pos_conv_rd_base + pos_conv_first_weak);
wr += last_weak - first_weak + 1; 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*/ /*Just store the letter*/
else { 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); if(pos_conv_out) pos_conv_out[pos_conv_wr] = SET_RTL_POS(pos_conv_rd_base + pos_conv_i, true);
wr += letter_size; wr += letter_size;
pos_conv_wr++; pos_conv_wr++;

View File

@@ -491,7 +491,7 @@ void lv_fs_drv_register(lv_fs_drv_t * drv_p)
LV_ASSERT_MEM(new_drv); LV_ASSERT_MEM(new_drv);
if(new_drv == NULL) return; 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));
} }
/** /**

View File

@@ -299,7 +299,7 @@ void * lv_ll_get_next(const lv_ll_t * ll_p, const void * n_act)
if(ll_p != NULL) { if(ll_p != NULL) {
const lv_ll_node_t * n_act_d = n_act; 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; 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) { if(ll_p != NULL) {
const lv_ll_node_t * n_act_d = n_act; 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; 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 *); uint32_t node_p_size = sizeof(lv_ll_node_t *);
if(prev) 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 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 *); uint32_t node_p_size = sizeof(lv_ll_node_t *);
if(next) 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 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);
} }

View File

@@ -312,7 +312,7 @@ void * lv_mem_realloc(void * data_p, size_t new_size)
if(data_p != NULL) { if(data_p != NULL) {
/*Copy the old data to the new. Use the smaller size*/ /*Copy the old data to the new. Use the smaller size*/
if(old_size != 0) { 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); 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. * 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 dst pointer to the destination buffer
* @param src pointer to the source buffer * @param src pointer to the source buffer
* @param len number of byte to copy * @param len number of byte to copy

View File

@@ -135,13 +135,31 @@ void lv_mem_buf_free_all(void);
/** /**
* Same as `memcpy` but optimized for 4 byte operation. * 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 dst pointer to the destination buffer
* @param src pointer to the source buffer * @param src pointer to the source buffer
* @param len number of byte to copy * @param len number of byte to copy
*/ */
void * lv_memcpy(void * dst, const void * src, size_t len); 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. * Same as `memset` but optimized for 4 byte operation.
* `dst` should be word aligned else normal `memcpy` will be used * `dst` should be word aligned else normal `memcpy` will be used

View File

@@ -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*/ /* 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) { if((c & 0x80) != 0) {
uint32_t swapped; uint32_t swapped;
uint8_t c8[4]; 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]); swapped = (c8[0] << 24) + (c8[1] << 16) + (c8[2] << 8) + (c8[3]);
uint8_t i; uint8_t i;
for(i = 0; i < 4; i++) { for(i = 0; i < 4; i++) {

View File

@@ -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_ASSERT_OBJ(btnm, LV_OBJX_NAME);
lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm); 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); 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_ASSERT_OBJ(btnm, LV_OBJX_NAME);
lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm); lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
return ext->btn_id_pr; return ext->btn_id_focused;
} }
/** /**

View File

@@ -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; uint8_t * to_copy8 = (uint8_t *)to_copy;
lv_coord_t i; lv_coord_t i;
for(i = 0; i < h; 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; px += ext->dsc.header.w * px_size;
to_copy8 += 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_color_t c;
lv_opa_t opa = LV_OPA_TRANSP; 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++) { for(x = a.x1 - r_back; x <= a.x1 + r_front; x++) {

View File

@@ -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->hdiv_cnt = ext_copy->hdiv_cnt;
ext->vdiv_cnt = ext_copy->vdiv_cnt; ext->vdiv_cnt = ext_copy->vdiv_cnt;
ext->point_cnt = ext_copy->point_cnt; ext->point_cnt = ext_copy->point_cnt;
memcpy(&ext->x_axis, &ext_copy->x_axis, sizeof(lv_chart_axis_cfg_t)); lv_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)); lv_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->secondary_y_axis, &ext_copy->secondary_y_axis, sizeof(lv_chart_axis_cfg_t));
/*Refresh the style with new signal function*/ /*Refresh the style with new signal function*/
lv_obj_refresh_style(chart, LV_STYLE_PROP_ALL); lv_obj_refresh_style(chart, LV_STYLE_PROP_ALL);

View File

@@ -93,10 +93,10 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy)
/*Copy an existing image button*/ /*Copy an existing image button*/
else { else {
lv_imgbtn_ext_t * copy_ext = lv_obj_get_ext_attr(copy); 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 #if LV_IMGBTN_TILED
memcpy((void *)ext->img_src_left, copy_ext->img_src_left, sizeof(ext->img_src_left)); lv_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_right, copy_ext->img_src_right, sizeof(ext->img_src_right));
#endif #endif
ext->tiled = copy_ext->tiled; ext->tiled = copy_ext->tiled;
/*Refresh the style with new signal function*/ /*Refresh the style with new signal function*/

View File

@@ -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)); ext->text = lv_mem_realloc(ext->text, lv_mem_get_size(copy_ext->text));
LV_ASSERT_MEM(ext->text); LV_ASSERT_MEM(ext->text);
if(ext->text == NULL) return NULL; 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) { 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); lv_label_set_dot_tmp(new_label, ext->dot.tmp_ptr, len);
} }
else { 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_tmp_alloc = copy_ext->dot_tmp_alloc;
ext->dot_end = copy_ext->dot_end; 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"); LV_LOG_ERROR("Failed to allocate memory for dot_tmp_ptr");
return false; 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_ptr[len] = '\0';
ext->dot_tmp_alloc = true; ext->dot_tmp_alloc = true;
} }
else { else {
/* Characters can be directly stored in object */ /* Characters can be directly stored in object */
ext->dot_tmp_alloc = false; ext->dot_tmp_alloc = false;
memcpy(ext->dot.tmp, data, len); lv_memcpy(ext->dot.tmp, data, len);
} }
return true; return true;
} }

View File

@@ -319,10 +319,14 @@ uint16_t lv_msgbox_get_active_btn(lv_obj_t * mbox)
LV_ASSERT_OBJ(mbox, LV_OBJX_NAME); LV_ASSERT_OBJ(mbox, LV_OBJX_NAME);
lv_msgbox_ext_t * ext = lv_obj_get_ext_attr(mbox); lv_msgbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
if(ext->btnm) if(ext->btnm == NULL) return LV_BTNMATRIX_BTN_NONE;
return lv_btnmatrix_get_active_btn(ext->btnm);
else uint16_t id = lv_btnmatrix_get_active_btn(ext->btnm);
return LV_BTNMATRIX_BTN_NONE; if(id == LV_BTNMATRIX_BTN_NONE) {
id = lv_btnmatrix_get_focused_btn(ext->btnm);
}
return id;
} }
/** /**
@@ -449,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) { else if(sign == LV_SIGNAL_RELEASED) {
if(ext->btnm) { 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); if(btn_id != LV_BTNMATRIX_BTN_NONE) lv_event_send(mbox, LV_EVENT_VALUE_CHANGED, &btn_id);
} }
} }

View File

@@ -121,7 +121,7 @@ lv_objmask_mask_t * lv_objmask_add_mask(lv_obj_t * objmask, void * param)
LV_ASSERT_MEM(m->param); LV_ASSERT_MEM(m->param);
if(m->param == NULL) return NULL; if(m->param == NULL) return NULL;
memcpy(m->param, param, param_size); lv_memcpy(m->param, param, param_size);
lv_obj_invalidate(objmask); lv_obj_invalidate(objmask);

View File

@@ -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 */ /* Include the ancient signal function */
res = ancestor_signal(roller, sign, param); if(sign != LV_SIGNAL_CONTROL) { /*Don't let the page to scroll on keys*/
if(res != LV_RES_OK) return res; 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); if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);

View File

@@ -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); LV_ASSERT_MEM(ext->pwd_tmp);
if(ext->pwd_tmp == NULL) return NULL; 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); 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); lv_draw_rect(&cur_area, clip_area, &cur_dsc);
char letter_buf[8] = {0}; 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) { if(cur_dsc.bg_opa == LV_OPA_COVER) {
lv_style_int_t left = lv_obj_get_style_pad_left(ta, LV_TEXTAREA_PART_CURSOR); 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); char * txt_tmp = lv_mem_buf_get(enc_len * bullet_len + 1);
uint16_t i; uint16_t i;
for(i = 0; i < enc_len; 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'; txt_tmp[i * bullet_len] = '\0';