diff --git a/scripts/code-format.cfg b/scripts/code-format.cfg index f85827b72..c0d538f8e 100644 --- a/scripts/code-format.cfg +++ b/scripts/code-format.cfg @@ -23,4 +23,12 @@ --suffix=none --preserve-date --formatted ---exclude=lv_conf_internal.h +--exclude=lv_conf_internal.h +--exclude=../src/lv_font/lv_font_roboto_12.c +--exclude=../src/lv_font/lv_font_roboto_12_subpx.c +--exclude=../src/lv_font/lv_font_roboto_16.c +--exclude=../src/lv_font/lv_font_roboto_22.c +--exclude=../src/lv_font/lv_font_roboto_28.c +--exclude=../src/lv_font/lv_font_roboto_28_compressed.c +--exclude=../src/lv_font/lv_font_unscii_8.c + diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index ab62cad28..642af074a 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -399,9 +399,9 @@ lv_res_t lv_obj_del(lv_obj_t * obj) bool act_scr_del = false; lv_obj_t * par = lv_obj_get_parent(obj); if(par == NULL) { - disp = lv_obj_get_disp(obj); - if(!disp) return LV_RES_INV; /*Shouldn't happen*/ - if(disp->act_scr == obj) act_scr_del = true; + disp = lv_obj_get_disp(obj); + if(!disp) return LV_RES_INV; /*Shouldn't happen*/ + if(disp->act_scr == obj) act_scr_del = true; } @@ -1290,9 +1290,10 @@ void lv_obj_refresh_style(lv_obj_t * obj, lv_style_property_t prop) lv_obj_invalidate(obj); if(prop == LV_STYLE_PROP_ALL || (prop & LV_STYLE_INHERIT_MASK)) - /*Send style change signals*/ - refresh_children_style(obj); - } else { + /*Send style change signals*/ + refresh_children_style(obj); + } + else { lv_obj_invalidate(obj); } } @@ -3040,7 +3041,7 @@ void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint8_t part, lv_draw_label_dsc_ } #if LV_USE_BIDI - draw_dsc->bidi_dir = lv_obj_get_base_dir(obj); + draw_dsc->bidi_dir = lv_obj_get_base_dir(obj); #endif } @@ -3110,10 +3111,10 @@ lv_coord_t lv_obj_get_draw_rect_ext_pad_size(lv_obj_t * obj, uint8_t part) { lv_coord_t s = 0; - lv_coord_t sh_width = lv_obj_get_style_shadow_width(obj, part); - if(sh_width) { - lv_opa_t sh_opa = lv_obj_get_style_shadow_opa(obj, part); - if(sh_opa > LV_OPA_MIN) { + lv_coord_t sh_width = lv_obj_get_style_shadow_width(obj, part); + if(sh_width) { + lv_opa_t sh_opa = lv_obj_get_style_shadow_opa(obj, part); + if(sh_opa > LV_OPA_MIN) { sh_width = sh_width / 2; /*THe blur adds only half width*/ sh_width++; sh_width += lv_obj_get_style_shadow_spread(obj, part); @@ -3124,10 +3125,10 @@ lv_coord_t lv_obj_get_draw_rect_ext_pad_size(lv_obj_t * obj, uint8_t part) } } - const char * value_str = lv_obj_get_style_value_str(obj, part); - if(value_str) { - lv_opa_t value_opa = lv_obj_get_style_value_opa(obj, part); - if(value_opa > LV_OPA_MIN) { + const char * value_str = lv_obj_get_style_value_str(obj, part); + if(value_str) { + lv_opa_t value_opa = lv_obj_get_style_value_opa(obj, part); + if(value_opa > LV_OPA_MIN) { lv_style_int_t letter_space = lv_obj_get_style_value_letter_space(obj, part); lv_style_int_t line_space = lv_obj_get_style_value_letter_space(obj, part); const lv_font_t * font = lv_obj_get_style_value_font(obj, part); @@ -3159,10 +3160,10 @@ lv_coord_t lv_obj_get_draw_rect_ext_pad_size(lv_obj_t * obj, uint8_t part) } } - lv_style_int_t outline_width = lv_obj_get_style_outline_width(obj, part); - if(outline_width) { - lv_opa_t outline_opa = lv_obj_get_style_outline_opa(obj, part); - if(outline_opa > LV_OPA_MIN) { + lv_style_int_t outline_width = lv_obj_get_style_outline_width(obj, part); + if(outline_width) { + lv_opa_t outline_opa = lv_obj_get_style_outline_opa(obj, part); + if(outline_opa > LV_OPA_MIN) { lv_style_int_t outline_pad = lv_obj_get_style_outline_pad(obj, part); s = LV_MATH_MAX(s, outline_pad + outline_width); } diff --git a/src/lv_core/lv_obj.h b/src/lv_core/lv_obj.h index 94f36c6b7..6088f8d5a 100644 --- a/src/lv_core/lv_obj.h +++ b/src/lv_core/lv_obj.h @@ -584,7 +584,8 @@ void _lv_obj_set_style_local_ptr(lv_obj_t * obj, uint8_t type, lv_style_property * For example: `lv_obj_style_get_trasition_path()` * @note for performance reasons it's not checked if the property really has pointer type */ -static inline void _lv_obj_set_style_local_func_ptr(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, lv_style_prop_cb_t value) +static inline void _lv_obj_set_style_local_func_ptr(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, + lv_style_prop_cb_t value) { lv_style_fptr_dptr_t fd; fd.fptr = value; @@ -603,7 +604,8 @@ static inline void _lv_obj_set_style_local_func_ptr(lv_obj_t * obj, uint8_t type * For example: `lv_obj_style_get_text_font()` * @note for performance reasons it's not checked if the property really has pointer type */ -static inline void _lv_obj_set_style_local_data_ptr(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, const void * value) +static inline void _lv_obj_set_style_local_data_ptr(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, + const void * value) { lv_style_fptr_dptr_t fd; fd.fptr = NULL; @@ -1089,7 +1091,8 @@ lv_style_fptr_dptr_t _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, l * For example: `lv_obj_style_get_trasition_path()` * @note for performance reasons it's not checked if the property really has pointer type */ -static inline lv_style_prop_cb_t _lv_obj_get_style_func_ptr(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop) +static inline lv_style_prop_cb_t _lv_obj_get_style_func_ptr(const lv_obj_t * obj, uint8_t part, + lv_style_property_t prop) { lv_style_fptr_dptr_t fd; fd = _lv_obj_get_style_ptr(obj, part, prop); diff --git a/src/lv_core/lv_obj_style_dec.h b/src/lv_core/lv_obj_style_dec.h index 8f6fb0864..27ba8e6da 100644 --- a/src/lv_core/lv_obj_style_dec.h +++ b/src/lv_core/lv_obj_style_dec.h @@ -101,22 +101,22 @@ extern "C" { } #define _OBJ_SET_STYLE_scalar(prop_name, func_name, value_type, style_type) \ - static inline void lv_style_set_##func_name (lv_style_t * style, lv_state_t state, value_type value) \ - { \ - _lv_style_set##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \ - } + static inline void lv_style_set_##func_name (lv_style_t * style, lv_state_t state, value_type value) \ + { \ + _lv_style_set##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \ + } #define _OBJ_SET_STYLE_nonscalar(prop_name, func_name, value_type, style_type) \ - static inline void lv_style_set_##func_name (lv_style_t * style, lv_state_t state, value_type value) \ - { \ - _lv_style_set##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \ - } + static inline void lv_style_set_##func_name (lv_style_t * style, lv_state_t state, value_type value) \ + { \ + _lv_style_set##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \ + } #define _OBJ_SET_STYLE_func_ptr(prop_name, func_name, value_type, style_type) \ - static inline void lv_style_set_##func_name (lv_style_t * style, lv_state_t state, value_type value) \ - { \ - _lv_style_set##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), FUNC_PTR_CAST(value)); \ - } \ + static inline void lv_style_set_##func_name (lv_style_t * style, lv_state_t state, value_type value) \ + { \ + _lv_style_set##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), FUNC_PTR_CAST(value)); \ + } \ #define _LV_OBJ_STYLE_SET_GET_DECLARE(prop_name, func_name, value_type, style_type, scalar) \ _OBJ_GET_STYLE_##scalar(prop_name, func_name, value_type, style_type) \ @@ -217,7 +217,8 @@ _LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_6, transition_prop_6, lv_style_int #if LV_USE_ANIMATION _LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path, lv_anim_path_cb_t, _func_ptr, func_ptr) #else -_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path,lv_style_prop_cb_t, _func_ptr, func_ptr) /*For compatibility*/ +_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path, lv_style_prop_cb_t, _func_ptr, + func_ptr) /*For compatibility*/ #endif _LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_WIDTH, scale_width, lv_style_int_t, _int, scalar) _LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_BORDER_WIDTH, scale_border_width, lv_style_int_t, _int, scalar) diff --git a/src/lv_core/lv_style.h b/src/lv_core/lv_style.h index 81fbce257..b9dafa4bc 100644 --- a/src/lv_core/lv_style.h +++ b/src/lv_core/lv_style.h @@ -218,7 +218,7 @@ typedef void(*lv_style_prop_cb_t)(void); typedef union { lv_style_prop_cb_t fptr; const void * dptr; -}lv_style_fptr_dptr_t; +} lv_style_fptr_dptr_t; typedef struct { @@ -512,8 +512,8 @@ static inline int16_t _lv_style_get_data_ptr(const lv_style_t * style, lv_style_ fd_res.fptr = NULL; lv_res_t r = _lv_style_get_ptr(style, prop, &fd_res); - void** res2 = (void**)res; - *res2 = (void*)fd_res.dptr; + void ** res2 = (void **)res; + *res2 = (void *)fd_res.dptr; return r; } @@ -587,7 +587,8 @@ void lv_style_list_set_local_ptr(lv_style_list_t * list, lv_style_property_t pro * @param value the value to set * @note for performance reasons it's not checked if the property really has pointer type */ -static inline void lv_style_list_set_local_func_ptr(lv_style_list_t * list, lv_style_property_t prop, lv_style_prop_cb_t value) +static inline void lv_style_list_set_local_func_ptr(lv_style_list_t * list, lv_style_property_t prop, + lv_style_prop_cb_t value) { lv_style_fptr_dptr_t fd; fd.dptr = NULL; @@ -603,7 +604,8 @@ static inline void lv_style_list_set_local_func_ptr(lv_style_list_t * list, lv_s * @param value the value to set * @note for performance reasons it's not checked if the property really has pointer type */ -static inline void lv_style_list_set_local_data_ptr(lv_style_list_t * list, lv_style_property_t prop, const void * value) +static inline void lv_style_list_set_local_data_ptr(lv_style_list_t * list, lv_style_property_t prop, + const void * value) { lv_style_fptr_dptr_t fd; fd.fptr = NULL; diff --git a/src/lv_draw/lv_draw_blend.c b/src/lv_draw/lv_draw_blend.c index 93d3fa736..674c77bcf 100644 --- a/src/lv_draw/lv_draw_blend.c +++ b/src/lv_draw/lv_draw_blend.c @@ -65,9 +65,9 @@ static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_co #define FILL_NORMAL_MASK_PX(out_x, color) \ if(*mask_tmp_x) { \ - if(*mask_tmp_x == LV_OPA_COVER) disp_buf_tmp[out_x] = color; \ - else if(disp_buf_tmp[out_x].full == color.full) disp_buf_tmp[out_x] = color; \ - else disp_buf_tmp[out_x] = lv_color_mix(color, disp_buf_tmp[out_x], *mask_tmp_x); \ + if(*mask_tmp_x == LV_OPA_COVER) disp_buf_tmp[out_x] = color; \ + else if(disp_buf_tmp[out_x].full == color.full) disp_buf_tmp[out_x] = color; \ + else disp_buf_tmp[out_x] = lv_color_mix(color, disp_buf_tmp[out_x], *mask_tmp_x); \ } \ mask_tmp_x++; @@ -75,18 +75,18 @@ static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_co #define FILL_NORMAL_MASK_PX_SCR_TRANSP(out_x, color) \ if(*mask_tmp_x) { \ if(*mask_tmp_x != last_mask || last_dest_color.full != disp_buf_tmp[out_x].full) { \ - if(disp->driver.screen_transp) { \ - lv_color_mix_with_alpha(disp_buf_tmp[x], disp_buf_tmp[out_x].ch.alpha, \ - color, *mask_tmp_x, &last_res_color, &last_res_color.ch.alpha); \ - } \ - else \ - { \ - if(*mask_tmp_x == LV_OPA_COVER) last_res_color = color; \ - else if(disp_buf_tmp[out_x].full == color.full) last_res_color = color; \ - else last_res_color = lv_color_mix(color, disp_buf_tmp[out_x], *mask_tmp_x); \ - last_mask = *mask_tmp_x; \ - last_dest_color.full = disp_buf_tmp[out_x].full; \ - } \ + if(disp->driver.screen_transp) { \ + lv_color_mix_with_alpha(disp_buf_tmp[x], disp_buf_tmp[out_x].ch.alpha, \ + color, *mask_tmp_x, &last_res_color, &last_res_color.ch.alpha); \ + } \ + else \ + { \ + if(*mask_tmp_x == LV_OPA_COVER) last_res_color = color; \ + else if(disp_buf_tmp[out_x].full == color.full) last_res_color = color; \ + else last_res_color = lv_color_mix(color, disp_buf_tmp[out_x], *mask_tmp_x); \ + last_mask = *mask_tmp_x; \ + last_dest_color.full = disp_buf_tmp[out_x].full; \ + } \ } \ disp_buf_tmp[out_x] = last_res_color; \ } \ @@ -379,30 +379,31 @@ static void fill_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, con #else for(x = draw_area->x1; x <= draw_area->x2 && ((lv_uintptr_t)mask_tmp_x & 0x3); x++) { #if LV_COLOR_SCREEN_TRANSP - FILL_NORMAL_MASK_PX_SCR_TRANSP(x, color) + FILL_NORMAL_MASK_PX_SCR_TRANSP(x, color) #else FILL_NORMAL_MASK_PX(x, color) #endif } uint32_t * mask32 = (uint32_t *) mask_tmp_x; - for(; x <= x_end4; x+= 4) { + for(; x <= x_end4; x += 4) { if(*mask32) { if((*mask32) == 0xFFFFFFFF) { disp_buf_tmp[x] = color; disp_buf_tmp[x + 1] = color; disp_buf_tmp[x + 2] = color; disp_buf_tmp[x + 3] = color; - } else { + } + else { mask_tmp_x = (const lv_opa_t *)mask32; #if LV_COLOR_SCREEN_TRANSP FILL_NORMAL_MASK_PX_SCR_TRANSP(x, color) - FILL_NORMAL_MASK_PX_SCR_TRANSP(x + 1 , color) + FILL_NORMAL_MASK_PX_SCR_TRANSP(x + 1, color) FILL_NORMAL_MASK_PX_SCR_TRANSP(x + 2, color) FILL_NORMAL_MASK_PX_SCR_TRANSP(x + 3, color) #else FILL_NORMAL_MASK_PX(x, color) - FILL_NORMAL_MASK_PX(x + 1 , color) + FILL_NORMAL_MASK_PX(x + 1, color) FILL_NORMAL_MASK_PX(x + 2, color) FILL_NORMAL_MASK_PX(x + 3, color) #endif @@ -414,7 +415,7 @@ static void fill_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, con mask_tmp_x = (const lv_opa_t *)mask32; for(; x <= draw_area->x2 ; x++) { #if LV_COLOR_SCREEN_TRANSP - FILL_NORMAL_MASK_PX_SCR_TRANSP(x, color) + FILL_NORMAL_MASK_PX_SCR_TRANSP(x, color) #else FILL_NORMAL_MASK_PX(x, color) #endif @@ -431,12 +432,13 @@ static void fill_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, con const lv_opa_t * mask_tmp_x = &mask_tmp[draw_area->x1]; for(x = draw_area->x1; x <= draw_area->x2; x++) { if(*mask_tmp_x) { - if(*mask_tmp_x != last_mask) opa_tmp = *mask_tmp_x == LV_OPA_COVER ? opa : (uint32_t)((uint32_t)(*mask_tmp_x) * opa) >> 8; + if(*mask_tmp_x != last_mask) opa_tmp = *mask_tmp_x == LV_OPA_COVER ? opa : (uint32_t)((uint32_t)( + *mask_tmp_x) * opa) >> 8; if(*mask_tmp_x != last_mask || last_dest_color.full != disp_buf_tmp[x].full) { #if LV_COLOR_SCREEN_TRANSP if(disp->driver.screen_transp) { lv_color_mix_with_alpha(disp_buf_tmp[x], disp_buf_tmp[x].ch.alpha, color, opa_tmp, &last_res_color, - &last_res_color.ch.alpha); + &last_res_color.ch.alpha); } else #endif @@ -682,14 +684,14 @@ static void map_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, cons for(y = draw_area->y1; y <= draw_area->y2; y++) { for(x = draw_area->x1; x <= draw_area->x2; x++) { if(mask_tmp[x]) { - #if LV_COLOR_SCREEN_TRANSP +#if LV_COLOR_SCREEN_TRANSP if(disp->driver.screen_transp) { lv_color_mix_with_alpha(disp_buf_tmp[x], disp_buf_tmp[x].ch.alpha, map_buf_tmp[x], mask_tmp[x], &res_color, &opa_composed); res_color.ch.alpha = opa_composed; } else - #endif +#endif { if(mask_tmp[x] > LV_OPA_MAX) res_color = map_buf_tmp[x]; else res_color = lv_color_mix(map_buf_tmp[x], disp_buf_tmp[x], mask_tmp[x]); @@ -709,13 +711,13 @@ static void map_normal(const lv_area_t * disp_area, lv_color_t * disp_buf, cons for(x = draw_area->x1; x <= draw_area->x2; x++) { if(mask_tmp[x]) { lv_opa_t opa_tmp = mask_tmp[x] >= LV_OPA_MAX ? opa : ((opa * mask_tmp[x]) >> 8); - #if LV_COLOR_SCREEN_TRANSP +#if LV_COLOR_SCREEN_TRANSP if(disp->driver.screen_transp) { lv_color_mix_with_alpha(disp_buf_tmp[x], disp_buf_tmp[x].ch.alpha, map_buf_tmp[x], opa_tmp, &disp_buf_tmp[x], &disp_buf_tmp[x].ch.alpha); } else - #endif +#endif { disp_buf_tmp[x] = lv_color_mix(map_buf_tmp[x], disp_buf_tmp[x], opa_tmp); } diff --git a/src/lv_draw/lv_draw_img.c b/src/lv_draw/lv_draw_img.c index c4564226a..d1bcfc18b 100644 --- a/src/lv_draw/lv_draw_img.c +++ b/src/lv_draw/lv_draw_img.c @@ -390,7 +390,7 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area, /*Prepare the `mask_buf`if there are other masks*/ if(other_mask_cnt) { - lv_memset_ff(mask_buf,mask_buf_size); + lv_memset_ff(mask_buf, mask_buf_size); } lv_coord_t draw_area_h = lv_area_get_height(&draw_area); @@ -405,26 +405,26 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area, for(y = 0; y < draw_area_h; y++) { map_px = map_buf_tmp; for(x = 0; x < draw_area_w; x++, map_px += px_size_byte, px_i++) { - lv_opa_t px_opa = map_px[LV_IMG_PX_SIZE_ALPHA_BYTE - 1]; - mask_buf[px_i] = px_opa; - if(px_opa < LV_OPA_MIN) { + lv_opa_t px_opa = map_px[LV_IMG_PX_SIZE_ALPHA_BYTE - 1]; + mask_buf[px_i] = px_opa; + if(px_opa < LV_OPA_MIN) { #if LV_COLOR_DEPTH == 32 - map2[px_i].ch.alpha = 0xFF; + map2[px_i].ch.alpha = 0xFF; #endif - continue; - } + continue; + } - #if LV_COLOR_DEPTH == 8 - c.full = map_px[0]; - #elif LV_COLOR_DEPTH == 16 - c.full = map_px[0] + (map_px[1] << 8); - #elif LV_COLOR_DEPTH == 32 - c.full = *((uint32_t *)map_px); - #endif +#if LV_COLOR_DEPTH == 8 + c.full = map_px[0]; +#elif LV_COLOR_DEPTH == 16 + c.full = map_px[0] + (map_px[1] << 8); +#elif LV_COLOR_DEPTH == 32 + c.full = *((uint32_t *)map_px); +#endif map2[px_i].full = c.full; } - map_buf_tmp += map_w * px_size_byte; + map_buf_tmp += map_w * px_size_byte; if(px_i + lv_area_get_width(&draw_area) < mask_buf_size) { blend_area.y2 ++; } @@ -449,134 +449,133 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area, /*Most complicated case: transform or other mask or chroma keyed*/ else { - lv_img_transform_dsc_t trans_dsc; - lv_memset_00(&trans_dsc, sizeof(lv_img_transform_dsc_t)); - if(transform) { - lv_img_cf_t cf = LV_IMG_CF_TRUE_COLOR; - if(alpha_byte) cf = LV_IMG_CF_TRUE_COLOR_ALPHA; - else if(chroma_key) cf = LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED; + lv_img_transform_dsc_t trans_dsc; + lv_memset_00(&trans_dsc, sizeof(lv_img_transform_dsc_t)); + if(transform) { + lv_img_cf_t cf = LV_IMG_CF_TRUE_COLOR; + if(alpha_byte) cf = LV_IMG_CF_TRUE_COLOR_ALPHA; + else if(chroma_key) cf = LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED; - trans_dsc.cfg.angle = draw_dsc->angle; - trans_dsc.cfg.zoom = draw_dsc->zoom; - trans_dsc.cfg.src = map_p; - trans_dsc.cfg.src_w = map_w; - trans_dsc.cfg.src_h = map_h; - trans_dsc.cfg.cf = cf; - trans_dsc.cfg.pivot_x = draw_dsc->pivot.x; - trans_dsc.cfg.pivot_y = draw_dsc->pivot.y; - trans_dsc.cfg.color = draw_dsc->recolor; - trans_dsc.cfg.antialias = draw_dsc->antialias; + trans_dsc.cfg.angle = draw_dsc->angle; + trans_dsc.cfg.zoom = draw_dsc->zoom; + trans_dsc.cfg.src = map_p; + trans_dsc.cfg.src_w = map_w; + trans_dsc.cfg.src_h = map_h; + trans_dsc.cfg.cf = cf; + trans_dsc.cfg.pivot_x = draw_dsc->pivot.x; + trans_dsc.cfg.pivot_y = draw_dsc->pivot.y; + trans_dsc.cfg.color = draw_dsc->recolor; + trans_dsc.cfg.antialias = draw_dsc->antialias; - lv_img_buf_transform_init(&trans_dsc); - } + lv_img_buf_transform_init(&trans_dsc); + } - uint16_t recolor_premult[3] = {0}; - lv_opa_t recolor_opa_inv = 255 - draw_dsc->recolor_opa; - if(draw_dsc->recolor_opa != 0) { - lv_color_premult(draw_dsc->recolor, draw_dsc->recolor_opa, recolor_premult); - } + uint16_t recolor_premult[3] = {0}; + lv_opa_t recolor_opa_inv = 255 - draw_dsc->recolor_opa; + if(draw_dsc->recolor_opa != 0) { + lv_color_premult(draw_dsc->recolor, draw_dsc->recolor_opa, recolor_premult); + } - lv_draw_mask_res_t mask_res; - mask_res = (alpha_byte || chroma_key || draw_dsc->angle) ? LV_DRAW_MASK_RES_CHANGED : LV_DRAW_MASK_RES_FULL_COVER; - int32_t x; - int32_t y; - for(y = 0; y < draw_area_h; y++) { - map_px = map_buf_tmp; - uint32_t px_i_start = px_i; + lv_draw_mask_res_t mask_res; + mask_res = (alpha_byte || chroma_key || draw_dsc->angle) ? LV_DRAW_MASK_RES_CHANGED : LV_DRAW_MASK_RES_FULL_COVER; + int32_t x; + int32_t y; + for(y = 0; y < draw_area_h; y++) { + map_px = map_buf_tmp; + uint32_t px_i_start = px_i; - for(x = 0; x < draw_area_w; x++, map_px += px_size_byte, px_i++) { + for(x = 0; x < draw_area_w; x++, map_px += px_size_byte, px_i++) { - if(transform == false) - { - if(alpha_byte) { - lv_opa_t px_opa = map_px[LV_IMG_PX_SIZE_ALPHA_BYTE - 1]; - mask_buf[px_i] = px_opa; - if(px_opa < LV_OPA_MIN) { - #if LV_COLOR_DEPTH == 32 - map2[px_i].ch.alpha = 0xFF; - #endif - continue; - } - } - else { - mask_buf[px_i] = LV_OPA_COVER; - } + if(transform == false) { + if(alpha_byte) { + lv_opa_t px_opa = map_px[LV_IMG_PX_SIZE_ALPHA_BYTE - 1]; + mask_buf[px_i] = px_opa; + if(px_opa < LV_OPA_MIN) { +#if LV_COLOR_DEPTH == 32 + map2[px_i].ch.alpha = 0xFF; +#endif + continue; + } + } + else { + mask_buf[px_i] = LV_OPA_COVER; + } - #if LV_COLOR_DEPTH == 8 - c.full = map_px[0]; - #elif LV_COLOR_DEPTH == 16 - c.full = map_px[0] + (map_px[1] << 8); - #elif LV_COLOR_DEPTH == 32 - c.full = *((uint32_t *)map_px); - #endif - if(chroma_key) { - if(c.full == chroma_keyed_color.full) { - mask_buf[px_i] = LV_OPA_TRANSP; - continue; - } - } - } - else { - /*Rotate*/ - bool ret; - int32_t rot_x = x + (disp_area->x1 + draw_area.x1) - map_area->x1; - int32_t rot_y = y + (disp_area->y1 + draw_area.y1) - map_area->y1; - ret = lv_img_buf_transform(&trans_dsc, rot_x, rot_y); - if(ret == false) { - mask_buf[px_i] = LV_OPA_TRANSP; - continue; - } - else { - mask_buf[px_i] = trans_dsc.res.opa; - c.full = trans_dsc.res.color.full; - } - } +#if LV_COLOR_DEPTH == 8 + c.full = map_px[0]; +#elif LV_COLOR_DEPTH == 16 + c.full = map_px[0] + (map_px[1] << 8); +#elif LV_COLOR_DEPTH == 32 + c.full = *((uint32_t *)map_px); +#endif + if(chroma_key) { + if(c.full == chroma_keyed_color.full) { + mask_buf[px_i] = LV_OPA_TRANSP; + continue; + } + } + } + else { + /*Rotate*/ + bool ret; + int32_t rot_x = x + (disp_area->x1 + draw_area.x1) - map_area->x1; + int32_t rot_y = y + (disp_area->y1 + draw_area.y1) - map_area->y1; + ret = lv_img_buf_transform(&trans_dsc, rot_x, rot_y); + if(ret == false) { + mask_buf[px_i] = LV_OPA_TRANSP; + continue; + } + else { + mask_buf[px_i] = trans_dsc.res.opa; + c.full = trans_dsc.res.color.full; + } + } - if(draw_dsc->recolor_opa != 0) { - c = lv_color_mix_premult(recolor_premult, c, recolor_opa_inv); - } + if(draw_dsc->recolor_opa != 0) { + c = lv_color_mix_premult(recolor_premult, c, recolor_opa_inv); + } - map2[px_i].full = c.full; - } + map2[px_i].full = c.full; + } - /*Apply the masks if any*/ - if(other_mask_cnt) { - lv_draw_mask_res_t mask_res_sub; - mask_res_sub = lv_draw_mask_apply(mask_buf + px_i_start, draw_area.x1 + vdb->area.x1, y + draw_area.y1 + vdb->area.y1, - lv_area_get_width(&draw_area)); - if(mask_res_sub == LV_DRAW_MASK_RES_FULL_TRANSP) { - lv_memset_00(mask_buf + px_i_start, lv_area_get_width(&draw_area)); - mask_res = LV_DRAW_MASK_RES_CHANGED; - } - else if(mask_res_sub == LV_DRAW_MASK_RES_CHANGED) { - mask_res = LV_DRAW_MASK_RES_CHANGED; - } - } + /*Apply the masks if any*/ + if(other_mask_cnt) { + lv_draw_mask_res_t mask_res_sub; + mask_res_sub = lv_draw_mask_apply(mask_buf + px_i_start, draw_area.x1 + vdb->area.x1, y + draw_area.y1 + vdb->area.y1, + lv_area_get_width(&draw_area)); + if(mask_res_sub == LV_DRAW_MASK_RES_FULL_TRANSP) { + lv_memset_00(mask_buf + px_i_start, lv_area_get_width(&draw_area)); + mask_res = LV_DRAW_MASK_RES_CHANGED; + } + else if(mask_res_sub == LV_DRAW_MASK_RES_CHANGED) { + mask_res = LV_DRAW_MASK_RES_CHANGED; + } + } - map_buf_tmp += map_w * px_size_byte; - if(px_i + lv_area_get_width(&draw_area) < mask_buf_size) { - blend_area.y2 ++; - } - else { - lv_blend_map(clip_area, &blend_area, map2, mask_buf, mask_res, draw_dsc->opa, draw_dsc->blend_mode); + map_buf_tmp += map_w * px_size_byte; + if(px_i + lv_area_get_width(&draw_area) < mask_buf_size) { + blend_area.y2 ++; + } + else { + lv_blend_map(clip_area, &blend_area, map2, mask_buf, mask_res, draw_dsc->opa, draw_dsc->blend_mode); - blend_area.y1 = blend_area.y2 + 1; - blend_area.y2 = blend_area.y1; + blend_area.y1 = blend_area.y2 + 1; + blend_area.y2 = blend_area.y1; - px_i = 0; - mask_res = (alpha_byte || chroma_key || draw_dsc->angle) ? LV_DRAW_MASK_RES_CHANGED : LV_DRAW_MASK_RES_FULL_COVER; + px_i = 0; + mask_res = (alpha_byte || chroma_key || draw_dsc->angle) ? LV_DRAW_MASK_RES_CHANGED : LV_DRAW_MASK_RES_FULL_COVER; - /*Prepare the `mask_buf`if there are other masks*/ - if(other_mask_cnt) { - lv_memset_ff(mask_buf, mask_buf_size); - } - } - } - /*Flush the last part*/ - if(blend_area.y1 != blend_area.y2) { - blend_area.y2--; - lv_blend_map(clip_area, &blend_area, map2, mask_buf, mask_res, draw_dsc->opa, draw_dsc->blend_mode); - } + /*Prepare the `mask_buf`if there are other masks*/ + if(other_mask_cnt) { + lv_memset_ff(mask_buf, mask_buf_size); + } + } + } + /*Flush the last part*/ + if(blend_area.y1 != blend_area.y2) { + blend_area.y2--; + lv_blend_map(clip_area, &blend_area, map2, mask_buf, mask_res, draw_dsc->opa, draw_dsc->blend_mode); + } } lv_mem_buf_release(mask_buf); diff --git a/src/lv_draw/lv_draw_label.c b/src/lv_draw/lv_draw_label.c index 93b860a45..42eeb95ee 100644 --- a/src/lv_draw/lv_draw_label.c +++ b/src/lv_draw/lv_draw_label.c @@ -52,7 +52,8 @@ static const uint8_t bpp2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping w static const uint8_t bpp4_opa_table[16] = {0, 17, 34, 51, /*Opacity mapping with bpp = 4*/ 68, 85, 102, 119, 136, 153, 170, 187, - 204, 221, 238, 255}; + 204, 221, 238, 255 + }; static const uint8_t bpp8_opa_table[256] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, @@ -68,7 +69,8 @@ static const uint8_t bpp8_opa_table[256] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, - 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255}; + 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 + }; /*clang-format on*/ /********************** @@ -518,42 +520,42 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph uint8_t other_mask_cnt = lv_draw_mask_get_cnt(); uint32_t col_bit_max = 8 - bpp; - uint32_t col_bit_row_ofs = (box_w + col_start- col_end) * bpp; + uint32_t col_bit_row_ofs = (box_w + col_start - col_end) * bpp; for(row = row_start ; row < row_end; row++) { int32_t mask_p_start = mask_p; bitmask = bitmask_init >> col_bit; - for(col = col_start; col < col_end; col++) { - /*Load the pixel's opacity into the mask*/ - letter_px = (*map_p & bitmask) >> (col_bit_max - col_bit); - if(letter_px) { - mask_buf[mask_p] = bpp_opa_table_p[letter_px]; - } - else { - mask_buf[mask_p] = 0; - } + for(col = col_start; col < col_end; col++) { + /*Load the pixel's opacity into the mask*/ + letter_px = (*map_p & bitmask) >> (col_bit_max - col_bit); + if(letter_px) { + mask_buf[mask_p] = bpp_opa_table_p[letter_px]; + } + else { + mask_buf[mask_p] = 0; + } - /*Go to the next column*/ - if(col_bit < col_bit_max) { - col_bit += bpp; - bitmask = bitmask >> bpp; - } - else { - col_bit = 0; - bitmask = bitmask_init; - map_p++; - } + /*Go to the next column*/ + if(col_bit < col_bit_max) { + col_bit += bpp; + bitmask = bitmask >> bpp; + } + else { + col_bit = 0; + bitmask = bitmask_init; + map_p++; + } - /*Next mask byte*/ - mask_p++; - } + /*Next mask byte*/ + mask_p++; + } /*Apply masks if any*/ if(other_mask_cnt) { lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf + mask_p_start, fill_area.x1, fill_area.y2, - lv_area_get_width(&fill_area)); + lv_area_get_width(&fill_area)); if(mask_res == LV_DRAW_MASK_RES_FULL_TRANSP) { lv_memset_00(mask_buf + mask_p_start, lv_area_get_width(&fill_area)); } @@ -564,8 +566,8 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph } else { lv_blend_fill(clip_area, &fill_area, - color, mask_buf, LV_DRAW_MASK_RES_CHANGED, LV_OPA_COVER, - LV_BLEND_MODE_NORMAL); + color, mask_buf, LV_DRAW_MASK_RES_CHANGED, LV_OPA_COVER, + LV_BLEND_MODE_NORMAL); fill_area.y1 = fill_area.y2 + 1; fill_area.y2 = fill_area.y1; diff --git a/src/lv_draw/lv_draw_mask.c b/src/lv_draw/lv_draw_mask.c index b1e3b9a0f..6c3a38fa8 100644 --- a/src/lv_draw/lv_draw_mask.c +++ b/src/lv_draw/lv_draw_mask.c @@ -651,7 +651,7 @@ static lv_draw_mask_res_t line_mask_steep(lv_opa_t * mask_buf, lv_coord_t abs_x, if(k >= len) { return LV_DRAW_MASK_RES_FULL_TRANSP; } - if(k >= 0) lv_memset_00(&mask_buf[0],k); + if(k >= 0) lv_memset_00(&mask_buf[0], k); } else { @@ -979,7 +979,7 @@ static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t ab return LV_DRAW_MASK_RES_FULL_TRANSP; } if(kr <= len) { - lv_memset_00(&mask_buf[kr],len - kr); + lv_memset_00(&mask_buf[kr], len - kr); } } else { diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index 617da0a0c..60f0ffdc4 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -19,7 +19,7 @@ *********************/ #define SHADOW_UPSACALE_SHIFT 6 #define SHADOW_ENHANCE 1 -#define SPLIT_LIMIT 50 +#define SPLIT_LIMIT 50 /********************** * TYPEDEFS diff --git a/src/lv_font/lv_font_fmt_txt.c b/src/lv_font/lv_font_fmt_txt.c index f50cbbe41..11747e510 100644 --- a/src/lv_font/lv_font_fmt_txt.c +++ b/src/lv_font/lv_font_fmt_txt.c @@ -379,15 +379,26 @@ static inline void decompress_line(uint8_t * out, lv_coord_t w) */ static inline uint8_t get_bits(const uint8_t * in, uint32_t bit_pos, uint8_t len) { - uint8_t bit_mask; - switch(len) { - case 1: bit_mask = 0x1; break; - case 2: bit_mask = 0x3; break; - case 3: bit_mask = 0x7; break; - case 4: bit_mask = 0xF; break; - case 8: bit_mask = 0xFF; break; - default: bit_mask = (uint16_t)((uint16_t) 1 << len) - 1; - } + uint8_t bit_mask; + switch(len) { + case 1: + bit_mask = 0x1; + break; + case 2: + bit_mask = 0x3; + break; + case 3: + bit_mask = 0x7; + break; + case 4: + bit_mask = 0xF; + break; + case 8: + bit_mask = 0xFF; + break; + default: + bit_mask = (uint16_t)((uint16_t) 1 << len) - 1; + } uint32_t byte_pos = bit_pos >> 3; bit_pos = bit_pos & 0x7; diff --git a/src/lv_misc/lv_color.h b/src/lv_misc/lv_color.h index 4c18f0ed8..2ac45fbe3 100644 --- a/src/lv_misc/lv_color.h +++ b/src/lv_misc/lv_color.h @@ -447,14 +447,14 @@ static inline lv_color_t lv_color_mix(lv_color_t c1, lv_color_t c2, uint8_t mix) static inline void lv_color_premult(lv_color_t c, uint8_t mix, uint16_t * out) { #if LV_COLOR_DEPTH != 1 - out[0] = (uint16_t) LV_COLOR_GET_R(c) * mix; - out[1] = (uint16_t) LV_COLOR_GET_G(c) * mix; - out[2] = (uint16_t) LV_COLOR_GET_B(c) * mix; + out[0] = (uint16_t) LV_COLOR_GET_R(c) * mix; + out[1] = (uint16_t) LV_COLOR_GET_G(c) * mix; + out[2] = (uint16_t) LV_COLOR_GET_B(c) * mix; #else - /*Pre-multiplication can't be used with 1 bpp*/ - out[0] = LV_COLOR_GET_R(c); - out[1] = LV_COLOR_GET_G(c); - out[2] = LV_COLOR_GET_B(c); + /*Pre-multiplication can't be used with 1 bpp*/ + out[0] = LV_COLOR_GET_R(c); + out[1] = LV_COLOR_GET_G(c); + out[2] = LV_COLOR_GET_B(c); #endif } @@ -468,7 +468,7 @@ static inline void lv_color_premult(lv_color_t c, uint8_t mix, uint16_t * out) * @return the mixed color * @note 255 won't give clearly `c1`. */ -static inline lv_color_t lv_color_mix_premult(uint16_t * premult_c1 , lv_color_t c2, uint8_t mix) +static inline lv_color_t lv_color_mix_premult(uint16_t * premult_c1, lv_color_t c2, uint8_t mix) { lv_color_t ret; #if LV_COLOR_DEPTH != 1 diff --git a/src/lv_misc/lv_log.c b/src/lv_misc/lv_log.c index 26bc75544..c8dbf0728 100644 --- a/src/lv_misc/lv_log.c +++ b/src/lv_misc/lv_log.c @@ -85,7 +85,7 @@ void lv_log_add(lv_log_level_t level, const char * file, int line, const char * } static const char * lvl_prefix[] = {"Trace", "Info", "Warn", "Error", "User"}; - printf("%s: %s \t(%s #%d %s())\n", lvl_prefix[level], buf, &file[p], line ,func); + printf("%s: %s \t(%s #%d %s())\n", lvl_prefix[level], buf, &file[p], line, func); #else if(custom_print_cb) custom_print_cb(level, file, line, func, buf); #endif diff --git a/src/lv_misc/lv_mem.c b/src/lv_misc/lv_mem.c index 249c9a983..4b7ae77f6 100644 --- a/src/lv_misc/lv_mem.c +++ b/src/lv_misc/lv_mem.c @@ -57,9 +57,9 @@ typedef struct { #endif /* LV_ENABLE_GC */ #ifdef LV_ARCH_64 -#define ALIGN_MASK 0x7 + #define ALIGN_MASK 0x7 #else -#define ALIGN_MASK 0x3 + #define ALIGN_MASK 0x3 #endif /********************** @@ -519,59 +519,59 @@ void lv_mem_buf_free_all(void) */ void * lv_memcpy(void * dst, const void * src, size_t len) { - uint8_t * d8 = dst; - const uint8_t * s8 = src; + uint8_t * d8 = dst; + const uint8_t * s8 = src; - lv_uintptr_t d_align = (lv_uintptr_t)d8 & ALIGN_MASK; - lv_uintptr_t s_align = (lv_uintptr_t)s8 & ALIGN_MASK; + lv_uintptr_t d_align = (lv_uintptr_t)d8 & ALIGN_MASK; + lv_uintptr_t s_align = (lv_uintptr_t)s8 & ALIGN_MASK; - /*Byte copy for unaligned memories*/ - if(s_align != d_align) { - while(len > 32) { - REPEAT8(COPY8); + /*Byte copy for unaligned memories*/ + if(s_align != d_align) { + while(len > 32) { REPEAT8(COPY8); REPEAT8(COPY8); REPEAT8(COPY8); - len -= 32; - } - while(len) { - COPY8 - len--; - } - return dst; - } + REPEAT8(COPY8); + len -= 32; + } + while(len) { + COPY8 + len--; + } + return dst; + } - /*Make the memories aligned*/ - if(d_align) { - d_align = ALIGN_MASK + 1 - d_align; + /*Make the memories aligned*/ + if(d_align) { + d_align = ALIGN_MASK + 1 - d_align; while(d_align && len) { COPY8; d_align--; len--; } - } + } - uint32_t * d32 = (uint32_t*)d8; - const uint32_t * s32 = (uint32_t*)s8; - while(len > 32) { - REPEAT8(COPY32) - len -= 32; - } + uint32_t * d32 = (uint32_t *)d8; + const uint32_t * s32 = (uint32_t *)s8; + while(len > 32) { + REPEAT8(COPY32) + len -= 32; + } - while(len > 4) { - COPY32; - len -= 4; - } + while(len > 4) { + COPY32; + len -= 4; + } - d8 = (uint8_t *)d32; - s8 = (const uint8_t *)s32; - while(len) { - COPY8 - len--; - } + d8 = (uint8_t *)d32; + s8 = (const uint8_t *)s32; + while(len) { + COPY8 + len--; + } - return dst; + return dst; } @@ -585,11 +585,11 @@ void * lv_memcpy(void * dst, const void * src, size_t len) void lv_memset(void * dst, uint8_t v, size_t len) { - uint8_t * d8 = (uint8_t *) dst; + uint8_t * d8 = (uint8_t *) dst; - uintptr_t d_align = (lv_uintptr_t) d8 & ALIGN_MASK; + uintptr_t d_align = (lv_uintptr_t) d8 & ALIGN_MASK; - /*Make the address aligned*/ + /*Make the address aligned*/ if(d_align) { d_align = ALIGN_MASK + 1 - d_align; while(d_align && len) { @@ -600,34 +600,34 @@ void lv_memset(void * dst, uint8_t v, size_t len) } } - uint32_t v32 = v + (v << 8) + (v << 16) + (v << 24); + uint32_t v32 = v + (v << 8) + (v << 16) + (v << 24); - uint32_t * d32 = (uint32_t*)d8; + uint32_t * d32 = (uint32_t *)d8; - while(len > 32) { - SET32(v32); - SET32(v32); - SET32(v32); - SET32(v32); - SET32(v32); - SET32(v32); - SET32(v32); - SET32(v32); - len -= 32; - } + while(len > 32) { + SET32(v32); + SET32(v32); + SET32(v32); + SET32(v32); + SET32(v32); + SET32(v32); + SET32(v32); + SET32(v32); + len -= 32; + } - while(len > 4) { - SET32(v32); - len -= 4; - } + while(len > 4) { + SET32(v32); + len -= 4; + } - d8 = (uint8_t *)d32; - while(len) { - *d8 = v; - d8++; - len--; - } + d8 = (uint8_t *)d32; + while(len) { + *d8 = v; + d8++; + len--; + } } /** @@ -638,7 +638,7 @@ void lv_memset(void * dst, uint8_t v, size_t len) */ void lv_memset_00(void * dst, size_t len) { - uint8_t * d8 = (uint8_t*) dst; + uint8_t * d8 = (uint8_t *) dst; uintptr_t d_align = (lv_uintptr_t) d8 & ALIGN_MASK; @@ -653,31 +653,31 @@ void lv_memset_00(void * dst, size_t len) } } - uint32_t * d32 = (uint32_t*)d8; - while(len > 32) { - SET32(0); - SET32(0); - SET32(0); - SET32(0); - SET32(0); - SET32(0); - SET32(0); - SET32(0); - len -= 32; - } + uint32_t * d32 = (uint32_t *)d8; + while(len > 32) { + SET32(0); + SET32(0); + SET32(0); + SET32(0); + SET32(0); + SET32(0); + SET32(0); + SET32(0); + len -= 32; + } - while(len > 4) { - SET32(0); - len -= 4; - } + while(len > 4) { + SET32(0); + len -= 4; + } - d8 = (uint8_t *)d32; - while(len) { - *d8 = 0; - d8++; - len--; - } + d8 = (uint8_t *)d32; + while(len) { + *d8 = 0; + d8++; + len--; + } } /** @@ -688,7 +688,7 @@ void lv_memset_00(void * dst, size_t len) */ void lv_memset_ff(void * dst, size_t len) { - uint8_t * d8 = (uint8_t*) dst; + uint8_t * d8 = (uint8_t *) dst; uintptr_t d_align = (lv_uintptr_t) d8 & ALIGN_MASK; @@ -703,31 +703,31 @@ void lv_memset_ff(void * dst, size_t len) } } - uint32_t * d32 = (uint32_t*)d8; - while(len > 32) { - SET32(0xFFFFFFFF); - SET32(0xFFFFFFFF); - SET32(0xFFFFFFFF); - SET32(0xFFFFFFFF); - SET32(0xFFFFFFFF); - SET32(0xFFFFFFFF); - SET32(0xFFFFFFFF); - SET32(0xFFFFFFFF); - len -= 32; - } + uint32_t * d32 = (uint32_t *)d8; + while(len > 32) { + SET32(0xFFFFFFFF); + SET32(0xFFFFFFFF); + SET32(0xFFFFFFFF); + SET32(0xFFFFFFFF); + SET32(0xFFFFFFFF); + SET32(0xFFFFFFFF); + SET32(0xFFFFFFFF); + SET32(0xFFFFFFFF); + len -= 32; + } - while(len > 4) { - SET32(0xFFFFFFFF); - len -= 4; - } + while(len > 4) { + SET32(0xFFFFFFFF); + len -= 4; + } - d8 = (uint8_t *)d32; - while(len) { - *d8 = 0xFF; - d8++; - len--; - } + d8 = (uint8_t *)d32; + while(len) { + *d8 = 0xFF; + d8++; + len--; + } } diff --git a/src/lv_misc/lv_utils.c b/src/lv_misc/lv_utils.c index 1939af6f9..c8f44ec87 100644 --- a/src/lv_misc/lv_utils.c +++ b/src/lv_misc/lv_utils.c @@ -10,6 +10,8 @@ #include "lv_utils.h" #include "lv_math.h" +#include "lv_printf.h" +#include "lv_txt.h" /********************* * DEFINES @@ -26,6 +28,7 @@ /********************** * STATIC VARIABLES **********************/ +static char decimal_separator[2] = "."; /********************** * MACROS @@ -72,6 +75,31 @@ char * lv_utils_num_to_str(int32_t num, char * buf) return buf; } +/** + * Convert a fixed point number to string + * @param num a number + * @param decimals number of digits after decimal point + * @param buf pointer to a `char` buffer + * @param bufsize length of buffer + * @return same as `buf` (just for convenience) + */ +char * lv_utils_num_to_str_fixed(int32_t num, int32_t decimals, char * buf, size_t bufsize) +{ + lv_snprintf(buf, bufsize, "%0*d", decimals+1, num); + if(decimals > 0) + lv_txt_ins(buf, strlen(buf) - decimals, decimal_separator); + return buf; +} + +/** + * Set the decimal separator character used by lv_utils_num_to_str_fixed + * @param separator the decimal separator char + */ +void lv_utils_set_decimal_separator(char separator) +{ + decimal_separator[0] = separator; +} + /** Searches base[0] to base[n - 1] for an item that matches *key. * * @note The function cmp must return negative if its first diff --git a/src/lv_misc/lv_utils.h b/src/lv_misc/lv_utils.h index 6eed79501..e2a61d6ee 100644 --- a/src/lv_misc/lv_utils.h +++ b/src/lv_misc/lv_utils.h @@ -35,6 +35,22 @@ extern "C" { */ char * lv_utils_num_to_str(int32_t num, char * buf); +/** + * Convert a fixed point number to string + * @param num a number + * @param decimals number of digits after decimal point + * @param buf pointer to a `char` buffer + * @param bufsize length of buffer + * @return same as `buf` (just for convenience) + */ +char * lv_utils_num_to_str_fixed(int32_t num, int32_t decimals, char * buf, size_t bufsize); + +/** + * Set the decimal separator character used by lv_utils_num_to_str_fixed + * @param separator the decimal separator char + */ +void lv_utils_set_decimal_separator(char separator); + /** Searches base[0] to base[n - 1] for an item that matches *key. * * @note The function cmp must return negative if its first diff --git a/src/lv_themes/lv_theme_material.c b/src/lv_themes/lv_theme_material.c index 9a63ae525..5be4f8972 100644 --- a/src/lv_themes/lv_theme_material.c +++ b/src/lv_themes/lv_theme_material.c @@ -760,7 +760,8 @@ static void tabview_init(void) lv_style_init(&tabview_btns_bg); lv_style_set_bg_opa(&tabview_btns_bg, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_color(&tabview_btns_bg, LV_STATE_DEFAULT, COLOR_BG); - lv_style_set_border_color(&tabview_btns_bg, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0xe4eaf0) : lv_color_hex(0x3b3e42)); + lv_style_set_border_color(&tabview_btns_bg, LV_STATE_DEFAULT, + IS_LIGHT ? lv_color_hex(0xe4eaf0) : lv_color_hex(0x3b3e42)); lv_style_set_border_width(&tabview_btns_bg, LV_STATE_DEFAULT, LV_DPI / 30 > 0 ? LV_DPI / 30 : 1); lv_style_set_border_side(&tabview_btns_bg, LV_STATE_DEFAULT, LV_BORDER_SIDE_BOTTOM); lv_style_set_text_color(&tabview_btns_bg, LV_STATE_DEFAULT, COLOR_SCR_TEXT); diff --git a/src/lv_themes/lv_theme_material.h b/src/lv_themes/lv_theme_material.h index c7e9b0ff3..86942c8a8 100644 --- a/src/lv_themes/lv_theme_material.h +++ b/src/lv_themes/lv_theme_material.h @@ -28,7 +28,7 @@ extern "C" { typedef enum { LV_THEME_MATERIAL_PALETTE_LIGHT, LV_THEME_MATERIAL_PALETTE_DARK, -}lv_theme_material_palette_t; +} lv_theme_material_palette_t; /********************** diff --git a/src/lv_widgets/lv_arc.c b/src/lv_widgets/lv_arc.c index c2b14da6a..17f8a7e09 100644 --- a/src/lv_widgets/lv_arc.c +++ b/src/lv_widgets/lv_arc.c @@ -382,7 +382,8 @@ static lv_design_res_t lv_arc_design(lv_obj_t * arc, const lv_area_t * clip_area lv_coord_t right_bg = lv_obj_get_style_pad_right(arc, LV_ARC_PART_BG); lv_coord_t top_bg = lv_obj_get_style_pad_top(arc, LV_ARC_PART_BG); lv_coord_t bottom_bg = lv_obj_get_style_pad_bottom(arc, LV_ARC_PART_BG); - lv_coord_t r = (LV_MATH_MIN(lv_obj_get_width(arc) - left_bg - right_bg, lv_obj_get_height(arc) - top_bg - bottom_bg)) / 2; + lv_coord_t r = (LV_MATH_MIN(lv_obj_get_width(arc) - left_bg - right_bg, + lv_obj_get_height(arc) - top_bg - bottom_bg)) / 2; lv_coord_t x = arc->coords.x1 + r + left_bg; lv_coord_t y = arc->coords.y1 + r + top_bg; @@ -400,7 +401,7 @@ static lv_design_res_t lv_arc_design(lv_obj_t * arc, const lv_area_t * clip_area lv_coord_t right_indic = lv_obj_get_style_pad_right(arc, LV_ARC_PART_INDIC); lv_coord_t top_indic = lv_obj_get_style_pad_top(arc, LV_ARC_PART_INDIC); lv_coord_t bottom_indic = lv_obj_get_style_pad_bottom(arc, LV_ARC_PART_INDIC); - r-= LV_MATH_MAX4(left_indic, right_indic, top_indic, bottom_indic); + r -= LV_MATH_MAX4(left_indic, right_indic, top_indic, bottom_indic); lv_draw_arc(x, y, r, ext->arc_angle_start, ext->arc_angle_end, clip_area, &arc_dsc); } diff --git a/src/lv_widgets/lv_bar.c b/src/lv_widgets/lv_bar.c index 1816e1a93..dcf876094 100644 --- a/src/lv_widgets/lv_bar.c +++ b/src/lv_widgets/lv_bar.c @@ -485,8 +485,9 @@ static void draw_indic(lv_obj_t * bar, const lv_area_t * clip_area) lv_coord_t anim_cur_value_end_x = (int32_t)((int32_t)anim_length * (ext->cur_value_anim.anim_end - ext->min_value)) / range; - anim_cur_value_x = anim_cur_value_start_x + (((anim_cur_value_end_x - anim_cur_value_start_x) * ext->cur_value_anim.anim_state) / - LV_BAR_ANIM_STATE_END); + anim_cur_value_x = anim_cur_value_start_x + (((anim_cur_value_end_x - anim_cur_value_start_x) * + ext->cur_value_anim.anim_state) / + LV_BAR_ANIM_STATE_END); } else #endif diff --git a/src/lv_widgets/lv_btnmatrix.c b/src/lv_widgets/lv_btnmatrix.c index 34497a0cc..495ba6eb0 100644 --- a/src/lv_widgets/lv_btnmatrix.c +++ b/src/lv_widgets/lv_btnmatrix.c @@ -233,7 +233,8 @@ void lv_btnmatrix_set_map(lv_obj_t * btnm, const char * map[]) /* Set the button's area. * If inner padding is zero then use the prev. button x2 as x1 to avoid rounding * errors*/ - if(btn_i != 0 && inner == 0 && ((act_x == left && base_dir != LV_BIDI_DIR_RTL) || (act_x + act_unit_w == max_w - right && base_dir == LV_BIDI_DIR_RTL))) { + if(btn_i != 0 && inner == 0 && ((act_x == left && base_dir != LV_BIDI_DIR_RTL) || + (act_x + act_unit_w == max_w - right && base_dir == LV_BIDI_DIR_RTL))) { lv_area_set(&ext->button_areas[btn_i], ext->button_areas[btn_i - 1].x2, act_y, act_x + act_unit_w, act_y + btn_h); } diff --git a/src/lv_widgets/lv_dropdown.c b/src/lv_widgets/lv_dropdown.c index bba325cf6..99194fc94 100644 --- a/src/lv_widgets/lv_dropdown.c +++ b/src/lv_widgets/lv_dropdown.c @@ -136,8 +136,8 @@ lv_obj_t * lv_dropdown_create(lv_obj_t * par, const lv_obj_t * copy) lv_dropdown_ext_t * copy_ext = lv_obj_get_ext_attr(copy); if(copy_ext->static_txt == 0) lv_dropdown_set_options(ddlist, lv_dropdown_get_options(copy)); - else - lv_dropdown_set_static_options(ddlist, lv_dropdown_get_options(copy)); + else + lv_dropdown_set_static_options(ddlist, lv_dropdown_get_options(copy)); ext->option_cnt = copy_ext->option_cnt; ext->sel_opt_id = copy_ext->sel_opt_id; ext->sel_opt_id_orig = copy_ext->sel_opt_id; @@ -219,7 +219,7 @@ void lv_dropdown_set_options(lv_obj_t * ddlist, const char * options) ext->option_cnt++; /*Last option has no `\n`*/ ext->sel_opt_id = 0; ext->sel_opt_id_orig = 0; - + /*Allocate space for the new text*/ size_t len = strlen(options) + 1; if(ext->options != NULL && ext->static_txt == 0) { @@ -297,11 +297,11 @@ void lv_dropdown_add_option(lv_obj_t * ddlist, const char * option, uint16_t pos /*Allocate space for the new option*/ size_t old_len = (ext->options == NULL) ? 0 : strlen(ext->options); - size_t ins_len = strlen(option); - size_t new_len = ins_len + old_len + 2; /* +2 for terminating NULL and possible \n */ - ext->options = lv_mem_realloc(ext->options, new_len + 1); - LV_ASSERT_MEM(ext->options); - if(ext->options == NULL) return; + size_t ins_len = strlen(option); + size_t new_len = ins_len + old_len + 2; /* +2 for terminating NULL and possible \n */ + ext->options = lv_mem_realloc(ext->options, new_len + 1); + LV_ASSERT_MEM(ext->options); + if(ext->options == NULL) return; ext->options[old_len] = 0; @@ -325,7 +325,7 @@ void lv_dropdown_add_option(lv_obj_t * ddlist, const char * option, uint16_t pos char * ins_buf = lv_mem_buf_get(ins_len + 2); /* + 2 for terminating NULL and possible \n */ LV_ASSERT_MEM(ins_buf); if(ins_buf == NULL) return; - strcpy(ins_buf, option); + strcpy(ins_buf, option); if(pos < ext->option_cnt) strcat(ins_buf, "\n"); lv_txt_ins(ext->options, insert_pos, ins_buf); @@ -592,13 +592,13 @@ bool lv_dropdown_get_show_selected(lv_obj_t * ddlist) * @param ddlist pointer to a drop down list * @return open/close animation time [ms] */ - uint16_t lv_dropdown_get_anim_time(const lv_obj_t * ddlist) +uint16_t lv_dropdown_get_anim_time(const lv_obj_t * ddlist) { - LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME); + LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME); - lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); + lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); - return ext->anim_time; + return ext->anim_time; } /*===================== @@ -937,7 +937,7 @@ static lv_res_t lv_dropdown_signal(lv_obj_t * ddlist, lv_signal_t sign, void * p lv_mem_free(ext->options); ext->options = NULL; } - + /*`lv_obj_clean_style_list` is not required because these styles are only copied to the page * so they can have transitions or other object related things. */ lv_style_list_reset(&ext->style_page); diff --git a/src/lv_widgets/lv_dropdown.h b/src/lv_widgets/lv_dropdown.h index 6dc75f2cc..51cd1d9f2 100644 --- a/src/lv_widgets/lv_dropdown.h +++ b/src/lv_widgets/lv_dropdown.h @@ -33,7 +33,7 @@ extern "C" { * DEFINES *********************/ #define LV_DROPDOWN_POS_LAST 0xFFFF - + /********************** * TYPEDEFS **********************/ @@ -127,7 +127,7 @@ void lv_dropdown_set_static_options(lv_obj_t * ddlist, const char * options); * @param pos the insert position, indexed from 0, LV_DROPDOWN_POS_LAST = end of string */ void lv_dropdown_add_option(lv_obj_t * ddlist, const char * option, uint16_t pos); - + /** * Set the selected option * @param ddlist pointer to drop down list object diff --git a/src/lv_widgets/lv_gauge.c b/src/lv_widgets/lv_gauge.c index 7dafc5c12..746a2aad5 100644 --- a/src/lv_widgets/lv_gauge.c +++ b/src/lv_widgets/lv_gauge.c @@ -1,7 +1,7 @@ - /** - * @file lv_gauge.c - * - */ +/** +* @file lv_gauge.c +* +*/ /********************* * INCLUDES @@ -84,6 +84,7 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy) ext->values = NULL; ext->needle_colors = NULL; ext->label_count = LV_GAUGE_DEF_LABEL_COUNT; + ext->format_cb = NULL; ext->needle_img = 0; ext->needle_img_pivot.x = 0; @@ -118,6 +119,7 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy) ext->values[i] = copy_ext->values[i]; } ext->label_count = copy_ext->label_count; + ext->format_cb = copy_ext->format_cb; /*Refresh the style with new signal function*/ lv_obj_refresh_style(new_gauge, LV_STYLE_PROP_ALL); @@ -173,7 +175,7 @@ void lv_gauge_set_needle_count(lv_obj_t * gauge, uint8_t needle_cnt, const lv_co * @param needle_id the id of the needle * @param value the new value */ -void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle_id, int16_t value) +void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle_id, int32_t value) { LV_ASSERT_OBJ(gauge, LV_OBJX_NAME); @@ -237,6 +239,20 @@ void lv_gauge_set_needle_img(lv_obj_t * gauge, const void * img, lv_coord_t pivo lv_obj_invalidate(gauge); } +/** + * Assign a function to format gauge values + * @param gauge pointer to a gauge object + * @param format_cb pointer to function of lv_gauge_format_cb_t + */ +void lv_gauge_set_formatter_cb(lv_obj_t * gauge, lv_gauge_format_cb_t format_cb) +{ + LV_ASSERT_OBJ(gauge, LV_OBJX_NAME); + + lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge); + + ext->format_cb = format_cb; +} + /*===================== * Getter functions *====================*/ @@ -247,7 +263,7 @@ void lv_gauge_set_needle_img(lv_obj_t * gauge, const void * img, lv_coord_t pivo * @param needle the id of the needle * @return the value of the needle [min,max] */ -int16_t lv_gauge_get_value(const lv_obj_t * gauge, uint8_t needle) +int32_t lv_gauge_get_value(const lv_obj_t * gauge, uint8_t needle) { LV_ASSERT_OBJ(gauge, LV_OBJX_NAME); @@ -454,8 +470,8 @@ static void lv_gauge_draw_labels(lv_obj_t * gauge, const lv_area_t * mask) int16_t scale_angle = lv_linemeter_get_scale_angle(gauge); uint16_t label_num = ext->label_count; int16_t angle_ofs = 90 + (360 - scale_angle) / 2; - int16_t min = lv_gauge_get_min_value(gauge); - int16_t max = lv_gauge_get_max_value(gauge); + int32_t min = lv_gauge_get_min_value(gauge); + int32_t max = lv_gauge_get_max_value(gauge); lv_draw_label_dsc_t label_dsc; lv_draw_label_dsc_init(&label_dsc); @@ -472,10 +488,13 @@ static void lv_gauge_draw_labels(lv_obj_t * gauge, const lv_area_t * mask) lv_coord_t x = (int32_t)((int32_t)lv_trigo_sin(angle + 90) * r) / LV_TRIGO_SIN_MAX; x += x_ofs; - int16_t scale_act = (int32_t)((int32_t)(max - min) * i) / (label_num - 1); + int32_t scale_act = (int32_t)((int32_t)(max - min) * i) / (label_num - 1); scale_act += min; - lv_utils_num_to_str(scale_act, scale_txt); - + if(ext->format_cb == NULL) + lv_utils_num_to_str(scale_act, scale_txt); + else + ext->format_cb(gauge, scale_txt, sizeof(scale_txt), scale_act); + lv_area_t label_cord; lv_point_t label_size; lv_txt_get_size(&label_size, scale_txt, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, diff --git a/src/lv_widgets/lv_gauge.h b/src/lv_widgets/lv_gauge.h index 436fefb0b..1c26f4078 100644 --- a/src/lv_widgets/lv_gauge.h +++ b/src/lv_widgets/lv_gauge.h @@ -35,11 +35,13 @@ extern "C" { * TYPEDEFS **********************/ +typedef void (*lv_gauge_format_cb_t)(lv_obj_t * gauge, char buf[], int bufsize, int32_t value); + /*Data of gauge*/ typedef struct { lv_linemeter_ext_t lmeter; /*Ext. of ancestor*/ /*New data for this type */ - int16_t * values; /*Array of the set values (for needles) */ + int32_t * values; /*Array of the set values (for needles) */ const lv_color_t * needle_colors; /*Color of the needles (lv_color_t my_colors[needle_num])*/ const void * needle_img; lv_point_t needle_img_pivot; @@ -47,6 +49,7 @@ typedef struct { lv_style_list_t style_strong; uint8_t needle_count; /*Number of needles*/ uint8_t label_count; /*Number of labels on the scale*/ + lv_gauge_format_cb_t format_cb; } lv_gauge_ext_t; /*Styles*/ @@ -89,7 +92,7 @@ void lv_gauge_set_needle_count(lv_obj_t * gauge, uint8_t needle_cnt, const lv_co * @param needle_id the id of the needle * @param value the new value */ -void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle_id, int16_t value); +void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle_id, int32_t value); /** * Set minimum and the maximum values of a gauge @@ -97,7 +100,7 @@ void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle_id, int16_t value); * @param min minimum value * @param max maximum value */ -static inline void lv_gauge_set_range(lv_obj_t * gauge, int16_t min, int16_t max) +static inline void lv_gauge_set_range(lv_obj_t * gauge, int32_t min, int32_t max) { lv_linemeter_set_range(gauge, min, max); } @@ -107,7 +110,7 @@ static inline void lv_gauge_set_range(lv_obj_t * gauge, int16_t min, int16_t max * @param gauge pointer to a gauge object * @param value the critical value */ -static inline void lv_gauge_set_critical_value(lv_obj_t * gauge, int16_t value) +static inline void lv_gauge_set_critical_value(lv_obj_t * gauge, int32_t value) { lv_linemeter_set_value(gauge, value); } @@ -144,6 +147,13 @@ static inline void lv_gauge_set_angle_offset(lv_obj_t * gauge, uint16_t angle) */ void lv_gauge_set_needle_img(lv_obj_t * gauge, const void * img, lv_coord_t pivot_x, lv_coord_t pivot_y); +/** + * Assign a function to format gauge values + * @param gauge pointer to a gauge object + * @param format_cb pointer to function of lv_gauge_format_cb_t + */ +void lv_gauge_set_formatter_cb(lv_obj_t * gauge, lv_gauge_format_cb_t format_cb); + /*===================== * Getter functions *====================*/ @@ -154,7 +164,7 @@ void lv_gauge_set_needle_img(lv_obj_t * gauge, const void * img, lv_coord_t pivo * @param needle the id of the needle * @return the value of the needle [min,max] */ -int16_t lv_gauge_get_value(const lv_obj_t * gauge, uint8_t needle); +int32_t lv_gauge_get_value(const lv_obj_t * gauge, uint8_t needle); /** * Get the count of needles on a gauge @@ -168,7 +178,7 @@ uint8_t lv_gauge_get_needle_count(const lv_obj_t * gauge); * @param gauge pointer to a gauge object * @return the minimum value of the gauge */ -static inline int16_t lv_gauge_get_min_value(const lv_obj_t * lmeter) +static inline int32_t lv_gauge_get_min_value(const lv_obj_t * lmeter) { return lv_linemeter_get_min_value(lmeter); } @@ -178,7 +188,7 @@ static inline int16_t lv_gauge_get_min_value(const lv_obj_t * lmeter) * @param gauge pointer to a gauge object * @return the maximum value of the gauge */ -static inline int16_t lv_gauge_get_max_value(const lv_obj_t * lmeter) +static inline int32_t lv_gauge_get_max_value(const lv_obj_t * lmeter) { return lv_linemeter_get_max_value(lmeter); } @@ -188,7 +198,7 @@ static inline int16_t lv_gauge_get_max_value(const lv_obj_t * lmeter) * @param gauge pointer to a gauge object * @return the critical value */ -static inline int16_t lv_gauge_get_critical_value(const lv_obj_t * gauge) +static inline int32_t lv_gauge_get_critical_value(const lv_obj_t * gauge) { return lv_linemeter_get_value(gauge); } diff --git a/src/lv_widgets/lv_imgbtn.c b/src/lv_widgets/lv_imgbtn.c index 6cddf895f..715d41156 100644 --- a/src/lv_widgets/lv_imgbtn.c +++ b/src/lv_widgets/lv_imgbtn.c @@ -146,7 +146,7 @@ void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src * to a file) */ void lv_imgbtn_set_src_tiled(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src_left, const void * src_mid, - const void * src_right) + const void * src_right) { LV_ASSERT_OBJ(imgbtn, LV_OBJX_NAME); @@ -293,7 +293,8 @@ static lv_design_res_t lv_imgbtn_design(lv_obj_t * imgbtn, const lv_area_t * cli lv_obj_init_draw_img_dsc(imgbtn, LV_IMGBTN_PART_MAIN, &img_dsc); lv_draw_img(&imgbtn->coords, clip_area, src, &img_dsc); } - } else { + } + else { #if LV_IMGBTN_TILED const void * src = ext->img_src_left[state]; if(lv_img_src_get_type(src) == LV_IMG_SRC_SYMBOL) { diff --git a/src/lv_widgets/lv_imgbtn.h b/src/lv_widgets/lv_imgbtn.h index f9eaf5143..ce75659d2 100644 --- a/src/lv_widgets/lv_imgbtn.h +++ b/src/lv_widgets/lv_imgbtn.h @@ -43,7 +43,7 @@ typedef struct { const void * img_src_right[_LV_BTN_STATE_LAST]; /*Store right side images to each state*/ #endif lv_img_cf_t act_cf; /*Color format of the currently active image*/ - uint8_t tiled :1; /*1: the middle src will be repeated to fill the user defined width*/ + uint8_t tiled : 1; /*1: the middle src will be repeated to fill the user defined width*/ } lv_imgbtn_ext_t; /*Parts of the image button*/ @@ -94,7 +94,7 @@ void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src * to a file) */ void lv_imgbtn_set_src_tiled(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src_left, const void * src_mid, - const void * src_right); + const void * src_right); #endif diff --git a/src/lv_widgets/lv_linemeter.c b/src/lv_widgets/lv_linemeter.c index 954873473..4c543618c 100644 --- a/src/lv_widgets/lv_linemeter.c +++ b/src/lv_widgets/lv_linemeter.c @@ -113,7 +113,7 @@ lv_obj_t * lv_linemeter_create(lv_obj_t * par, const lv_obj_t * copy) * @param lmeter pointer to a line meter object * @param value new value */ -void lv_linemeter_set_value(lv_obj_t * lmeter, int16_t value) +void lv_linemeter_set_value(lv_obj_t * lmeter, int32_t value) { LV_ASSERT_OBJ(lmeter, LV_OBJX_NAME); @@ -131,7 +131,7 @@ void lv_linemeter_set_value(lv_obj_t * lmeter, int16_t value) * @param min minimum value * @param max maximum value */ -void lv_linemeter_set_range(lv_obj_t * lmeter, int16_t min, int16_t max) +void lv_linemeter_set_range(lv_obj_t * lmeter, int32_t min, int32_t max) { LV_ASSERT_OBJ(lmeter, LV_OBJX_NAME); @@ -194,7 +194,7 @@ void lv_linemeter_set_angle_offset(lv_obj_t * lmeter, uint16_t angle) * @param lmeter pointer to a line meter object * @return the value of the line meter */ -int16_t lv_linemeter_get_value(const lv_obj_t * lmeter) +int32_t lv_linemeter_get_value(const lv_obj_t * lmeter) { LV_ASSERT_OBJ(lmeter, LV_OBJX_NAME); @@ -207,7 +207,7 @@ int16_t lv_linemeter_get_value(const lv_obj_t * lmeter) * @param lmeter pointer to a line meter object * @return the minimum value of the line meter */ -int16_t lv_linemeter_get_min_value(const lv_obj_t * lmeter) +int32_t lv_linemeter_get_min_value(const lv_obj_t * lmeter) { LV_ASSERT_OBJ(lmeter, LV_OBJX_NAME); @@ -220,7 +220,7 @@ int16_t lv_linemeter_get_min_value(const lv_obj_t * lmeter) * @param lmeter pointer to a line meter object * @return the maximum value of the line meter */ -int16_t lv_linemeter_get_max_value(const lv_obj_t * lmeter) +int32_t lv_linemeter_get_max_value(const lv_obj_t * lmeter) { LV_ASSERT_OBJ(lmeter, LV_OBJX_NAME); @@ -298,17 +298,17 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin lv_area_t mask_area; mask_area.x1 = x_ofs - r_in; - mask_area.x2 = x_ofs + r_in-1; + mask_area.x2 = x_ofs + r_in - 1; mask_area.y1 = y_ofs - r_in; - mask_area.y2 = y_ofs + r_in-1; + mask_area.y2 = y_ofs + r_in - 1; lv_draw_mask_radius_param_t mask_in_param; lv_draw_mask_radius_init(&mask_in_param, &mask_area, LV_RADIUS_CIRCLE, true); int16_t mask_in_id = lv_draw_mask_add(&mask_in_param, 0); mask_area.x1 = x_ofs - r_out; - mask_area.x2 = x_ofs + r_out-1; + mask_area.x2 = x_ofs + r_out - 1; mask_area.y1 = y_ofs - r_out; - mask_area.y2 = y_ofs + r_out-1; + mask_area.y2 = y_ofs + r_out - 1; lv_draw_mask_radius_param_t mask_out_param; lv_draw_mask_radius_init(&mask_out_param, &mask_area, LV_RADIUS_CIRCLE, false); int16_t mask_out_id = lv_draw_mask_add(&mask_out_param, 0); @@ -327,11 +327,11 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin /*Interpolate sine and cos*/ int32_t sin_low = lv_trigo_sin(angle_low + angle_ofs); int32_t sin_high = lv_trigo_sin(angle_high + angle_ofs); - int32_t sin_mid = (sin_low * (256 - angle_rem) + sin_high * angle_rem) >> 8; + int32_t sin_mid = (sin_low * (256 - angle_rem) + sin_high * angle_rem) >> 8; int32_t cos_low = lv_trigo_sin(angle_low + 90 + angle_ofs); int32_t cos_high = lv_trigo_sin(angle_high + 90 + angle_ofs); - int32_t cos_mid = (cos_low * (256 - angle_rem) + cos_high * angle_rem) >> 8; + int32_t cos_mid = (cos_low * (256 - angle_rem) + cos_high * angle_rem) >> 8; /*Use the interpolated values to get x and y coordinates*/ int32_t y_out = (int32_t)((int32_t)sin_mid * r_out_extra) >> (LV_TRIGO_SHIFT - 8); diff --git a/src/lv_widgets/lv_linemeter.h b/src/lv_widgets/lv_linemeter.h index 27691ea38..592b5adbd 100644 --- a/src/lv_widgets/lv_linemeter.h +++ b/src/lv_widgets/lv_linemeter.h @@ -33,9 +33,9 @@ typedef struct { uint16_t scale_angle; /*Angle of the scale in deg. (0..360)*/ uint16_t angle_ofs; uint16_t line_cnt; /*Count of lines */ - int16_t cur_value; - int16_t min_value; - int16_t max_value; + int32_t cur_value; + int32_t min_value; + int32_t max_value; } lv_linemeter_ext_t; /*Styles*/ @@ -68,7 +68,7 @@ lv_obj_t * lv_linemeter_create(lv_obj_t * par, const lv_obj_t * copy); * @param lmeter pointer to a line meter object * @param value new value */ -void lv_linemeter_set_value(lv_obj_t * lmeter, int16_t value); +void lv_linemeter_set_value(lv_obj_t * lmeter, int32_t value); /** * Set minimum and the maximum values of a line meter @@ -76,7 +76,7 @@ void lv_linemeter_set_value(lv_obj_t * lmeter, int16_t value); * @param min minimum value * @param max maximum value */ -void lv_linemeter_set_range(lv_obj_t * lmeter, int16_t min, int16_t max); +void lv_linemeter_set_range(lv_obj_t * lmeter, int32_t min, int32_t max); /** * Set the scale settings of a line meter @@ -102,21 +102,21 @@ void lv_linemeter_set_angle_offset(lv_obj_t * lmeter, uint16_t angle); * @param lmeter pointer to a line meter object * @return the value of the line meter */ -int16_t lv_linemeter_get_value(const lv_obj_t * lmeter); +int32_t lv_linemeter_get_value(const lv_obj_t * lmeter); /** * Get the minimum value of a line meter * @param lmeter pointer to a line meter object * @return the minimum value of the line meter */ -int16_t lv_linemeter_get_min_value(const lv_obj_t * lmeter); +int32_t lv_linemeter_get_min_value(const lv_obj_t * lmeter); /** * Get the maximum value of a line meter * @param lmeter pointer to a line meter object * @return the maximum value of the line meter */ -int16_t lv_linemeter_get_max_value(const lv_obj_t * lmeter); +int32_t lv_linemeter_get_max_value(const lv_obj_t * lmeter); /** * Get the scale number of a line meter diff --git a/src/lv_widgets/lv_page.c b/src/lv_widgets/lv_page.c index a9eb66a08..7a13f5ae5 100644 --- a/src/lv_widgets/lv_page.c +++ b/src/lv_widgets/lv_page.c @@ -986,7 +986,8 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi #if LV_USE_GROUP if(lv_obj_get_group(page)) { lv_group_focus_obj(page); - } else + } + else #endif { res = lv_signal_send(page, LV_SIGNAL_FOCUS, NULL); diff --git a/src/lv_widgets/lv_roller.c b/src/lv_widgets/lv_roller.c index ecb28e7a3..9588a50e7 100644 --- a/src/lv_widgets/lv_roller.c +++ b/src/lv_widgets/lv_roller.c @@ -764,7 +764,7 @@ static lv_res_t release_handler(lv_obj_t * roller) lv_obj_t * label = get_label(roller); if(label == NULL) return LV_RES_OK; - + if(lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER || lv_indev_get_type(indev) == LV_INDEV_TYPE_BUTTON) { /*Search the clicked option (For KEYPAD and ENCODER the new value should be already set)*/ uint16_t new_opt = 0; diff --git a/src/lv_widgets/lv_slider.c b/src/lv_widgets/lv_slider.c index 21b4e359e..8f07cca02 100644 --- a/src/lv_widgets/lv_slider.c +++ b/src/lv_widgets/lv_slider.c @@ -273,10 +273,12 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par lv_coord_t dist_left, dist_right; if(hor) { - if((base_dir != LV_BIDI_DIR_RTL && p.x > ext->right_knob_area.x2) || (base_dir == LV_BIDI_DIR_RTL && p.x < ext->right_knob_area.x1)) { + if((base_dir != LV_BIDI_DIR_RTL && p.x > ext->right_knob_area.x2) || (base_dir == LV_BIDI_DIR_RTL && + p.x < ext->right_knob_area.x1)) { ext->value_to_set = &ext->bar.cur_value; } - else if((base_dir != LV_BIDI_DIR_RTL && p.x < ext->left_knob_area.x1) || (base_dir == LV_BIDI_DIR_RTL && p.x > ext->left_knob_area.x2)) { + else if((base_dir != LV_BIDI_DIR_RTL && p.x < ext->left_knob_area.x1) || (base_dir == LV_BIDI_DIR_RTL && + p.x > ext->left_knob_area.x2)) { ext->value_to_set = &ext->bar.start_value; } else { diff --git a/src/lv_widgets/lv_switch.c b/src/lv_widgets/lv_switch.c index 1ca8495cc..0825364ef 100644 --- a/src/lv_widgets/lv_switch.c +++ b/src/lv_widgets/lv_switch.c @@ -219,7 +219,8 @@ static lv_design_res_t lv_switch_design(lv_obj_t * sw, const lv_area_t * clip_ar if(base_dir != LV_BIDI_DIR_RTL) { knob_area.x1 = ext->bar.indic_area.x2 - ((act_indic_w * knob_size) / max_indic_w); knob_area.x2 = knob_area.x1 + knob_size; - } else { + } + else { knob_area.x2 = ext->bar.indic_area.x1 + ((act_indic_w * knob_size) / max_indic_w); knob_area.x1 = knob_area.x2 - knob_size; } diff --git a/src/lv_widgets/lv_table.c b/src/lv_widgets/lv_table.c index 42d7626f4..72bf14d13 100644 --- a/src/lv_widgets/lv_table.c +++ b/src/lv_widgets/lv_table.c @@ -350,7 +350,7 @@ void lv_table_set_cell_crop(lv_obj_t * table, uint16_t row, uint16_t col, bool c LV_ASSERT_OBJ(table, LV_OBJX_NAME); lv_table_ext_t * ext = lv_obj_get_ext_attr(table); - if( col >= ext->col_cnt) { + if(col >= ext->col_cnt) { LV_LOG_WARN("lv_table_set_cell_crop: invalid column"); return; } @@ -740,13 +740,14 @@ static lv_design_res_t lv_table_design(lv_obj_t * table, const lv_area_t * clip_ label_dsc[cell_type].letter_space, label_dsc[cell_type].line_space, lv_area_get_width(&txt_area), txt_flags); + label_dsc[cell_type].flag = 0; /*Align the content to the middle if not cropped*/ if(format.s.crop == 0) { txt_area.y1 = cell_area.y1 + h_row / 2 - txt_size.y / 2; txt_area.y2 = cell_area.y1 + h_row / 2 + txt_size.y / 2; + label_dsc[cell_type].flag |= LV_TXT_FLAG_FIT; } - label_dsc[cell_type].flag = 0; switch(format.s.align) { default: case LV_LABEL_ALIGN_LEFT: