From 3a0069adf8fb19e1a3a95a1c2c2e7745655f65ce Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Mon, 22 Nov 2021 06:32:48 -0600 Subject: [PATCH] chore(format): run code-format.sh (#2822) * fix(format): run code-format.sh Signed-off-by: Xiang Xiao * fix(astyle): add the 3rd party source file to exclude list Signed-off-by: Xiang Xiao --- scripts/built_in_font/generate_all.py | 2 +- scripts/code-format.cfg | 9 + src/core/lv_event.c | 9 +- src/core/lv_indev.c | 3 +- src/core/lv_obj_pos.c | 44 +-- src/core/lv_obj_style_gen.c | 6 +- src/core/lv_obj_style_gen.h | 9 +- src/core/lv_refr.c | 3 +- src/draw/lv_draw_label.c | 2 +- src/draw/lv_draw_mask.c | 8 +- src/draw/lv_draw_mask.h | 2 +- src/extra/libs/bmp/lv_bmp.c | 10 +- src/extra/libs/ffmpeg/lv_ffmpeg.c | 2 +- src/extra/libs/freetype/lv_freetype.c | 10 +- src/extra/libs/fsdrv/lv_fs_fatfs.c | 27 +- src/extra/libs/fsdrv/lv_fs_posix.c | 37 ++- src/extra/libs/fsdrv/lv_fs_stdio.c | 37 ++- src/extra/libs/fsdrv/lv_fs_win32.c | 76 ++--- src/extra/libs/fsdrv/lv_fsdrv.h | 8 +- src/extra/libs/gif/lv_gif.c | 27 +- src/extra/libs/gif/lv_gif.h | 4 +- src/extra/libs/png/lv_png.c | 100 +++--- src/extra/libs/qrcode/lv_qrcode.c | 41 +-- src/extra/libs/rlottie/lv_rlottie.c | 57 ++-- src/extra/libs/rlottie/lv_rlottie.h | 13 +- src/extra/libs/sjpg/lv_sjpg.c | 389 ++++++++++++----------- src/extra/widgets/calendar/lv_calendar.c | 3 +- src/extra/widgets/imgbtn/lv_imgbtn.c | 21 +- src/extra/widgets/keyboard/lv_keyboard.c | 7 +- src/extra/widgets/msgbox/lv_msgbox.c | 28 +- src/extra/widgets/spinbox/lv_spinbox.c | 8 +- src/extra/widgets/spinbox/lv_spinbox.h | 2 +- src/font/lv_font.c | 2 +- src/font/lv_font.h | 7 +- src/gpu/lv_gpu_sdl.h | 2 +- src/gpu/sdl/lv_gpu_sdl_draw_label.c | 12 +- src/gpu/sdl/lv_gpu_sdl_lru.c | 2 +- src/hal/lv_hal_disp.c | 3 +- src/hal/lv_hal_disp.h | 11 +- src/hal/lv_hal_tick.c | 4 +- src/misc/lv_anim_timeline.c | 2 +- src/misc/lv_bidi.c | 24 +- src/misc/lv_log.c | 2 +- src/misc/lv_printf.c | 2 +- src/misc/lv_printf.h | 28 +- src/misc/lv_types.h | 2 +- src/widgets/lv_arc.c | 5 +- src/widgets/lv_btnmatrix.c | 24 +- src/widgets/lv_label.c | 5 +- 49 files changed, 598 insertions(+), 543 deletions(-) diff --git a/scripts/built_in_font/generate_all.py b/scripts/built_in_font/generate_all.py index e96eb053c..61bed8d8d 100755 --- a/scripts/built_in_font/generate_all.py +++ b/scripts/built_in_font/generate_all.py @@ -84,5 +84,5 @@ print("\nGenerating 16 px unscii") os.system("lv_font_conv --no-compress --no-prefilter --bpp 1 --size 16 --font unscii-8.ttf -r 0x20-0x7F --format lvgl -o lv_font_unscii_16.c --force-fast-kern-format") os.system('sed -i \'s|#include "lvgl/lvgl.h"|#include "../../lvgl.h"|\' lv_font_*.c') -os.system('astyle --options=../code-format.cfg "lv_font_*.c"') +os.system('astyle --ignore-exclude-errors --options=../code-format.cfg "lv_font_*.c"') os.system('mv lv_font_*.c ../../src/font/') diff --git a/scripts/code-format.cfg b/scripts/code-format.cfg index e3a2c55f0..e6a88fe82 100644 --- a/scripts/code-format.cfg +++ b/scripts/code-format.cfg @@ -23,3 +23,12 @@ --suffix=none --preserve-date --formatted +--exclude=../src/extra/libs/gif/gifdec.c +--exclude=../src/extra/libs/gif/gifdec.h +--exclude=../src/extra/libs/png/lodepng.c +--exclude=../src/extra/libs/png/lodepng.h +--exclude=../src/extra/libs/qrcode/qrcodegen.c +--exclude=../src/extra/libs/qrcode/qrcodegen.h +--exclude=../src/extra/libs/sjpg/tjpgd.c +--exclude=../src/extra/libs/sjpg/tjpgd.h +--exclude=../src/extra/libs/sjpg/tjpgdcnf.h diff --git a/src/core/lv_event.c b/src/core/lv_event.c index 21b79f16a..43c46c843 100644 --- a/src/core/lv_event.c +++ b/src/core/lv_event.c @@ -429,11 +429,10 @@ static lv_res_t event_send_core(lv_event_t * e) event_dsc = lv_obj_get_event_dsc(e->current_target, i); } - if(res == LV_RES_OK && e->current_target->parent && event_is_bubbled(e)) - { - e->current_target = e->current_target->parent; - res = event_send_core(e); - if(res != LV_RES_OK) return LV_RES_INV; + if(res == LV_RES_OK && e->current_target->parent && event_is_bubbled(e)) { + e->current_target = e->current_target->parent; + res = event_send_core(e); + if(res != LV_RES_OK) return LV_RES_INV; } diff --git a/src/core/lv_indev.c b/src/core/lv_indev.c index 02a65a28f..2bed6a8bd 100644 --- a/src/core/lv_indev.c +++ b/src/core/lv_indev.c @@ -994,8 +994,7 @@ static void indev_click_focus(_lv_indev_proc_t * proc) { /*Handle click focus*/ if(lv_obj_has_flag(indev_obj_act, LV_OBJ_FLAG_CLICK_FOCUSABLE) == false || - proc->types.pointer.last_pressed == indev_obj_act) - { + proc->types.pointer.last_pressed == indev_obj_act) { return; } diff --git a/src/core/lv_obj_pos.c b/src/core/lv_obj_pos.c index f904ed0aa..e7d44c266 100644 --- a/src/core/lv_obj_pos.c +++ b/src/core/lv_obj_pos.c @@ -966,13 +966,14 @@ static lv_coord_t calc_content_width(lv_obj_t * obj) child_res = LV_MAX(child_res, obj->coords.x2 - child->coords.x1 + 1); break; default: - /* Consider other cases only if x=0 and use the width of the object. - * With x!=0 circular dependency could occur. */ - if(lv_obj_get_style_y(child, 0) == 0) { - child_res = LV_MAX(child_res, lv_area_get_width(&child->coords)); - } + /* Consider other cases only if x=0 and use the width of the object. + * With x!=0 circular dependency could occur. */ + if(lv_obj_get_style_y(child, 0) == 0) { + child_res = LV_MAX(child_res, lv_area_get_width(&child->coords)); + } } - } else { + } + else { child_res = LV_MAX(child_res, obj->coords.x2 - child->coords.x1 + 1); } } @@ -997,13 +998,14 @@ static lv_coord_t calc_content_width(lv_obj_t * obj) child_res = LV_MAX(child_res, child->coords.x2 - obj->coords.x1 + 1); break; default: - /* Consider other cases only if x=0 and use the width of the object. - * With x!=0 circular dependency could occur. */ - if(lv_obj_get_style_y(child, 0) == 0) { - child_res = LV_MAX(child_res, lv_area_get_width(&child->coords)); - } + /* Consider other cases only if x=0 and use the width of the object. + * With x!=0 circular dependency could occur. */ + if(lv_obj_get_style_y(child, 0) == 0) { + child_res = LV_MAX(child_res, lv_area_get_width(&child->coords)); + } } - } else { + } + else { child_res = LV_MAX(child_res, child->coords.x2 - obj->coords.x1 + 1); } } @@ -1047,14 +1049,15 @@ static lv_coord_t calc_content_height(lv_obj_t * obj) child_res = LV_MAX(child_res, child->coords.y2 - obj->coords.y1 + 1); break; default: - /* Consider other cases only if y=0 and use the height of the object. - * With y!=0 circular dependency could occur. */ - if(lv_obj_get_style_y(child, 0) == 0) { - child_res = LV_MAX(child_res, lv_area_get_height(&child->coords)); - } - break; + /* Consider other cases only if y=0 and use the height of the object. + * With y!=0 circular dependency could occur. */ + if(lv_obj_get_style_y(child, 0) == 0) { + child_res = LV_MAX(child_res, lv_area_get_height(&child->coords)); + } + break; } - } else { + } + else { child_res = LV_MAX(child_res, child->coords.y2 - obj->coords.y1 + 1); } } @@ -1062,7 +1065,8 @@ static lv_coord_t calc_content_height(lv_obj_t * obj) if(child_res != LV_COORD_MIN) { child_res += pad_bottom; return LV_MAX(child_res, self_h); - } else { + } + else { return self_h; } diff --git a/src/core/lv_obj_style_gen.c b/src/core/lv_obj_style_gen.c index 5064f1bf0..e8a8f1399 100644 --- a/src/core/lv_obj_style_gen.c +++ b/src/core/lv_obj_style_gen.c @@ -648,7 +648,8 @@ void lv_obj_set_style_opa(struct _lv_obj_t * obj, lv_opa_t value, lv_style_selec lv_obj_set_local_style_prop(obj, LV_STYLE_OPA, v, selector); } -void lv_obj_set_style_color_filter_dsc(struct _lv_obj_t * obj, const lv_color_filter_dsc_t * value, lv_style_selector_t selector) +void lv_obj_set_style_color_filter_dsc(struct _lv_obj_t * obj, const lv_color_filter_dsc_t * value, + lv_style_selector_t selector) { lv_style_value_t v = { .ptr = value @@ -680,7 +681,8 @@ void lv_obj_set_style_anim_speed(struct _lv_obj_t * obj, uint32_t value, lv_styl lv_obj_set_local_style_prop(obj, LV_STYLE_ANIM_SPEED, v, selector); } -void lv_obj_set_style_transition(struct _lv_obj_t * obj, const lv_style_transition_dsc_t * value, lv_style_selector_t selector) +void lv_obj_set_style_transition(struct _lv_obj_t * obj, const lv_style_transition_dsc_t * value, + lv_style_selector_t selector) { lv_style_value_t v = { .ptr = value diff --git a/src/core/lv_obj_style_gen.h b/src/core/lv_obj_style_gen.h index d7f414ed7..fe7863dbd 100644 --- a/src/core/lv_obj_style_gen.h +++ b/src/core/lv_obj_style_gen.h @@ -484,7 +484,8 @@ static inline lv_opa_t lv_obj_get_style_opa(const struct _lv_obj_t * obj, uint32 return (lv_opa_t)v.num; } -static inline const lv_color_filter_dsc_t * lv_obj_get_style_color_filter_dsc(const struct _lv_obj_t * obj, uint32_t part) +static inline const lv_color_filter_dsc_t * lv_obj_get_style_color_filter_dsc(const struct _lv_obj_t * obj, + uint32_t part) { lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_COLOR_FILTER_DSC); return (const lv_color_filter_dsc_t *)v.ptr; @@ -613,11 +614,13 @@ void lv_obj_set_style_text_align(struct _lv_obj_t * obj, lv_text_align_t value, void lv_obj_set_style_radius(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector); void lv_obj_set_style_clip_corner(struct _lv_obj_t * obj, bool value, lv_style_selector_t selector); void lv_obj_set_style_opa(struct _lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector); -void lv_obj_set_style_color_filter_dsc(struct _lv_obj_t * obj, const lv_color_filter_dsc_t * value, lv_style_selector_t selector); +void lv_obj_set_style_color_filter_dsc(struct _lv_obj_t * obj, const lv_color_filter_dsc_t * value, + lv_style_selector_t selector); void lv_obj_set_style_color_filter_opa(struct _lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector); void lv_obj_set_style_anim_time(struct _lv_obj_t * obj, uint32_t value, lv_style_selector_t selector); void lv_obj_set_style_anim_speed(struct _lv_obj_t * obj, uint32_t value, lv_style_selector_t selector); -void lv_obj_set_style_transition(struct _lv_obj_t * obj, const lv_style_transition_dsc_t * value, lv_style_selector_t selector); +void lv_obj_set_style_transition(struct _lv_obj_t * obj, const lv_style_transition_dsc_t * value, + lv_style_selector_t selector); void lv_obj_set_style_blend_mode(struct _lv_obj_t * obj, lv_blend_mode_t value, lv_style_selector_t selector); void lv_obj_set_style_layout(struct _lv_obj_t * obj, uint16_t value, lv_style_selector_t selector); void lv_obj_set_style_base_dir(struct _lv_obj_t * obj, lv_base_dir_t value, lv_style_selector_t selector); diff --git a/src/core/lv_refr.c b/src/core/lv_refr.c index 1fba0542f..1ebf43aa3 100644 --- a/src/core/lv_refr.c +++ b/src/core/lv_refr.c @@ -536,7 +536,8 @@ static void lv_refr_area_part(const lv_area_t * area_p) if(top_act_scr == NULL && top_prev_scr == NULL) { if(disp_refr->bg_fn) { disp_refr->bg_fn(&start_mask); - } else if(disp_refr->bg_img) { + } + else if(disp_refr->bg_img) { lv_draw_img_dsc_t dsc; lv_draw_img_dsc_init(&dsc); dsc.opa = disp_refr->bg_opa; diff --git a/src/draw/lv_draw_label.c b/src/draw/lv_draw_label.c index 0a92e57a3..e26cb0c6e 100644 --- a/src/draw/lv_draw_label.c +++ b/src/draw/lv_draw_label.c @@ -449,7 +449,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_letter(const lv_point_t * pos_p, const lv_are return; } - if (g.resolved_font) { + if(g.resolved_font) { font_p = g.resolved_font; } const uint8_t * map_p = lv_font_get_glyph_bitmap(font_p, letter); diff --git a/src/draw/lv_draw_mask.c b/src/draw/lv_draw_mask.c index fbbbf68a9..17f55a898 100644 --- a/src/draw/lv_draw_mask.c +++ b/src/draw/lv_draw_mask.c @@ -140,16 +140,16 @@ LV_ATTRIBUTE_FAST_MEM lv_draw_mask_res_t lv_draw_mask_apply(lv_opa_t * mask_buf, * - `LV_DRAW_MASK_RES_CHANGED`: `mask_buf` has changed, it shows the desired opacity of each pixel in the given line */ LV_ATTRIBUTE_FAST_MEM lv_draw_mask_res_t lv_draw_mask_apply_ids(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, - lv_coord_t len, const int16_t *ids, int16_t ids_count) + lv_coord_t len, const int16_t * ids, int16_t ids_count) { bool changed = false; _lv_draw_mask_common_dsc_t * dsc; - for (int i = 0; i < ids_count; i++) { + for(int i = 0; i < ids_count; i++) { int16_t id = ids[i]; - if (id == LV_MASK_ID_INV) continue; + if(id == LV_MASK_ID_INV) continue; dsc = LV_GC_ROOT(_lv_draw_mask_list[id]).param; - if (!dsc) continue; + if(!dsc) continue; lv_draw_mask_res_t res = LV_DRAW_MASK_RES_FULL_COVER; res = dsc->cb(mask_buf, abs_x, abs_y, len, dsc); if(res == LV_DRAW_MASK_RES_TRANSP) return LV_DRAW_MASK_RES_TRANSP; diff --git a/src/draw/lv_draw_mask.h b/src/draw/lv_draw_mask.h index 123cd9163..ae9ec759a 100644 --- a/src/draw/lv_draw_mask.h +++ b/src/draw/lv_draw_mask.h @@ -250,7 +250,7 @@ LV_ATTRIBUTE_FAST_MEM lv_draw_mask_res_t lv_draw_mask_apply(lv_opa_t * mask_buf, * - `LV_DRAW_MASK_RES_CHANGED`: `mask_buf` has changed, it shows the desired opacity of each pixel in the given line */ LV_ATTRIBUTE_FAST_MEM lv_draw_mask_res_t lv_draw_mask_apply_ids(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, - lv_coord_t len, const int16_t *ids, int16_t ids_count); + lv_coord_t len, const int16_t * ids, int16_t ids_count); //! @endcond diff --git a/src/extra/libs/bmp/lv_bmp.c b/src/extra/libs/bmp/lv_bmp.c index d0533589f..969c4e1b2 100644 --- a/src/extra/libs/bmp/lv_bmp.c +++ b/src/extra/libs/bmp/lv_bmp.c @@ -36,7 +36,7 @@ static lv_res_t decoder_open(lv_img_decoder_t * dec, lv_img_decoder_dsc_t * dsc) static lv_res_t decoder_read_line(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc, - lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t * buf); + lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t * buf); static void decoder_close(lv_img_decoder_t * dec, lv_img_decoder_dsc_t * dsc); @@ -140,7 +140,7 @@ static lv_res_t decoder_open(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * uint8_t header[54]; lv_fs_read(&b.f, header, 54, NULL); - if (0x42 != header[0] || 0x4d != header[1]) { + if(0x42 != header[0] || 0x4d != header[1]) { return LV_RES_INV; } @@ -169,7 +169,7 @@ static lv_res_t decoder_open(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * static lv_res_t decoder_read_line(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc, - lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t * buf) + lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t * buf) { LV_UNUSED(decoder); @@ -188,7 +188,7 @@ static lv_res_t decoder_read_line(lv_img_decoder_t * decoder, lv_img_decoder_dsc uint8_t b1 = buf[i * 4 + 1]; uint8_t b2 = buf[i * 4 + 2]; uint8_t b3 = buf[i * 4 + 3]; - lv_color32_t *c = (lv_color32_t*)&buf[i*4]; + lv_color32_t * c = (lv_color32_t *)&buf[i * 4]; c->ch.red = b2; c->ch.green = b1; c->ch.blue = b0; @@ -200,7 +200,7 @@ static lv_res_t decoder_read_line(lv_img_decoder_t * decoder, lv_img_decoder_dsc for(i = len - 1; i >= 0; i--) { uint8_t * t = &buf[i * 3]; - lv_color32_t *c = (lv_color32_t*)&buf[i*4]; + lv_color32_t * c = (lv_color32_t *)&buf[i * 4]; c->ch.red = t[2]; c->ch.green = t[1]; c->ch.blue = t[0]; diff --git a/src/extra/libs/ffmpeg/lv_ffmpeg.c b/src/extra/libs/ffmpeg/lv_ffmpeg.c index 63949d522..a72a89188 100644 --- a/src/extra/libs/ffmpeg/lv_ffmpeg.c +++ b/src/extra/libs/ffmpeg/lv_ffmpeg.c @@ -617,7 +617,7 @@ static int ffmpeg_get_frame_refr_period(struct ffmpeg_context_s * ffmpeg_ctx) int avg_frame_rate_num = ffmpeg_ctx->video_stream->avg_frame_rate.num; if(avg_frame_rate_num > 0) { int period = 1000 * (int64_t)ffmpeg_ctx->video_stream->avg_frame_rate.den - / avg_frame_rate_num; + / avg_frame_rate_num; return period; } diff --git a/src/extra/libs/freetype/lv_freetype.c b/src/extra/libs/freetype/lv_freetype.c index 579976c00..bf8edf6b1 100644 --- a/src/extra/libs/freetype/lv_freetype.c +++ b/src/extra/libs/freetype/lv_freetype.c @@ -163,9 +163,10 @@ static FT_Error font_face_requester(FTC_FaceID face_id, lv_face_info_t * info = (lv_face_info_t *)face_id; FT_Error error; - if (info->mem) { + if(info->mem) { error = FT_New_Memory_Face(library, info->mem, info->size, 0, aface); - } else { + } + else { error = FT_New_Face(library, info->name, 0, aface); } if(error) { @@ -423,9 +424,10 @@ static bool lv_ft_font_init_nocache(lv_ft_info_t * info) goto Fail; } FT_Error error; - if (info->mem) { + if(info->mem) { error = FT_New_Memory_Face(library, info->mem, (FT_Long) info->mem_size, 0, &face); - } else { + } + else { error = FT_New_Face(library, info->name, 0, &face); } if(error) { diff --git a/src/extra/libs/fsdrv/lv_fs_fatfs.c b/src/extra/libs/fsdrv/lv_fs_fatfs.c index 157a778ed..d45f9f006 100644 --- a/src/extra/libs/fsdrv/lv_fs_fatfs.c +++ b/src/extra/libs/fsdrv/lv_fs_fatfs.c @@ -110,7 +110,8 @@ static void * fs_open(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode) FRESULT res = f_open(f, path, flags); if(res == FR_OK) { return f; - } else { + } + else { lv_mem_free(f); return NULL; } @@ -178,18 +179,18 @@ static lv_fs_res_t fs_write(lv_fs_drv_t * drv, void * file_p, const void * buf, static lv_fs_res_t fs_seek(lv_fs_drv_t * drv, void * file_p, uint32_t pos, lv_fs_whence_t whence) { LV_UNUSED(drv); - switch (whence) { - case LV_FS_SEEK_SET: - f_lseek(file_p, pos); - break; - case LV_FS_SEEK_CUR: - f_lseek(file_p, f_tell(file_p) + pos); - break; - case LV_FS_SEEK_END: - f_lseek(file_p, f_size(file_p) + pos); - break; - default: - break; + switch(whence) { + case LV_FS_SEEK_SET: + f_lseek(file_p, pos); + break; + case LV_FS_SEEK_CUR: + f_lseek(file_p, f_tell(file_p) + pos); + break; + case LV_FS_SEEK_END: + f_lseek(file_p, f_size(file_p) + pos); + break; + default: + break; } return LV_FS_RES_OK; } diff --git a/src/extra/libs/fsdrv/lv_fs_posix.c b/src/extra/libs/fsdrv/lv_fs_posix.c index 85985bcb0..919ad41ba 100644 --- a/src/extra/libs/fsdrv/lv_fs_posix.c +++ b/src/extra/libs/fsdrv/lv_fs_posix.c @@ -13,10 +13,10 @@ #include #include #ifndef WIN32 -#include -#include + #include + #include #else -#include + #include #endif /********************* @@ -143,7 +143,7 @@ static lv_fs_res_t fs_read(lv_fs_drv_t * drv, void * file_p, void * buf, uint32_ { LV_UNUSED(drv); *br = read((lv_uintptr_t)file_p, buf, btr); - return (int32_t)*br < 0 ? LV_FS_RES_UNKNOWN : LV_FS_RES_OK; + return (int32_t)(*br) < 0 ? LV_FS_RES_UNKNOWN : LV_FS_RES_OK; } /** @@ -159,7 +159,7 @@ static lv_fs_res_t fs_write(lv_fs_drv_t * drv, void * file_p, const void * buf, { LV_UNUSED(drv); *bw = write((lv_uintptr_t)file_p, buf, btw); - return (int32_t)*bw < 0 ? LV_FS_RES_UNKNOWN : LV_FS_RES_OK; + return (int32_t)(*bw) < 0 ? LV_FS_RES_UNKNOWN : LV_FS_RES_OK; } /** @@ -193,7 +193,7 @@ static lv_fs_res_t fs_tell(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p) } #ifdef WIN32 -static char next_fn[256]; + static char next_fn[256]; #endif /** @@ -230,12 +230,14 @@ static void * fs_dir_open(lv_fs_drv_t * drv, const char * path) strcpy(next_fn, ""); d = FindFirstFile(buf, &fdata); do { - if (strcmp(fdata.cFileName, ".") == 0 || strcmp(fdata.cFileName, "..") == 0) { + if(strcmp(fdata.cFileName, ".") == 0 || strcmp(fdata.cFileName, "..") == 0) { continue; - } else { - if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + } + else { + if(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { sprintf(next_fn, "/%s", fdata.cFileName); - } else { + } + else { sprintf(next_fn, "%s", fdata.cFileName); } break; @@ -259,13 +261,14 @@ static lv_fs_res_t fs_dir_read(lv_fs_drv_t * drv, void * dir_p, char * fn) LV_UNUSED(drv); #ifndef WIN32 - struct dirent *entry; + struct dirent * entry; do { entry = readdir(dir_p); if(entry) { if(entry->d_type == DT_DIR) sprintf(fn, "/%s", entry->d_name); else strcpy(fn, entry->d_name); - } else { + } + else { strcpy(fn, ""); } } while(strcmp(fn, "/.") == 0 || strcmp(fn, "/..") == 0); @@ -277,12 +280,14 @@ static lv_fs_res_t fs_dir_read(lv_fs_drv_t * drv, void * dir_p, char * fn) if(FindNextFile(dir_p, &fdata) == false) return LV_FS_RES_OK; do { - if (strcmp(fdata.cFileName, ".") == 0 || strcmp(fdata.cFileName, "..") == 0) { + if(strcmp(fdata.cFileName, ".") == 0 || strcmp(fdata.cFileName, "..") == 0) { continue; - } else { - if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + } + else { + if(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { sprintf(next_fn, "/%s", fdata.cFileName); - } else { + } + else { sprintf(next_fn, "%s", fdata.cFileName); } break; diff --git a/src/extra/libs/fsdrv/lv_fs_stdio.c b/src/extra/libs/fsdrv/lv_fs_stdio.c index 193741b20..e6fd8e0cc 100644 --- a/src/extra/libs/fsdrv/lv_fs_stdio.c +++ b/src/extra/libs/fsdrv/lv_fs_stdio.c @@ -12,10 +12,10 @@ #include #ifndef WIN32 -#include -#include + #include + #include #else -#include + #include #endif /********************* @@ -141,7 +141,7 @@ static lv_fs_res_t fs_read(lv_fs_drv_t * drv, void * file_p, void * buf, uint32_ { LV_UNUSED(drv); *br = fread(buf, 1, btr, file_p); - return (int32_t)*br < 0 ? LV_FS_RES_UNKNOWN : LV_FS_RES_OK; + return (int32_t)(*br) < 0 ? LV_FS_RES_UNKNOWN : LV_FS_RES_OK; } /** @@ -157,7 +157,7 @@ static lv_fs_res_t fs_write(lv_fs_drv_t * drv, void * file_p, const void * buf, { LV_UNUSED(drv); *bw = fwrite(buf, 1, btw, file_p); - return (int32_t)*bw < 0 ? LV_FS_RES_UNKNOWN : LV_FS_RES_OK; + return (int32_t)(*bw) < 0 ? LV_FS_RES_UNKNOWN : LV_FS_RES_OK; } /** @@ -191,7 +191,7 @@ static lv_fs_res_t fs_tell(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p) } #ifdef WIN32 -static char next_fn[256]; + static char next_fn[256]; #endif /** @@ -227,12 +227,14 @@ static void * fs_dir_open(lv_fs_drv_t * drv, const char * path) strcpy(next_fn, ""); d = FindFirstFile(buf, &fdata); do { - if (strcmp(fdata.cFileName, ".") == 0 || strcmp(fdata.cFileName, "..") == 0) { + if(strcmp(fdata.cFileName, ".") == 0 || strcmp(fdata.cFileName, "..") == 0) { continue; - } else { - if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + } + else { + if(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { sprintf(next_fn, "/%s", fdata.cFileName); - } else { + } + else { sprintf(next_fn, "%s", fdata.cFileName); } break; @@ -256,13 +258,14 @@ static lv_fs_res_t fs_dir_read(lv_fs_drv_t * drv, void * dir_p, char * fn) LV_UNUSED(drv); #ifndef WIN32 - struct dirent *entry; + struct dirent * entry; do { entry = readdir(dir_p); if(entry) { if(entry->d_type == DT_DIR) sprintf(fn, "/%s", entry->d_name); else strcpy(fn, entry->d_name); - } else { + } + else { strcpy(fn, ""); } } while(strcmp(fn, "/.") == 0 || strcmp(fn, "/..") == 0); @@ -274,12 +277,14 @@ static lv_fs_res_t fs_dir_read(lv_fs_drv_t * drv, void * dir_p, char * fn) if(FindNextFile(dir_p, &fdata) == false) return LV_FS_RES_OK; do { - if (strcmp(fdata.cFileName, ".") == 0 || strcmp(fdata.cFileName, "..") == 0) { + if(strcmp(fdata.cFileName, ".") == 0 || strcmp(fdata.cFileName, "..") == 0) { continue; - } else { - if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + } + else { + if(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { sprintf(next_fn, "/%s", fdata.cFileName); - } else { + } + else { sprintf(next_fn, "%s", fdata.cFileName); } break; diff --git a/src/extra/libs/fsdrv/lv_fs_win32.c b/src/extra/libs/fsdrv/lv_fs_win32.c index 72ef22a70..4100c5268 100644 --- a/src/extra/libs/fsdrv/lv_fs_win32.c +++ b/src/extra/libs/fsdrv/lv_fs_win32.c @@ -101,7 +101,7 @@ static lv_fs_res_t fs_error_from_win32(DWORD error) { lv_fs_res_t res; - switch (error) { + switch(error) { case ERROR_SUCCESS: res = LV_FS_RES_OK; break; @@ -199,11 +199,11 @@ static void * fs_open(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode) DWORD desired_access = 0; - if (mode & LV_FS_MODE_RD) { + if(mode & LV_FS_MODE_RD) { desired_access |= GENERIC_READ; } - if (mode & LV_FS_MODE_WR) { + if(mode & LV_FS_MODE_WR) { desired_access |= GENERIC_WRITE; } @@ -214,18 +214,18 @@ static void * fs_open(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode) sprintf(buf, LV_FS_WIN32_PATH "%s", path); #endif - return (void*)CreateFileA( + return (void *)CreateFileA( #ifdef LV_FS_WIN32_PATH - buf, + buf, #else - path, + path, #endif - desired_access, - FILE_SHARE_READ, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); + desired_access, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); } /** @@ -239,8 +239,8 @@ static lv_fs_res_t fs_close(lv_fs_drv_t * drv, void * file_p) { LV_UNUSED(drv); return CloseHandle((HANDLE)file_p) - ? LV_FS_RES_OK - : fs_error_from_win32(GetLastError()); + ? LV_FS_RES_OK + : fs_error_from_win32(GetLastError()); } /** @@ -257,8 +257,8 @@ static lv_fs_res_t fs_read(lv_fs_drv_t * drv, void * file_p, void * buf, uint32_ { LV_UNUSED(drv); return ReadFile((HANDLE)file_p, buf, btr, (LPDWORD)br, NULL) - ? LV_FS_RES_OK - : fs_error_from_win32(GetLastError()); + ? LV_FS_RES_OK + : fs_error_from_win32(GetLastError()); } /** @@ -274,8 +274,8 @@ static lv_fs_res_t fs_write(lv_fs_drv_t * drv, void * file_p, const void * buf, { LV_UNUSED(drv); return WriteFile((HANDLE)file_p, buf, btw, (LPDWORD)bw, NULL) - ? LV_FS_RES_OK - : fs_error_from_win32(GetLastError()); + ? LV_FS_RES_OK + : fs_error_from_win32(GetLastError()); } /** @@ -290,8 +290,8 @@ static lv_fs_res_t fs_seek(lv_fs_drv_t * drv, void * file_p, uint32_t pos, lv_fs { LV_UNUSED(drv); - DWORD move_method = (DWORD)-1; - if (whence == LV_FS_SEEK_SET) { + DWORD move_method = (DWORD) -1; + if(whence == LV_FS_SEEK_SET) { move_method = FILE_BEGIN; } else if(whence == LV_FS_SEEK_CUR) { @@ -304,8 +304,8 @@ static lv_fs_res_t fs_seek(lv_fs_drv_t * drv, void * file_p, uint32_t pos, lv_fs LARGE_INTEGER distance_to_move; distance_to_move.QuadPart = pos; return SetFilePointerEx((HANDLE)file_p, distance_to_move, NULL, move_method) - ? LV_FS_RES_OK - : fs_error_from_win32(GetLastError()); + ? LV_FS_RES_OK + : fs_error_from_win32(GetLastError()); } /** @@ -320,7 +320,7 @@ static lv_fs_res_t fs_tell(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p) { LV_UNUSED(drv); - if (!pos_p) { + if(!pos_p) { return LV_FS_RES_INV_PARAM; } @@ -329,12 +329,12 @@ static lv_fs_res_t fs_tell(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p) LARGE_INTEGER distance_to_move; distance_to_move.QuadPart = 0; - if (SetFilePointerEx( - (HANDLE)file_p, - distance_to_move, - &file_pointer, - FILE_CURRENT)) { - if (file_pointer.QuadPart > LONG_MAX) { + if(SetFilePointerEx( + (HANDLE)file_p, + distance_to_move, + &file_pointer, + FILE_CURRENT)) { + if(file_pointer.QuadPart > LONG_MAX) { return LV_FS_RES_INV_PARAM; } else { @@ -374,11 +374,11 @@ static void * fs_dir_open(lv_fs_drv_t * drv, const char * path) strcpy(next_fn, ""); d = FindFirstFileA(buf, &fdata); do { - if (is_dots_name(fdata.cFileName)) { + if(is_dots_name(fdata.cFileName)) { continue; } else { - if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + if(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { sprintf(next_fn, "/%s", fdata.cFileName); } else { @@ -387,7 +387,7 @@ static void * fs_dir_open(lv_fs_drv_t * drv, const char * path) break; } - } while (FindNextFileA(d, &fdata)); + } while(FindNextFileA(d, &fdata)); next_error = fs_error_from_win32(GetLastError()); return d; @@ -412,12 +412,12 @@ static lv_fs_res_t fs_dir_read(lv_fs_drv_t * drv, void * dir_p, char * fn) strcpy(next_fn, ""); WIN32_FIND_DATAA fdata; - while (FindNextFileA(dir_p, &fdata)) { - if (is_dots_name(fdata.cFileName)) { + while(FindNextFileA(dir_p, &fdata)) { + if(is_dots_name(fdata.cFileName)) { continue; } else { - if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + if(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { sprintf(next_fn, "/%s", fdata.cFileName); } else { @@ -427,7 +427,7 @@ static lv_fs_res_t fs_dir_read(lv_fs_drv_t * drv, void * dir_p, char * fn) } } - if (next_fn[0] == '\0') { + if(next_fn[0] == '\0') { next_error = fs_error_from_win32(GetLastError()); } @@ -444,8 +444,8 @@ static lv_fs_res_t fs_dir_close(lv_fs_drv_t * drv, void * dir_p) { LV_UNUSED(drv); return FindClose((HANDLE)dir_p) - ? LV_FS_RES_OK - : fs_error_from_win32(GetLastError()); + ? LV_FS_RES_OK + : fs_error_from_win32(GetLastError()); } #endif /*LV_USE_FS_WIN32*/ diff --git a/src/extra/libs/fsdrv/lv_fsdrv.h b/src/extra/libs/fsdrv/lv_fsdrv.h index c7ca8df1b..285d598fd 100644 --- a/src/extra/libs/fsdrv/lv_fsdrv.h +++ b/src/extra/libs/fsdrv/lv_fsdrv.h @@ -28,19 +28,19 @@ extern "C" { **********************/ #if LV_USE_FS_FATFS != '\0' - void lv_fs_fatfs_init(void); +void lv_fs_fatfs_init(void); #endif #if LV_USE_FS_STDIO != '\0' - void lv_fs_stdio_init(void); +void lv_fs_stdio_init(void); #endif #if LV_USE_FS_POSIX != '\0' - void lv_fs_posix_init(void); +void lv_fs_posix_init(void); #endif #if LV_USE_FS_WIN32 != '\0' - void lv_fs_win32_init(void); +void lv_fs_win32_init(void); #endif /********************** diff --git a/src/extra/libs/gif/lv_gif.c b/src/extra/libs/gif/lv_gif.c index bd3a372b7..4cb2955e2 100644 --- a/src/extra/libs/gif/lv_gif.c +++ b/src/extra/libs/gif/lv_gif.c @@ -69,29 +69,29 @@ void lv_gif_set_src(lv_obj_t * obj, const void * src) if(lv_img_src_get_type(src) == LV_IMG_SRC_VARIABLE) { const lv_img_dsc_t * img_dsc = src; - gifobj->gif = gd_open_gif_data(img_dsc->data); + gifobj->gif = gd_open_gif_data(img_dsc->data); } else if(lv_img_src_get_type(src) == LV_IMG_SRC_FILE) { - gifobj->gif = gd_open_gif_file(src); + gifobj->gif = gd_open_gif_file(src); } if(gifobj->gif == NULL) { LV_LOG_WARN("Could't load the source"); return; } - gifobj->imgdsc.data = gifobj->gif->canvas; - gifobj->imgdsc.header.always_zero = 0; - gifobj->imgdsc.header.cf = LV_IMG_CF_TRUE_COLOR_ALPHA; - gifobj->imgdsc.header.h = gifobj->gif->height; - gifobj->imgdsc.header.w = gifobj->gif->width; - gifobj->last_call = lv_tick_get(); + gifobj->imgdsc.data = gifobj->gif->canvas; + gifobj->imgdsc.header.always_zero = 0; + gifobj->imgdsc.header.cf = LV_IMG_CF_TRUE_COLOR_ALPHA; + gifobj->imgdsc.header.h = gifobj->gif->height; + gifobj->imgdsc.header.w = gifobj->gif->width; + gifobj->last_call = lv_tick_get(); - lv_img_set_src(obj, &gifobj->imgdsc); + lv_img_set_src(obj, &gifobj->imgdsc); - lv_timer_resume(gifobj->timer); - lv_timer_reset(gifobj->timer); + lv_timer_resume(gifobj->timer); + lv_timer_reset(gifobj->timer); - next_frame_task_cb(gifobj->timer); + next_frame_task_cb(gifobj->timer); } @@ -139,7 +139,8 @@ static void next_frame_task_cb(lv_timer_t * t) if(gifobj->gif->loop_count == 1) { lv_res_t res = lv_event_send(obj, LV_EVENT_READY, NULL); if(res != LV_FS_RES_OK) return; - } else { + } + else { if(gifobj->gif->loop_count > 1) gifobj->gif->loop_count--; gd_rewind(gifobj->gif); } diff --git a/src/extra/libs/gif/lv_gif.h b/src/extra/libs/gif/lv_gif.h index a871c614e..d8c93dbc0 100644 --- a/src/extra/libs/gif/lv_gif.h +++ b/src/extra/libs/gif/lv_gif.h @@ -29,11 +29,11 @@ extern "C" { typedef struct { lv_img_t img; - gd_GIF *gif; + gd_GIF * gif; lv_timer_t * timer; lv_img_dsc_t imgdsc; uint32_t last_call; -}lv_gif_t; +} lv_gif_t; extern const lv_obj_class_t lv_gif_class; diff --git a/src/extra/libs/png/lv_png.c b/src/extra/libs/png/lv_png.c index 5eb2ff71c..1207895e5 100644 --- a/src/extra/libs/png/lv_png.c +++ b/src/extra/libs/png/lv_png.c @@ -65,47 +65,47 @@ void lv_png_init(void) static lv_res_t decoder_info(struct _lv_img_decoder_t * decoder, const void * src, lv_img_header_t * header) { (void) decoder; /*Unused*/ - lv_img_src_t src_type = lv_img_src_get_type(src); /*Get the source type*/ + lv_img_src_t src_type = lv_img_src_get_type(src); /*Get the source type*/ - /*If it's a PNG file...*/ - if(src_type == LV_IMG_SRC_FILE) { - const char * fn = src; - if(!strcmp(&fn[strlen(fn) - 3], "png")) { /*Check the extension*/ + /*If it's a PNG file...*/ + if(src_type == LV_IMG_SRC_FILE) { + const char * fn = src; + if(!strcmp(&fn[strlen(fn) - 3], "png")) { /*Check the extension*/ - /* Read the width and height from the file. They have a constant location: - * [16..23]: width - * [24..27]: height - */ - uint32_t size[2]; - lv_fs_file_t f; - lv_fs_res_t res = lv_fs_open(&f, fn, LV_FS_MODE_RD); - if(res != LV_FS_RES_OK) return LV_RES_INV; - lv_fs_seek(&f, 16, LV_FS_SEEK_SET); - uint32_t rn; - lv_fs_read(&f, &size, 8, &rn); - if(rn != 8) return LV_RES_INV; - lv_fs_close(&f); - /*Save the data in the header*/ - header->always_zero = 0; - header->cf = LV_IMG_CF_RAW_ALPHA; - /*The width and height are stored in Big endian format so convert them to little endian*/ - header->w = (lv_coord_t) ((size[0] & 0xff000000) >> 24) + ((size[0] & 0x00ff0000) >> 8); - header->h = (lv_coord_t) ((size[1] & 0xff000000) >> 24) + ((size[1] & 0x00ff0000) >> 8); + /* Read the width and height from the file. They have a constant location: + * [16..23]: width + * [24..27]: height + */ + uint32_t size[2]; + lv_fs_file_t f; + lv_fs_res_t res = lv_fs_open(&f, fn, LV_FS_MODE_RD); + if(res != LV_FS_RES_OK) return LV_RES_INV; + lv_fs_seek(&f, 16, LV_FS_SEEK_SET); + uint32_t rn; + lv_fs_read(&f, &size, 8, &rn); + if(rn != 8) return LV_RES_INV; + lv_fs_close(&f); + /*Save the data in the header*/ + header->always_zero = 0; + header->cf = LV_IMG_CF_RAW_ALPHA; + /*The width and height are stored in Big endian format so convert them to little endian*/ + header->w = (lv_coord_t)((size[0] & 0xff000000) >> 24) + ((size[0] & 0x00ff0000) >> 8); + header->h = (lv_coord_t)((size[1] & 0xff000000) >> 24) + ((size[1] & 0x00ff0000) >> 8); - return LV_RES_OK; - } - } - /*If it's a PNG file in a C array...*/ - else if(src_type == LV_IMG_SRC_VARIABLE) { - const lv_img_dsc_t * img_dsc = src; - header->always_zero = 0; - header->cf = img_dsc->header.cf; /*Save the color format*/ - header->w = img_dsc->header.w; /*Save the color width*/ - header->h = img_dsc->header.h; /*Save the color height*/ - return LV_RES_OK; - } + return LV_RES_OK; + } + } + /*If it's a PNG file in a C array...*/ + else if(src_type == LV_IMG_SRC_VARIABLE) { + const lv_img_dsc_t * img_dsc = src; + header->always_zero = 0; + header->cf = img_dsc->header.cf; /*Save the color format*/ + header->w = img_dsc->header.w; /*Save the color width*/ + header->h = img_dsc->header.h; /*Save the color height*/ + return LV_RES_OK; + } - return LV_RES_INV; /*If didn't succeeded earlier then it's an error*/ + return LV_RES_INV; /*If didn't succeeded earlier then it's an error*/ } @@ -183,10 +183,10 @@ static lv_res_t decoder_open(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * /** * Free the allocated resources */ -static void decoder_close(lv_img_decoder_t *decoder, lv_img_decoder_dsc_t *dsc) +static void decoder_close(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc) { LV_UNUSED(decoder); /*Unused*/ - if (dsc->img_data) { + if(dsc->img_data) { lv_mem_free((uint8_t *)dsc->img_data); dsc->img_data = NULL; } @@ -200,7 +200,7 @@ static void decoder_close(lv_img_decoder_t *decoder, lv_img_decoder_dsc_t *dsc) static void convert_color_depth(uint8_t * img, uint32_t px_cnt) { #if LV_COLOR_DEPTH == 32 - lv_color32_t * img_argb = (lv_color32_t*)img; + lv_color32_t * img_argb = (lv_color32_t *)img; lv_color_t c; lv_color_t * img_c = (lv_color_t *) img; uint32_t i; @@ -210,32 +210,32 @@ static void convert_color_depth(uint8_t * img, uint32_t px_cnt) img_c[i].ch.blue = c.ch.red; } #elif LV_COLOR_DEPTH == 16 - lv_color32_t * img_argb = (lv_color32_t*)img; + lv_color32_t * img_argb = (lv_color32_t *)img; lv_color_t c; uint32_t i; for(i = 0; i < px_cnt; i++) { c = lv_color_make(img_argb[i].ch.blue, img_argb[i].ch.green, img_argb[i].ch.red); - img[i*3 + 2] = img_argb[i].ch.alpha; - img[i*3 + 1] = c.full >> 8; - img[i*3 + 0] = c.full & 0xFF; + img[i * 3 + 2] = img_argb[i].ch.alpha; + img[i * 3 + 1] = c.full >> 8; + img[i * 3 + 0] = c.full & 0xFF; } #elif LV_COLOR_DEPTH == 8 - lv_color32_t * img_argb = (lv_color32_t*)img; + lv_color32_t * img_argb = (lv_color32_t *)img; lv_color_t c; uint32_t i; for(i = 0; i < px_cnt; i++) { c = lv_color_make(img_argb[i].ch.red, img_argb[i].ch.green, img_argb[i].ch.blue); - img[i*2 + 1] = img_argb[i].ch.alpha; - img[i*2 + 0] = c.full; + img[i * 2 + 1] = img_argb[i].ch.alpha; + img[i * 2 + 0] = c.full; } #elif LV_COLOR_DEPTH == 1 - lv_color32_t * img_argb = (lv_color32_t*)img; + lv_color32_t * img_argb = (lv_color32_t *)img; uint8_t b; uint32_t i; for(i = 0; i < px_cnt; i++) { b = img_argb[i].ch.red | img_argb[i].ch.green | img_argb[i].ch.blue; - img[i*2 + 1] = img_argb[i].ch.alpha; - img[i*2 + 0] = b > 128 ? 1 : 0; + img[i * 2 + 1] = img_argb[i].ch.alpha; + img[i * 2 + 0] = b > 128 ? 1 : 0; } #endif } diff --git a/src/extra/libs/qrcode/lv_qrcode.c b/src/extra/libs/qrcode/lv_qrcode.c index 0dfbd3e35..d8a190fc3 100644 --- a/src/extra/libs/qrcode/lv_qrcode.c +++ b/src/extra/libs/qrcode/lv_qrcode.c @@ -88,18 +88,18 @@ lv_res_t lv_qrcode_update(lv_obj_t * qrcode, const void * data, uint32_t data_le lv_img_dsc_t * imgdsc = lv_canvas_get_img(qrcode); int32_t qr_version = qrcodegen_getMinFitVersion(qrcodegen_Ecc_MEDIUM, data_len); - if (qr_version <= 0) return LV_RES_INV; + if(qr_version <= 0) return LV_RES_INV; int32_t qr_size = qrcodegen_version2size(qr_version); - if (qr_size <= 0) return LV_RES_INV; + if(qr_size <= 0) return LV_RES_INV; int32_t scale = imgdsc->header.w / qr_size; - if (scale <= 0) return LV_RES_INV; + if(scale <= 0) return LV_RES_INV; int32_t remain = imgdsc->header.w % qr_size; /* The qr version is incremented by four point */ uint32_t version_extend = remain / (scale << 2); - if (version_extend && qr_version < qrcodegen_VERSION_MAX) { - qr_version = qr_version + version_extend > qrcodegen_VERSION_MAX ? - qrcodegen_VERSION_MAX : qr_version + version_extend; + if(version_extend && qr_version < qrcodegen_VERSION_MAX) { + qr_version = qr_version + version_extend > qrcodegen_VERSION_MAX ? + qrcodegen_VERSION_MAX : qr_version + version_extend; } uint8_t * qr0 = lv_mem_alloc(qrcodegen_BUFFER_LEN_FOR_VERSION(qr_version)); @@ -109,11 +109,11 @@ lv_res_t lv_qrcode_update(lv_obj_t * qrcode, const void * data, uint32_t data_le memcpy(data_tmp, data, data_len); bool ok = qrcodegen_encodeBinary(data_tmp, data_len, - qr0, qrcodegen_Ecc_MEDIUM, - qr_version, qr_version, - qrcodegen_Mask_AUTO, true); + qr0, qrcodegen_Ecc_MEDIUM, + qr_version, qr_version, + qrcodegen_Mask_AUTO, true); - if (!ok) { + if(!ok) { lv_mem_free(qr0); lv_mem_free(data_tmp); return LV_RES_INV; @@ -131,12 +131,12 @@ lv_res_t lv_qrcode_update(lv_obj_t * qrcode, const void * data, uint32_t data_le * So buffer 1 byte (8 px) from the qr code and set it in the canvas image */ uint32_t row_byte_cnt = (imgdsc->header.w + 7) >> 3; int y; - for (y = margin; y < scaled + margin; y+=scale) { + for(y = margin; y < scaled + margin; y += scale) { uint8_t b = 0; uint8_t p = 0; bool aligned = false; int x; - for (x = margin; x < scaled + margin; x++) { + for(x = margin; x < scaled + margin; x++) { bool a = qrcodegen_getModule(qr0, (x - margin) / scale, (y - margin) / scale); if(aligned == false && (x & 0x7) == 0) aligned = true; @@ -144,7 +144,8 @@ lv_res_t lv_qrcode_update(lv_obj_t * qrcode, const void * data, uint32_t data_le if(aligned == false) { c.full = a ? 0 : 1; lv_canvas_set_px_color(qrcode, x, y, c); - } else { + } + else { if(!a) b |= (1 << (7 - p)); p++; if(p == 8) { @@ -165,12 +166,12 @@ lv_res_t lv_qrcode_update(lv_obj_t * qrcode, const void * data, uint32_t data_le buf_u8[px] = b; } - /*The Qr is probably scaled so simply to the repeated rows*/ - int s; - const uint8_t * row_ori = buf_u8 + row_byte_cnt * y; - for(s = 1; s < scale; s++) { - memcpy((uint8_t*)buf_u8 + row_byte_cnt * (y + s), row_ori, row_byte_cnt); - } + /*The Qr is probably scaled so simply to the repeated rows*/ + int s; + const uint8_t * row_ori = buf_u8 + row_byte_cnt * y; + for(s = 1; s < scale; s++) { + memcpy((uint8_t *)buf_u8 + row_byte_cnt * (y + s), row_ori, row_byte_cnt); + } } lv_mem_free(qr0); @@ -210,7 +211,7 @@ static void lv_qrcode_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj) lv_img_dsc_t * img = lv_canvas_get_img(obj); lv_img_cache_invalidate_src(img); - lv_mem_free((void*)img->data); + lv_mem_free((void *)img->data); img->data = NULL; } diff --git a/src/extra/libs/rlottie/lv_rlottie.c b/src/extra/libs/rlottie/lv_rlottie.c index 6b03e7d5c..89d5d1386 100644 --- a/src/extra/libs/rlottie/lv_rlottie.c +++ b/src/extra/libs/rlottie/lv_rlottie.c @@ -3,9 +3,9 @@ * */ - /********************* - * INCLUDES - *********************/ +/********************* + * INCLUDES + *********************/ #include "lv_rlottie.h" #if LV_USE_RLOTTIE @@ -24,7 +24,7 @@ **********************/ static void lv_rlottie_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj); static void lv_rlottie_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj); -static void next_frame_task_cb(lv_timer_t* t); +static void next_frame_task_cb(lv_timer_t * t); /********************** * STATIC VARIABLES @@ -38,18 +38,18 @@ const lv_obj_class_t lv_rlottie_class = { static lv_coord_t create_width; static lv_coord_t create_height; -static const char* rlottie_desc_create; -static const char* path_create; +static const char * rlottie_desc_create; +static const char * path_create; /********************** * MACROS **********************/ - /********************** - * GLOBAL FUNCTIONS - **********************/ +/********************** + * GLOBAL FUNCTIONS + **********************/ -lv_obj_t* lv_rlottie_create_from_file(lv_obj_t* parent, lv_coord_t width, lv_coord_t height, const char* path) +lv_obj_t * lv_rlottie_create_from_file(lv_obj_t * parent, lv_coord_t width, lv_coord_t height, const char * path) { create_width = width; @@ -65,7 +65,7 @@ lv_obj_t* lv_rlottie_create_from_file(lv_obj_t* parent, lv_coord_t width, lv_coo } -lv_obj_t* lv_rlottie_create_from_raw(lv_obj_t* parent, lv_coord_t width, lv_coord_t height, const char* rlottie_desc) +lv_obj_t * lv_rlottie_create_from_raw(lv_obj_t * parent, lv_coord_t width, lv_coord_t height, const char * rlottie_desc) { create_width = width; @@ -90,12 +90,12 @@ static void lv_rlottie_constructor(const lv_obj_class_t * class_p, lv_obj_t * ob lv_rlottie_t * rlottie = (lv_rlottie_t *) obj; if(rlottie_desc_create) { - rlottie->animation = lottie_animation_from_data(rlottie_desc_create, rlottie_desc_create,""); + rlottie->animation = lottie_animation_from_data(rlottie_desc_create, rlottie_desc_create, ""); } else if(path_create) { rlottie->animation = lottie_animation_from_file(path_create); } - if (rlottie->animation == NULL) { + if(rlottie->animation == NULL) { LV_LOG_WARN("The aniamtion can't be opened"); return; } @@ -108,8 +108,7 @@ static void lv_rlottie_constructor(const lv_obj_class_t * class_p, lv_obj_t * ob size_t allocaled_buf_size = (create_width * create_height * LV_COLOR_DEPTH / 8); rlottie->allocated_buf = lv_mem_alloc(allocaled_buf_size); - if (rlottie->allocated_buf != NULL) - { + if(rlottie->allocated_buf != NULL) { rlottie->allocated_buffer_size = allocaled_buf_size; memset(rlottie->allocated_buf, 0, allocaled_buf_size); } @@ -118,7 +117,7 @@ static void lv_rlottie_constructor(const lv_obj_class_t * class_p, lv_obj_t * ob rlottie->imgdsc.header.cf = LV_IMG_CF_TRUE_COLOR_ALPHA; rlottie->imgdsc.header.h = create_height; rlottie->imgdsc.header.w = create_width; - rlottie->imgdsc.data = (void*)rlottie->allocated_buf; + rlottie->imgdsc.data = (void *)rlottie->allocated_buf; rlottie->imgdsc.data_size = allocaled_buf_size; lv_img_set_src(obj, &rlottie->imgdsc); @@ -129,12 +128,12 @@ static void lv_rlottie_constructor(const lv_obj_class_t * class_p, lv_obj_t * ob } -static void lv_rlottie_destructor(const lv_obj_class_t * class_p, lv_obj_t* obj) +static void lv_rlottie_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj) { lv_rlottie_t * rlottie = (lv_rlottie_t *) obj; - if (rlottie->animation) { + if(rlottie->animation) { lottie_animation_destroy(rlottie->animation); rlottie->animation = 0; rlottie->current_frame = 0; @@ -143,12 +142,12 @@ static void lv_rlottie_destructor(const lv_obj_class_t * class_p, lv_obj_t* obj) rlottie->total_frames = 0; } - if (rlottie->task){ + if(rlottie->task) { lv_timer_del(rlottie->task); rlottie->task = NULL; } - if (rlottie->allocated_buf) { + if(rlottie->allocated_buf) { lv_mem_free(rlottie->allocated_buf); rlottie->allocated_buf = NULL; rlottie->allocated_buffer_size = 0; @@ -156,22 +155,22 @@ static void lv_rlottie_destructor(const lv_obj_class_t * class_p, lv_obj_t* obj) } -static void next_frame_task_cb(lv_timer_t* t) +static void next_frame_task_cb(lv_timer_t * t) { - lv_obj_t* obj = t->user_data; + lv_obj_t * obj = t->user_data; lv_rlottie_t * rlottie = (lv_rlottie_t *) obj; - if (rlottie->current_frame == rlottie->total_frames) + if(rlottie->current_frame == rlottie->total_frames) rlottie->current_frame = 0; else ++rlottie->current_frame; lottie_animation_render( - rlottie->animation, - rlottie->current_frame, - rlottie->allocated_buf, - rlottie->imgdsc.header.w, - rlottie->imgdsc.header.h, - rlottie->scanline_width + rlottie->animation, + rlottie->current_frame, + rlottie->allocated_buf, + rlottie->imgdsc.header.w, + rlottie->imgdsc.header.h, + rlottie->scanline_width ); lv_obj_invalidate(obj); diff --git a/src/extra/libs/rlottie/lv_rlottie.h b/src/extra/libs/rlottie/lv_rlottie.h index 46b3ed567..7730f2fb9 100644 --- a/src/extra/libs/rlottie/lv_rlottie.h +++ b/src/extra/libs/rlottie/lv_rlottie.h @@ -27,16 +27,16 @@ extern "C" { **********************/ typedef struct { lv_img_t img_ext; - Lottie_Animation* animation; - lv_timer_t* task; + Lottie_Animation * animation; + lv_timer_t * task; lv_img_dsc_t imgdsc; size_t total_frames; size_t current_frame; size_t framerate; - uint32_t* allocated_buf; + uint32_t * allocated_buf; size_t allocated_buffer_size; size_t scanline_width; -}lv_rlottie_t; +} lv_rlottie_t; extern const lv_obj_class_t lv_rlottie_class; @@ -44,9 +44,10 @@ extern const lv_obj_class_t lv_rlottie_class; * GLOBAL PROTOTYPES **********************/ -lv_obj_t * lv_rlottie_create_from_file(lv_obj_t * parent,lv_coord_t width, lv_coord_t height, const char * path); +lv_obj_t * lv_rlottie_create_from_file(lv_obj_t * parent, lv_coord_t width, lv_coord_t height, const char * path); -lv_obj_t* lv_rlottie_create_from_raw(lv_obj_t* parent, lv_coord_t width, lv_coord_t height, const char* rlottie_desc); +lv_obj_t * lv_rlottie_create_from_raw(lv_obj_t * parent, lv_coord_t width, lv_coord_t height, + const char * rlottie_desc); /********************** * MACROS diff --git a/src/extra/libs/sjpg/lv_sjpg.c b/src/extra/libs/sjpg/lv_sjpg.c index e84a1959c..a34df6a72 100644 --- a/src/extra/libs/sjpg/lv_sjpg.c +++ b/src/extra/libs/sjpg/lv_sjpg.c @@ -36,9 +36,9 @@ /---------------------------------------------------------------------------------------------------------------------------------- / JPEG DECODER / ------------ -/ We are using TJpgDec - Tiny JPEG Decompressor library from ELM-CHAN for decoding each split-jpeg fragments. -/ The tjpgd.c and tjpgd.h is not modified and those are used as it is. So if any update comes for the tiny-jpeg, -/ just replace those files with updated files. +/ We are using TJpgDec - Tiny JPEG Decompressor library from ELM-CHAN for decoding each split-jpeg fragments. +/ The tjpgd.c and tjpgd.h is not modified and those are used as it is. So if any update comes for the tiny-jpeg, +/ just replace those files with updated files. /---------------------------------------------------------------------------------------------------------------------------------*/ /********************* @@ -77,42 +77,43 @@ enum io_source_type { typedef struct { enum io_source_type type; lv_fs_file_t lv_file; - uint8_t* img_cache_buff; + uint8_t * img_cache_buff; int img_cache_x_res; int img_cache_y_res; - uint8_t *raw_sjpg_data; //Used when type==SJPEG_IO_SOURCE_C_ARRAY. + uint8_t * raw_sjpg_data; //Used when type==SJPEG_IO_SOURCE_C_ARRAY. uint32_t raw_sjpg_data_size; //Num bytes pointed to by raw_sjpg_data. uint32_t raw_sjpg_data_next_read_pos; //Used for all types. } io_source_t; typedef struct { - uint8_t *sjpeg_data; + uint8_t * sjpeg_data; uint32_t sjpeg_data_size; int sjpeg_x_res; int sjpeg_y_res; int sjpeg_total_frames; int sjpeg_single_frame_height; int sjpeg_cache_frame_index; - uint8_t **frame_base_array; //to save base address of each split frames upto sjpeg_total_frames. - int *frame_base_offset; //to save base offset for fseek - uint8_t *frame_cache; - uint8_t* workb; //JPG work buffer for jpeg library - JDEC *tjpeg_jd; + uint8_t ** frame_base_array; //to save base address of each split frames upto sjpeg_total_frames. + int * frame_base_offset; //to save base offset for fseek + uint8_t * frame_cache; + uint8_t * workb; //JPG work buffer for jpeg library + JDEC * tjpeg_jd; io_source_t io; } SJPEG; /********************** * STATIC PROTOTYPES **********************/ -static lv_res_t decoder_info( lv_img_decoder_t * decoder, const void * src, lv_img_header_t * header ); -static lv_res_t decoder_open( lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc ); -static lv_res_t decoder_read_line( lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc, lv_coord_t x,lv_coord_t y, lv_coord_t len, uint8_t * buf ); -static void decoder_close( lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc ); -static size_t input_func ( JDEC* jd, uint8_t* buff, size_t ndata ); -static int is_jpg( const uint8_t *raw_data ); -static void lv_sjpg_cleanup( SJPEG* sjpeg ); -static void lv_sjpg_free( SJPEG* sjpeg ); +static lv_res_t decoder_info(lv_img_decoder_t * decoder, const void * src, lv_img_header_t * header); +static lv_res_t decoder_open(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc); +static lv_res_t decoder_read_line(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc, lv_coord_t x, lv_coord_t y, + lv_coord_t len, uint8_t * buf); +static void decoder_close(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc); +static size_t input_func(JDEC * jd, uint8_t * buff, size_t ndata); +static int is_jpg(const uint8_t * raw_data); +static void lv_sjpg_cleanup(SJPEG * sjpeg); +static void lv_sjpg_free(SJPEG * sjpeg); /********************** * STATIC VARIABLES @@ -125,13 +126,13 @@ static void lv_sjpg_free( SJPEG* sjpeg ); /********************** * GLOBAL FUNCTIONS **********************/ -void lv_split_jpeg_init( void ) +void lv_split_jpeg_init(void) { - lv_img_decoder_t* dec = lv_img_decoder_create( ); - lv_img_decoder_set_info_cb( dec, decoder_info ); - lv_img_decoder_set_open_cb( dec, decoder_open ); - lv_img_decoder_set_close_cb( dec, decoder_close ); - lv_img_decoder_set_read_line_cb( dec, decoder_read_line ); + lv_img_decoder_t * dec = lv_img_decoder_create(); + lv_img_decoder_set_info_cb(dec, decoder_info); + lv_img_decoder_set_open_cb(dec, decoder_open); + lv_img_decoder_set_close_cb(dec, decoder_close); + lv_img_decoder_set_read_line_cb(dec, decoder_read_line); } /********************** @@ -144,7 +145,7 @@ void lv_split_jpeg_init( void ) * @param header store the info here * @return LV_RES_OK: no error; LV_RES_INV: can't get the info */ -static lv_res_t decoder_info( lv_img_decoder_t * decoder, const void * src, lv_img_header_t * header ) +static lv_res_t decoder_info(lv_img_decoder_t * decoder, const void * src, lv_img_header_t * header) { LV_UNUSED(decoder); @@ -156,10 +157,10 @@ static lv_res_t decoder_info( lv_img_decoder_t * decoder, const void * src, lv_i lv_res_t ret = LV_RES_OK; if(src_type == LV_IMG_SRC_VARIABLE) { - uint8_t *raw_sjpeg_data = (uint8_t *)((lv_img_dsc_t * )src)->data; + uint8_t * raw_sjpeg_data = (uint8_t *)((lv_img_dsc_t *)src)->data; const uint32_t raw_sjpeg_data_size = ((lv_img_dsc_t *)src)->data_size; - if(!strncmp((char *)raw_sjpeg_data, "_SJPG__", strlen("_SJPG__") )) { + if(!strncmp((char *)raw_sjpeg_data, "_SJPG__", strlen("_SJPG__"))) { raw_sjpeg_data += 14; //seek to res info ... refer sjpeg format header->always_zero = 0; @@ -173,11 +174,12 @@ static lv_res_t decoder_info( lv_img_decoder_t * decoder, const void * src, lv_i return ret; - } else if( is_jpg( raw_sjpeg_data ) == true ) { + } + else if(is_jpg(raw_sjpeg_data) == true) { header->always_zero = 0; header->cf = LV_IMG_CF_RAW; - uint8_t *workb_temp = lv_mem_alloc( TJPGD_WORKBUFF_SIZE ); + uint8_t * workb_temp = lv_mem_alloc(TJPGD_WORKBUFF_SIZE); if(!workb_temp) return LV_RES_INV; io_source_t io_source_temp; @@ -188,24 +190,25 @@ static lv_res_t decoder_info( lv_img_decoder_t * decoder, const void * src, lv_i JDEC jd_tmp; - JRESULT rc = jd_prepare( &jd_tmp, input_func, workb_temp, (size_t)TJPGD_WORKBUFF_SIZE, &io_source_temp); - if(rc == JDR_OK ) { + JRESULT rc = jd_prepare(&jd_tmp, input_func, workb_temp, (size_t)TJPGD_WORKBUFF_SIZE, &io_source_temp); + if(rc == JDR_OK) { header->w = jd_tmp.width; header->h = jd_tmp.height; - } else { + } + else { ret = LV_RES_INV; goto end; } - end: +end: lv_mem_free(workb_temp); return ret; } } - else if( src_type == LV_IMG_SRC_FILE ) { + else if(src_type == LV_IMG_SRC_FILE) { const char * fn = src; if(!strcmp(&fn[strlen(fn) - 5], ".sjpg")) { @@ -213,7 +216,7 @@ static lv_res_t decoder_info( lv_img_decoder_t * decoder, const void * src, lv_i memset(buff, 0, sizeof(buff)); lv_fs_file_t file; - lv_fs_res_t res = lv_fs_open(&file , fn, LV_FS_MODE_RD); + lv_fs_res_t res = lv_fs_open(&file, fn, LV_FS_MODE_RD); if(res != LV_FS_RES_OK) return 78; uint32_t rn; @@ -223,16 +226,16 @@ static lv_res_t decoder_info( lv_img_decoder_t * decoder, const void * src, lv_i return LV_RES_INV; } - if(strcmp((char *)buff, "_SJPG__") == 0 ) { + if(strcmp((char *)buff, "_SJPG__") == 0) { lv_fs_seek(&file, 14, LV_FS_SEEK_SET); res = lv_fs_read(&file, buff, 4, &rn); - if(res != LV_FS_RES_OK || rn != 4 ) { + if(res != LV_FS_RES_OK || rn != 4) { lv_fs_close(&file); return LV_RES_INV; } header->always_zero = 0; header->cf = LV_IMG_CF_RAW; - uint8_t *raw_sjpeg_data = buff; + uint8_t * raw_sjpeg_data = buff; header->w = *raw_sjpeg_data++; header->w |= *raw_sjpeg_data++ << 8; header->h = *raw_sjpeg_data++; @@ -241,12 +244,13 @@ static lv_res_t decoder_info( lv_img_decoder_t * decoder, const void * src, lv_i return LV_RES_OK; } - } else if(!strcmp(&fn[strlen(fn) - 4], ".jpg")) { + } + else if(!strcmp(&fn[strlen(fn) - 4], ".jpg")) { lv_fs_file_t file; - lv_fs_res_t res = lv_fs_open(&file , fn, LV_FS_MODE_RD); + lv_fs_res_t res = lv_fs_open(&file, fn, LV_FS_MODE_RD); if(res != LV_FS_RES_OK) return 78; - uint8_t *workb_temp = lv_mem_alloc( TJPGD_WORKBUFF_SIZE ); + uint8_t * workb_temp = lv_mem_alloc(TJPGD_WORKBUFF_SIZE); if(!workb_temp) { lv_fs_close(&file); return LV_RES_INV; @@ -259,11 +263,11 @@ static lv_res_t decoder_info( lv_img_decoder_t * decoder, const void * src, lv_i io_source_temp.lv_file = file; JDEC jd_tmp; - JRESULT rc = jd_prepare( &jd_tmp, input_func, workb_temp, (size_t)TJPGD_WORKBUFF_SIZE, &io_source_temp); + JRESULT rc = jd_prepare(&jd_tmp, input_func, workb_temp, (size_t)TJPGD_WORKBUFF_SIZE, &io_source_temp); lv_mem_free(workb_temp); lv_fs_close(&file); - if(rc == JDR_OK ) { + if(rc == JDR_OK) { header->always_zero = 0; header->cf = LV_IMG_CF_RAW; header->w = jd_tmp.width; @@ -275,35 +279,35 @@ static lv_res_t decoder_info( lv_img_decoder_t * decoder, const void * src, lv_i return LV_RES_INV; } -static int img_data_cb( JDEC* jd, void* data, JRECT* rect ) +static int img_data_cb(JDEC * jd, void * data, JRECT * rect) { - io_source_t *io = jd->device; - uint8_t *cache = io->img_cache_buff; + io_source_t * io = jd->device; + uint8_t * cache = io->img_cache_buff; const int xres = io->img_cache_x_res; - uint8_t *buf = data; + uint8_t * buf = data; const int INPUT_PIXEL_SIZE = 3; const int row_width = rect->right - rect->left + 1; // Row width in pixels. const int row_size = row_width * INPUT_PIXEL_SIZE; // Row size (bytes). - for( int y = rect->top; y <= rect->bottom; y++ ) { + for(int y = rect->top; y <= rect->bottom; y++) { int row_offset = y * xres * INPUT_PIXEL_SIZE + rect->left * INPUT_PIXEL_SIZE; - memcpy( cache + row_offset, buf, row_size ); + memcpy(cache + row_offset, buf, row_size); buf += row_size; } return 1; } -static size_t input_func ( JDEC* jd, uint8_t* buff, size_t ndata ) +static size_t input_func(JDEC * jd, uint8_t * buff, size_t ndata) { - io_source_t *io = jd->device; + io_source_t * io = jd->device; if(!io) return 0; if(io->type == SJPEG_IO_SOURCE_C_ARRAY) { const uint32_t bytes_left = io->raw_sjpg_data_size - io->raw_sjpg_data_next_read_pos; const uint32_t to_read = ndata <= bytes_left ? (uint32_t)ndata : bytes_left; - if (to_read == 0) + if(to_read == 0) return 0; if(buff) { memcpy(buff, io->raw_sjpg_data + io->raw_sjpg_data_next_read_pos, to_read); @@ -313,13 +317,14 @@ static size_t input_func ( JDEC* jd, uint8_t* buff, size_t ndata ) } else if(io->type == SJPEG_IO_SOURCE_DISK) { - lv_fs_file_t* lv_file_p = &(io->lv_file); + lv_fs_file_t * lv_file_p = &(io->lv_file); - if( buff ) { + if(buff) { uint32_t rn = 0; lv_fs_read(lv_file_p, buff, (uint32_t)ndata, &rn); return rn; - } else { + } + else { uint32_t pos; lv_fs_tell(lv_file_p, &pos); lv_fs_seek(lv_file_p, (uint32_t)(ndata + pos), LV_FS_SEEK_SET); @@ -335,26 +340,26 @@ static size_t input_func ( JDEC* jd, uint8_t* buff, size_t ndata ) * @param dsc pointer to a descriptor which describes this decoding session * @return LV_RES_OK: no error; LV_RES_INV: can't get the info */ -static lv_res_t decoder_open( lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc ) +static lv_res_t decoder_open(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc) { LV_UNUSED(decoder); lv_res_t lv_ret = LV_RES_OK; if(dsc->src_type == LV_IMG_SRC_VARIABLE) { - uint8_t *data; - SJPEG* sjpeg = ( SJPEG* ) dsc->user_data; - if( sjpeg == NULL ) { - sjpeg = lv_mem_alloc( sizeof( SJPEG ) ); - if( !sjpeg ) return LV_RES_INV; + uint8_t * data; + SJPEG * sjpeg = (SJPEG *) dsc->user_data; + if(sjpeg == NULL) { + sjpeg = lv_mem_alloc(sizeof(SJPEG)); + if(!sjpeg) return LV_RES_INV; memset(sjpeg, 0, sizeof(SJPEG)); dsc->user_data = sjpeg; - sjpeg->sjpeg_data = (uint8_t *)( ( lv_img_dsc_t* )(dsc->src) )->data; - sjpeg->sjpeg_data_size = ( ( lv_img_dsc_t* )(dsc->src) )->data_size; + sjpeg->sjpeg_data = (uint8_t *)((lv_img_dsc_t *)(dsc->src))->data; + sjpeg->sjpeg_data_size = ((lv_img_dsc_t *)(dsc->src))->data_size; } - if( !strncmp( ( char * ) sjpeg->sjpeg_data, "_SJPG__", strlen("_SJPG__") ) ) { + if(!strncmp((char *) sjpeg->sjpeg_data, "_SJPG__", strlen("_SJPG__"))) { data = sjpeg->sjpeg_data; data += 14; @@ -371,42 +376,42 @@ static lv_res_t decoder_open( lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * sjpeg->sjpeg_single_frame_height = *data++; sjpeg->sjpeg_single_frame_height |= *data++ << 8; - sjpeg->frame_base_array = lv_mem_alloc( sizeof(uint8_t *) * sjpeg->sjpeg_total_frames ); - if( ! sjpeg->frame_base_array ) { - lv_sjpg_cleanup( sjpeg ); + sjpeg->frame_base_array = lv_mem_alloc(sizeof(uint8_t *) * sjpeg->sjpeg_total_frames); + if(! sjpeg->frame_base_array) { + lv_sjpg_cleanup(sjpeg); sjpeg = NULL; return LV_RES_INV; } sjpeg->frame_base_offset = NULL; - uint8_t *img_frame_base = data + sjpeg->sjpeg_total_frames *2; + uint8_t * img_frame_base = data + sjpeg->sjpeg_total_frames * 2; sjpeg->frame_base_array[0] = img_frame_base; - for( int i = 1; i < sjpeg->sjpeg_total_frames; i++ ) { + for(int i = 1; i < sjpeg->sjpeg_total_frames; i++) { int offset = *data++; - offset |= *data++ <<8; - sjpeg->frame_base_array[i] = sjpeg->frame_base_array[i-1] + offset; + offset |= *data++ << 8; + sjpeg->frame_base_array[i] = sjpeg->frame_base_array[i - 1] + offset; } sjpeg->sjpeg_cache_frame_index = -1; - sjpeg->frame_cache = (void *)lv_mem_alloc( sjpeg->sjpeg_x_res * sjpeg->sjpeg_single_frame_height * 3/*2*/ ); - if( ! sjpeg->frame_cache ) { - lv_sjpg_cleanup( sjpeg ); + sjpeg->frame_cache = (void *)lv_mem_alloc(sjpeg->sjpeg_x_res * sjpeg->sjpeg_single_frame_height * 3/*2*/); + if(! sjpeg->frame_cache) { + lv_sjpg_cleanup(sjpeg); sjpeg = NULL; return LV_RES_INV; } sjpeg->io.img_cache_buff = sjpeg->frame_cache; sjpeg->io.img_cache_x_res = sjpeg->sjpeg_x_res; - sjpeg->workb = lv_mem_alloc( TJPGD_WORKBUFF_SIZE ); - if( ! sjpeg->workb ) { - lv_sjpg_cleanup( sjpeg ); + sjpeg->workb = lv_mem_alloc(TJPGD_WORKBUFF_SIZE); + if(! sjpeg->workb) { + lv_sjpg_cleanup(sjpeg); sjpeg = NULL; return LV_RES_INV; } - sjpeg->tjpeg_jd = lv_mem_alloc( sizeof( JDEC ) ); - if( ! sjpeg->tjpeg_jd ) { - lv_sjpg_cleanup( sjpeg ); + sjpeg->tjpeg_jd = lv_mem_alloc(sizeof(JDEC)); + if(! sjpeg->tjpeg_jd) { + lv_sjpg_cleanup(sjpeg); sjpeg = NULL; return LV_RES_INV; } @@ -416,11 +421,11 @@ static lv_res_t decoder_open( lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * return lv_ret; } - else if( is_jpg( sjpeg->sjpeg_data ) == true ) { + else if(is_jpg(sjpeg->sjpeg_data) == true) { - uint8_t *workb_temp = lv_mem_alloc( TJPGD_WORKBUFF_SIZE ); - if( ! workb_temp ) { - lv_sjpg_cleanup( sjpeg ); + uint8_t * workb_temp = lv_mem_alloc(TJPGD_WORKBUFF_SIZE); + if(! workb_temp) { + lv_sjpg_cleanup(sjpeg); sjpeg = NULL; return LV_RES_INV; } @@ -431,47 +436,47 @@ static lv_res_t decoder_open( lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * io_source_temp.raw_sjpg_data_next_read_pos = 0; JDEC jd_tmp; - JRESULT rc = jd_prepare( &jd_tmp, input_func, workb_temp, (size_t)TJPGD_WORKBUFF_SIZE, &io_source_temp); + JRESULT rc = jd_prepare(&jd_tmp, input_func, workb_temp, (size_t)TJPGD_WORKBUFF_SIZE, &io_source_temp); lv_mem_free(workb_temp); - if(rc == JDR_OK ) { + if(rc == JDR_OK) { sjpeg->sjpeg_x_res = jd_tmp.width; sjpeg->sjpeg_y_res = jd_tmp.height; sjpeg->sjpeg_total_frames = 1; sjpeg->sjpeg_single_frame_height = jd_tmp.height; - sjpeg->frame_base_array = lv_mem_alloc( sizeof(uint8_t *) * sjpeg->sjpeg_total_frames ); - if( ! sjpeg->frame_base_array ) { - lv_sjpg_cleanup( sjpeg ); + sjpeg->frame_base_array = lv_mem_alloc(sizeof(uint8_t *) * sjpeg->sjpeg_total_frames); + if(! sjpeg->frame_base_array) { + lv_sjpg_cleanup(sjpeg); sjpeg = NULL; return LV_RES_INV; } sjpeg->frame_base_offset = NULL; - uint8_t *img_frame_base = sjpeg->sjpeg_data; + uint8_t * img_frame_base = sjpeg->sjpeg_data; sjpeg->frame_base_array[0] = img_frame_base; sjpeg->sjpeg_cache_frame_index = -1; - sjpeg->frame_cache = (void *)lv_mem_alloc( sjpeg->sjpeg_x_res * sjpeg->sjpeg_single_frame_height * 3 ); - if( ! sjpeg->frame_cache ) { - lv_sjpg_cleanup( sjpeg ); + sjpeg->frame_cache = (void *)lv_mem_alloc(sjpeg->sjpeg_x_res * sjpeg->sjpeg_single_frame_height * 3); + if(! sjpeg->frame_cache) { + lv_sjpg_cleanup(sjpeg); sjpeg = NULL; return LV_RES_INV; } sjpeg->io.img_cache_buff = sjpeg->frame_cache; sjpeg->io.img_cache_x_res = sjpeg->sjpeg_x_res; - sjpeg->workb = lv_mem_alloc( TJPGD_WORKBUFF_SIZE ); - if( ! sjpeg->workb ) { - lv_sjpg_cleanup( sjpeg ); + sjpeg->workb = lv_mem_alloc(TJPGD_WORKBUFF_SIZE); + if(! sjpeg->workb) { + lv_sjpg_cleanup(sjpeg); sjpeg = NULL; return LV_RES_INV; } - sjpeg->tjpeg_jd = lv_mem_alloc( sizeof( JDEC ) ); - if( ! sjpeg->tjpeg_jd ) { - lv_sjpg_cleanup( sjpeg ); + sjpeg->tjpeg_jd = lv_mem_alloc(sizeof(JDEC)); + if(! sjpeg->tjpeg_jd) { + lv_sjpg_cleanup(sjpeg); sjpeg = NULL; return LV_RES_INV; } @@ -480,12 +485,13 @@ static lv_res_t decoder_open( lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * sjpeg->io.lv_file.file_d = NULL; dsc->img_data = NULL; return lv_ret; - } else { + } + else { lv_ret = LV_RES_INV; goto end; } - end: +end: lv_mem_free(workb_temp); return lv_ret; @@ -494,7 +500,7 @@ static lv_res_t decoder_open( lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * else if(dsc->src_type == LV_IMG_SRC_FILE) { /* If all fine, then the file will be kept open */ const char * fn = dsc->src; - uint8_t *data; + uint8_t * data; if(!strcmp(&fn[strlen(fn) - 5], ".sjpg")) { @@ -503,7 +509,7 @@ static lv_res_t decoder_open( lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * lv_fs_file_t lv_file; - lv_fs_res_t res = lv_fs_open(&lv_file , fn, LV_FS_MODE_RD); + lv_fs_res_t res = lv_fs_open(&lv_file, fn, LV_FS_MODE_RD); if(res != LV_FS_RES_OK) { return 78; } @@ -511,26 +517,26 @@ static lv_res_t decoder_open( lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * uint32_t rn; res = lv_fs_read(&lv_file, buff, 22, &rn); - if(res != LV_FS_RES_OK || rn != 22 ) { + if(res != LV_FS_RES_OK || rn != 22) { lv_fs_close(&lv_file); return LV_RES_INV; } - if(strcmp((char *)buff, "_SJPG__") == 0 ) { + if(strcmp((char *)buff, "_SJPG__") == 0) { - SJPEG* sjpeg = ( SJPEG* ) dsc->user_data; + SJPEG * sjpeg = (SJPEG *) dsc->user_data; if(sjpeg == NULL) { sjpeg = lv_mem_alloc(sizeof(SJPEG)); - if( ! sjpeg ) { + if(! sjpeg) { lv_fs_close(&lv_file); return LV_RES_INV; } memset(sjpeg, 0, sizeof(SJPEG)); dsc->user_data = sjpeg; - sjpeg->sjpeg_data = (uint8_t *)( (lv_img_dsc_t* )(dsc->src) )->data; - sjpeg->sjpeg_data_size = ( (lv_img_dsc_t* )(dsc->src) )->data_size; + sjpeg->sjpeg_data = (uint8_t *)((lv_img_dsc_t *)(dsc->src))->data; + sjpeg->sjpeg_data_size = ((lv_img_dsc_t *)(dsc->src))->data_size; } data = buff; data += 14; @@ -548,46 +554,46 @@ static lv_res_t decoder_open( lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * sjpeg->sjpeg_single_frame_height |= *data++ << 8; sjpeg->frame_base_array = NULL;//lv_mem_alloc( sizeof(uint8_t *) * sjpeg->sjpeg_total_frames ); - sjpeg->frame_base_offset = lv_mem_alloc( sizeof(int) * sjpeg->sjpeg_total_frames ); - if( ! sjpeg->frame_base_offset ) { + sjpeg->frame_base_offset = lv_mem_alloc(sizeof(int) * sjpeg->sjpeg_total_frames); + if(! sjpeg->frame_base_offset) { lv_fs_close(&lv_file); lv_sjpg_cleanup(sjpeg); return LV_RES_INV; } - int img_frame_start_offset = (SJPEG_FRAME_INFO_ARRAY_OFFSET + sjpeg->sjpeg_total_frames *2); + int img_frame_start_offset = (SJPEG_FRAME_INFO_ARRAY_OFFSET + sjpeg->sjpeg_total_frames * 2); sjpeg->frame_base_offset[0] = img_frame_start_offset; //pointer used to save integer for now... - for( int i = 1; i < sjpeg->sjpeg_total_frames; i++ ) { + for(int i = 1; i < sjpeg->sjpeg_total_frames; i++) { res = lv_fs_read(&lv_file, buff, 2, &rn); - if(res != LV_FS_RES_OK || rn != 2 ) { + if(res != LV_FS_RES_OK || rn != 2) { lv_fs_close(&lv_file); return LV_RES_INV; } data = buff; int offset = *data++; - offset |= *data++ <<8; - sjpeg->frame_base_offset[i] = sjpeg->frame_base_offset[i-1] + offset; + offset |= *data++ << 8; + sjpeg->frame_base_offset[i] = sjpeg->frame_base_offset[i - 1] + offset; } sjpeg->sjpeg_cache_frame_index = -1; //INVALID AT BEGINNING for a forced compare mismatch at first time. - sjpeg->frame_cache = (void *)lv_mem_alloc( sjpeg->sjpeg_x_res * sjpeg->sjpeg_single_frame_height * 3 ); - if( ! sjpeg->frame_cache ) { + sjpeg->frame_cache = (void *)lv_mem_alloc(sjpeg->sjpeg_x_res * sjpeg->sjpeg_single_frame_height * 3); + if(! sjpeg->frame_cache) { lv_fs_close(&lv_file); lv_sjpg_cleanup(sjpeg); return LV_RES_INV; } sjpeg->io.img_cache_buff = sjpeg->frame_cache; sjpeg->io.img_cache_x_res = sjpeg->sjpeg_x_res; - sjpeg->workb = lv_mem_alloc( TJPGD_WORKBUFF_SIZE ); - if( ! sjpeg->workb ) { + sjpeg->workb = lv_mem_alloc(TJPGD_WORKBUFF_SIZE); + if(! sjpeg->workb) { lv_fs_close(&lv_file); lv_sjpg_cleanup(sjpeg); return LV_RES_INV; } - sjpeg->tjpeg_jd = lv_mem_alloc( sizeof( JDEC ) ); - if( ! sjpeg->tjpeg_jd ) { + sjpeg->tjpeg_jd = lv_mem_alloc(sizeof(JDEC)); + if(! sjpeg->tjpeg_jd) { lv_fs_close(&lv_file); lv_sjpg_cleanup(sjpeg); return LV_RES_INV; @@ -599,30 +605,30 @@ static lv_res_t decoder_open( lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * return LV_RES_OK; } } - else if( !strcmp(&fn[strlen(fn) - 4], ".jpg" ) ) { + else if(!strcmp(&fn[strlen(fn) - 4], ".jpg")) { lv_fs_file_t lv_file; - lv_fs_res_t res = lv_fs_open( &lv_file , fn, LV_FS_MODE_RD ); + lv_fs_res_t res = lv_fs_open(&lv_file, fn, LV_FS_MODE_RD); if(res != LV_FS_RES_OK) { return LV_RES_INV; } - SJPEG* sjpeg = ( SJPEG* ) dsc->user_data; + SJPEG * sjpeg = (SJPEG *) dsc->user_data; if(sjpeg == NULL) { - sjpeg = lv_mem_alloc( sizeof( SJPEG ) ); - if( ! sjpeg ) { - lv_fs_close( &lv_file ); + sjpeg = lv_mem_alloc(sizeof(SJPEG)); + if(! sjpeg) { + lv_fs_close(&lv_file); return LV_RES_INV; } memset(sjpeg, 0, sizeof(SJPEG)); dsc->user_data = sjpeg; - sjpeg->sjpeg_data = (uint8_t *)( (lv_img_dsc_t* )(dsc->src) )->data; - sjpeg->sjpeg_data_size = ( (lv_img_dsc_t *)(dsc->src) )->data_size; + sjpeg->sjpeg_data = (uint8_t *)((lv_img_dsc_t *)(dsc->src))->data; + sjpeg->sjpeg_data_size = ((lv_img_dsc_t *)(dsc->src))->data_size; } - uint8_t *workb_temp = lv_mem_alloc( TJPGD_WORKBUFF_SIZE ); - if( ! workb_temp ) { + uint8_t * workb_temp = lv_mem_alloc(TJPGD_WORKBUFF_SIZE); + if(! workb_temp) { lv_fs_close(&lv_file); lv_sjpg_cleanup(sjpeg); return LV_RES_INV; @@ -636,20 +642,20 @@ static lv_res_t decoder_open( lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * JDEC jd_tmp; - JRESULT rc = jd_prepare( &jd_tmp, input_func, workb_temp, (size_t)TJPGD_WORKBUFF_SIZE, &io_source_temp); + JRESULT rc = jd_prepare(&jd_tmp, input_func, workb_temp, (size_t)TJPGD_WORKBUFF_SIZE, &io_source_temp); lv_mem_free(workb_temp); - if(rc == JDR_OK ) { + if(rc == JDR_OK) { sjpeg->sjpeg_x_res = jd_tmp.width; sjpeg->sjpeg_y_res = jd_tmp.height; sjpeg->sjpeg_total_frames = 1; sjpeg->sjpeg_single_frame_height = jd_tmp.height; sjpeg->frame_base_array = NULL; - sjpeg->frame_base_offset = lv_mem_alloc( sizeof(uint8_t *) * sjpeg->sjpeg_total_frames ); - if( ! sjpeg->frame_base_offset ) { + sjpeg->frame_base_offset = lv_mem_alloc(sizeof(uint8_t *) * sjpeg->sjpeg_total_frames); + if(! sjpeg->frame_base_offset) { lv_fs_close(&lv_file); lv_sjpg_cleanup(sjpeg); return LV_RES_INV; @@ -659,8 +665,8 @@ static lv_res_t decoder_open( lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * sjpeg->frame_base_offset[0] = img_frame_start_offset; sjpeg->sjpeg_cache_frame_index = -1; - sjpeg->frame_cache = (void *)lv_mem_alloc( sjpeg->sjpeg_x_res * sjpeg->sjpeg_single_frame_height * 3 ); - if( ! sjpeg->frame_cache ) { + sjpeg->frame_cache = (void *)lv_mem_alloc(sjpeg->sjpeg_x_res * sjpeg->sjpeg_single_frame_height * 3); + if(! sjpeg->frame_cache) { lv_fs_close(&lv_file); lv_sjpg_cleanup(sjpeg); return LV_RES_INV; @@ -668,15 +674,15 @@ static lv_res_t decoder_open( lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * sjpeg->io.img_cache_buff = sjpeg->frame_cache; sjpeg->io.img_cache_x_res = sjpeg->sjpeg_x_res; - sjpeg->workb = lv_mem_alloc( TJPGD_WORKBUFF_SIZE ); - if( ! sjpeg->workb ) { + sjpeg->workb = lv_mem_alloc(TJPGD_WORKBUFF_SIZE); + if(! sjpeg->workb) { lv_fs_close(&lv_file); lv_sjpg_cleanup(sjpeg); return LV_RES_INV; } - sjpeg->tjpeg_jd = lv_mem_alloc( sizeof( JDEC ) ); - if( ! sjpeg->tjpeg_jd ) { + sjpeg->tjpeg_jd = lv_mem_alloc(sizeof(JDEC)); + if(! sjpeg->tjpeg_jd) { lv_fs_close(&lv_file); lv_sjpg_cleanup(sjpeg); return LV_RES_INV; @@ -687,7 +693,8 @@ static lv_res_t decoder_open( lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc->img_data = NULL; return LV_RES_OK; - } else { + } + else { if(dsc->user_data) lv_mem_free(dsc->user_data); lv_fs_close(&lv_file); return LV_RES_INV; @@ -710,11 +717,12 @@ static lv_res_t decoder_open( lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * * @return LV_RES_OK: ok; LV_RES_INV: failed */ -static lv_res_t decoder_read_line( lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t * buf ) +static lv_res_t decoder_read_line(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc, lv_coord_t x, lv_coord_t y, + lv_coord_t len, uint8_t * buf) { LV_UNUSED(decoder); if(dsc->src_type == LV_IMG_SRC_VARIABLE) { - SJPEG* sjpeg = ( SJPEG* ) dsc->user_data; + SJPEG * sjpeg = (SJPEG *) dsc->user_data; JRESULT rc; int sjpeg_req_frame_index = y / sjpeg->sjpeg_single_frame_height; @@ -722,27 +730,29 @@ static lv_res_t decoder_read_line( lv_img_decoder_t * decoder, lv_img_decoder_ds /*If line not from cache, refresh cache */ if(sjpeg_req_frame_index != sjpeg->sjpeg_cache_frame_index) { sjpeg->io.raw_sjpg_data = sjpeg->frame_base_array[ sjpeg_req_frame_index ]; - if (sjpeg_req_frame_index == (sjpeg->sjpeg_total_frames - 1)) { + if(sjpeg_req_frame_index == (sjpeg->sjpeg_total_frames - 1)) { /*This is the last frame. */ const uint32_t frame_offset = (uint32_t)(sjpeg->io.raw_sjpg_data - sjpeg->sjpeg_data); sjpeg->io.raw_sjpg_data_size = sjpeg->sjpeg_data_size - frame_offset; - } else { + } + else { sjpeg->io.raw_sjpg_data_size = - (uint32_t)(sjpeg->frame_base_array[sjpeg_req_frame_index + 1] - sjpeg->io.raw_sjpg_data); + (uint32_t)(sjpeg->frame_base_array[sjpeg_req_frame_index + 1] - sjpeg->io.raw_sjpg_data); } sjpeg->io.raw_sjpg_data_next_read_pos = 0; - rc = jd_prepare( sjpeg->tjpeg_jd, input_func, sjpeg->workb, (size_t)TJPGD_WORKBUFF_SIZE, &(sjpeg->io)); - if(rc != JDR_OK ) return LV_RES_INV; - rc = jd_decomp ( sjpeg->tjpeg_jd, img_data_cb, 0); - if(rc != JDR_OK ) return LV_RES_INV; + rc = jd_prepare(sjpeg->tjpeg_jd, input_func, sjpeg->workb, (size_t)TJPGD_WORKBUFF_SIZE, &(sjpeg->io)); + if(rc != JDR_OK) return LV_RES_INV; + rc = jd_decomp(sjpeg->tjpeg_jd, img_data_cb, 0); + if(rc != JDR_OK) return LV_RES_INV; sjpeg->sjpeg_cache_frame_index = sjpeg_req_frame_index; } int offset = 0; - uint8_t *cache = (uint8_t *)sjpeg->frame_cache + x*3 + ( y % sjpeg->sjpeg_single_frame_height ) * sjpeg->sjpeg_x_res*3; + uint8_t * cache = (uint8_t *)sjpeg->frame_cache + x * 3 + (y % sjpeg->sjpeg_single_frame_height) * sjpeg->sjpeg_x_res * + 3; #if LV_COLOR_DEPTH == 32 - for( int i = 0; i < len; i++ ) { + for(int i = 0; i < len; i++) { buf[offset + 3] = 0xff; buf[offset + 2] = *cache++; buf[offset + 1] = *cache++; @@ -752,7 +762,7 @@ static lv_res_t decoder_read_line( lv_img_decoder_t * decoder, lv_img_decoder_ds #elif LV_COLOR_DEPTH == 16 - for( int i = 0; i < len; i++ ) { + for(int i = 0; i < len; i++) { uint16_t col_16bit = (*cache++ & 0xf8) << 8; col_16bit |= (*cache++ & 0xFC) << 3; col_16bit |= (*cache++ >> 3); @@ -767,7 +777,7 @@ static lv_res_t decoder_read_line( lv_img_decoder_t * decoder, lv_img_decoder_ds #elif LV_COLOR_DEPTH == 8 - for( int i = 0; i < len; i++ ) { + for(int i = 0; i < len; i++) { uint8_t col_8bit = (*cache++ & 0xC0); col_8bit |= (*cache++ & 0xe0) >> 2; col_8bit |= (*cache++ & 0xe0) >> 5; @@ -781,32 +791,33 @@ static lv_res_t decoder_read_line( lv_img_decoder_t * decoder, lv_img_decoder_ds return LV_RES_OK; } else if(dsc->src_type == LV_IMG_SRC_FILE) { - SJPEG* sjpeg = ( SJPEG* ) dsc->user_data; + SJPEG * sjpeg = (SJPEG *) dsc->user_data; JRESULT rc; int sjpeg_req_frame_index = y / sjpeg->sjpeg_single_frame_height; - lv_fs_file_t* lv_file_p = &(sjpeg->io.lv_file); + lv_fs_file_t * lv_file_p = &(sjpeg->io.lv_file); if(!lv_file_p) goto end; /*If line not from cache, refresh cache */ if(sjpeg_req_frame_index != sjpeg->sjpeg_cache_frame_index) { sjpeg->io.raw_sjpg_data_next_read_pos = (int)(sjpeg->frame_base_offset [ sjpeg_req_frame_index ]); - lv_fs_seek( &(sjpeg->io.lv_file), sjpeg->io.raw_sjpg_data_next_read_pos, LV_FS_SEEK_SET); + lv_fs_seek(&(sjpeg->io.lv_file), sjpeg->io.raw_sjpg_data_next_read_pos, LV_FS_SEEK_SET); - rc = jd_prepare( sjpeg->tjpeg_jd, input_func, sjpeg->workb, (size_t)TJPGD_WORKBUFF_SIZE, &(sjpeg->io)); - if(rc != JDR_OK ) return LV_RES_INV; + rc = jd_prepare(sjpeg->tjpeg_jd, input_func, sjpeg->workb, (size_t)TJPGD_WORKBUFF_SIZE, &(sjpeg->io)); + if(rc != JDR_OK) return LV_RES_INV; - rc = jd_decomp ( sjpeg->tjpeg_jd, img_data_cb, 0); - if(rc != JDR_OK ) return LV_RES_INV; + rc = jd_decomp(sjpeg->tjpeg_jd, img_data_cb, 0); + if(rc != JDR_OK) return LV_RES_INV; sjpeg->sjpeg_cache_frame_index = sjpeg_req_frame_index; } int offset = 0; - uint8_t *cache = (uint8_t *)sjpeg->frame_cache + x*3 + ( y % sjpeg->sjpeg_single_frame_height ) * sjpeg->sjpeg_x_res*3; + uint8_t * cache = (uint8_t *)sjpeg->frame_cache + x * 3 + (y % sjpeg->sjpeg_single_frame_height) * sjpeg->sjpeg_x_res * + 3; #if LV_COLOR_DEPTH == 32 - for( int i = 0; i < len; i++ ) { + for(int i = 0; i < len; i++) { buf[offset + 3] = 0xff; buf[offset + 2] = *cache++; buf[offset + 1] = *cache++; @@ -815,7 +826,7 @@ static lv_res_t decoder_read_line( lv_img_decoder_t * decoder, lv_img_decoder_ds } #elif LV_COLOR_DEPTH == 16 - for( int i = 0; i < len; i++ ) { + for(int i = 0; i < len; i++) { uint16_t col_8bit = (*cache++ & 0xf8) << 8; col_8bit |= (*cache++ & 0xFC) << 3; col_8bit |= (*cache++ >> 3); @@ -830,7 +841,7 @@ static lv_res_t decoder_read_line( lv_img_decoder_t * decoder, lv_img_decoder_ds #elif LV_COLOR_DEPTH == 8 - for( int i = 0; i < len; i++ ) { + for(int i = 0; i < len; i++) { uint8_t col_8bit = (*cache++ & 0xC0); col_8bit |= (*cache++ & 0xe0) >> 2; col_8bit |= (*cache++ & 0xe0) >> 5; @@ -845,7 +856,7 @@ static lv_res_t decoder_read_line( lv_img_decoder_t * decoder, lv_img_decoder_ds return LV_RES_OK; } - end: +end: return LV_RES_INV; } @@ -854,37 +865,37 @@ static lv_res_t decoder_read_line( lv_img_decoder_t * decoder, lv_img_decoder_ds * @param decoder pointer to the decoder where this function belongs * @param dsc pointer to a descriptor which describes this decoding session */ -static void decoder_close( lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc ) +static void decoder_close(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc) { LV_UNUSED(decoder); /*Free all allocated data*/ - SJPEG* sjpeg = ( SJPEG* ) dsc->user_data; + SJPEG * sjpeg = (SJPEG *) dsc->user_data; if(!sjpeg) return; switch(dsc->src_type) { - case LV_IMG_SRC_FILE: - if(sjpeg->io.lv_file.file_d) { - lv_fs_close(&(sjpeg->io.lv_file)); - } - lv_sjpg_cleanup(sjpeg); - break; + case LV_IMG_SRC_FILE: + if(sjpeg->io.lv_file.file_d) { + lv_fs_close(&(sjpeg->io.lv_file)); + } + lv_sjpg_cleanup(sjpeg); + break; - case LV_IMG_SRC_VARIABLE: - lv_sjpg_cleanup(sjpeg); - break; + case LV_IMG_SRC_VARIABLE: + lv_sjpg_cleanup(sjpeg); + break; - default: - ; + default: + ; } } -static int is_jpg( const uint8_t *raw_data ) +static int is_jpg(const uint8_t * raw_data) { const uint8_t jpg_signature[] = {0xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10, 0x4A, 0x46, 0x49, 0x46}; - return memcmp( jpg_signature, raw_data, sizeof( jpg_signature ) ) == 0; + return memcmp(jpg_signature, raw_data, sizeof(jpg_signature)) == 0; } -static void lv_sjpg_free( SJPEG* sjpeg ) +static void lv_sjpg_free(SJPEG * sjpeg) { if(sjpeg->frame_cache) lv_mem_free(sjpeg->frame_cache); if(sjpeg->frame_base_array) lv_mem_free(sjpeg->frame_base_array); @@ -893,12 +904,12 @@ static void lv_sjpg_free( SJPEG* sjpeg ) if(sjpeg->workb) lv_mem_free(sjpeg->workb); } -static void lv_sjpg_cleanup( SJPEG* sjpeg ) +static void lv_sjpg_cleanup(SJPEG * sjpeg) { - if(! sjpeg ) return; + if(! sjpeg) return; - lv_sjpg_free( sjpeg ); - lv_mem_free( sjpeg ); + lv_sjpg_free(sjpeg); + lv_mem_free(sjpeg); } #endif /*LV_USE_SJPG*/ diff --git a/src/extra/widgets/calendar/lv_calendar.c b/src/extra/widgets/calendar/lv_calendar.c index 3ba73ea30..f469eae5c 100644 --- a/src/extra/widgets/calendar/lv_calendar.c +++ b/src/extra/widgets/calendar/lv_calendar.c @@ -388,7 +388,8 @@ static void highlight_update(lv_obj_t * obj) for(i = 0; i < calendar->highlighted_dates_num; i++) { if(calendar->highlighted_dates[i].year == calendar->showed_date.year && calendar->highlighted_dates[i].month == calendar->showed_date.month) { - lv_btnmatrix_set_btn_ctrl(calendar->btnm, calendar->highlighted_dates[i].day - 1 + day_first + 7, LV_CALENDAR_CTRL_HIGHLIGHT); + lv_btnmatrix_set_btn_ctrl(calendar->btnm, calendar->highlighted_dates[i].day - 1 + day_first + 7, + LV_CALENDAR_CTRL_HIGHLIGHT); } } } diff --git a/src/extra/widgets/imgbtn/lv_imgbtn.c b/src/extra/widgets/imgbtn/lv_imgbtn.c index 964801f7c..2b6c0c5f1 100644 --- a/src/extra/widgets/imgbtn/lv_imgbtn.c +++ b/src/extra/widgets/imgbtn/lv_imgbtn.c @@ -92,19 +92,20 @@ void lv_imgbtn_set_src(lv_obj_t * obj, lv_imgbtn_state_t state, const void * src void lv_imgbtn_set_state(lv_obj_t * obj, lv_imgbtn_state_t state) { - LV_ASSERT_OBJ(obj, MY_CLASS); + LV_ASSERT_OBJ(obj, MY_CLASS); - lv_state_t obj_state = LV_STATE_DEFAULT; - if(state == LV_IMGBTN_STATE_PRESSED || state == LV_IMGBTN_STATE_CHECKED_PRESSED) obj_state |= LV_STATE_PRESSED; - if(state == LV_IMGBTN_STATE_DISABLED || state == LV_IMGBTN_STATE_CHECKED_DISABLED) obj_state |= LV_STATE_DISABLED; - if(state == LV_IMGBTN_STATE_CHECKED_DISABLED || state == LV_IMGBTN_STATE_CHECKED_PRESSED || state == LV_IMGBTN_STATE_CHECKED_RELEASED) { - obj_state |= LV_STATE_CHECKED; - } + lv_state_t obj_state = LV_STATE_DEFAULT; + if(state == LV_IMGBTN_STATE_PRESSED || state == LV_IMGBTN_STATE_CHECKED_PRESSED) obj_state |= LV_STATE_PRESSED; + if(state == LV_IMGBTN_STATE_DISABLED || state == LV_IMGBTN_STATE_CHECKED_DISABLED) obj_state |= LV_STATE_DISABLED; + if(state == LV_IMGBTN_STATE_CHECKED_DISABLED || state == LV_IMGBTN_STATE_CHECKED_PRESSED || + state == LV_IMGBTN_STATE_CHECKED_RELEASED) { + obj_state |= LV_STATE_CHECKED; + } - lv_obj_clear_state(obj, LV_STATE_CHECKED | LV_STATE_PRESSED | LV_STATE_DISABLED); - lv_obj_add_state(obj, obj_state); + lv_obj_clear_state(obj, LV_STATE_CHECKED | LV_STATE_PRESSED | LV_STATE_DISABLED); + lv_obj_add_state(obj, obj_state); - refr_img(obj); + refr_img(obj); } /*===================== diff --git a/src/extra/widgets/keyboard/lv_keyboard.c b/src/extra/widgets/keyboard/lv_keyboard.c index 09cb0c875..7b27e6883 100644 --- a/src/extra/widgets/keyboard/lv_keyboard.c +++ b/src/extra/widgets/keyboard/lv_keyboard.c @@ -197,7 +197,7 @@ void lv_keyboard_set_popovers(lv_obj_t * obj, bool en) { lv_keyboard_t * keyboard = (lv_keyboard_t *)obj; - if (keyboard->popovers == en) { + if(keyboard->popovers == en) { return; } @@ -406,10 +406,11 @@ static void lv_keyboard_update_ctrl_map(lv_obj_t * obj) { lv_keyboard_t * keyboard = (lv_keyboard_t *)obj; - if (keyboard->popovers) { + if(keyboard->popovers) { /*Apply the current control map (already includes LV_BTNMATRIX_CTRL_POPOVER flags)*/ lv_btnmatrix_set_ctrl_map(obj, kb_ctrl[keyboard->mode]); - } else { + } + else { /*Make a copy of the current control map*/ lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj; lv_btnmatrix_ctrl_t * ctrl_map = lv_mem_alloc(btnm->btn_cnt * sizeof(lv_btnmatrix_ctrl_t)); diff --git a/src/extra/widgets/msgbox/lv_msgbox.c b/src/extra/widgets/msgbox/lv_msgbox.c index d8a6817e2..a62c9ae63 100644 --- a/src/extra/widgets/msgbox/lv_msgbox.c +++ b/src/extra/widgets/msgbox/lv_msgbox.c @@ -30,24 +30,24 @@ static void msgbox_close_click_event_cb(lv_event_t * e); * STATIC VARIABLES **********************/ const lv_obj_class_t lv_msgbox_class = { - .base_class = &lv_obj_class, - .width_def = LV_DPI_DEF * 2, - .height_def = LV_SIZE_CONTENT, - .instance_size = sizeof(lv_msgbox_t) + .base_class = &lv_obj_class, + .width_def = LV_DPI_DEF * 2, + .height_def = LV_SIZE_CONTENT, + .instance_size = sizeof(lv_msgbox_t) }; const lv_obj_class_t lv_msgbox_content_class = { - .base_class = &lv_obj_class, - .width_def = LV_PCT(100), - .height_def = LV_SIZE_CONTENT, - .instance_size = sizeof(lv_obj_t) + .base_class = &lv_obj_class, + .width_def = LV_PCT(100), + .height_def = LV_SIZE_CONTENT, + .instance_size = sizeof(lv_obj_t) }; const lv_obj_class_t lv_msgbox_backdrop_class = { - .base_class = &lv_obj_class, - .width_def = LV_PCT(100), - .height_def = LV_PCT(100), - .instance_size = sizeof(lv_obj_t) + .base_class = &lv_obj_class, + .width_def = LV_PCT(100), + .height_def = LV_PCT(100), + .instance_size = sizeof(lv_obj_t) }; /********************** @@ -85,7 +85,7 @@ lv_obj_t * lv_msgbox_create(lv_obj_t * parent, const char * title, const char * bool has_title = title && strlen(title) > 0; /*When a close button is required, we need the empty label as spacer to push the button to the right*/ - if (add_close_btn || has_title) { + if(add_close_btn || has_title) { mbox->title = lv_label_create(obj); lv_label_set_text(mbox->title, has_title ? title : ""); lv_label_set_long_mode(mbox->title, LV_LABEL_LONG_SCROLL_CIRCULAR); @@ -108,7 +108,7 @@ lv_obj_t * lv_msgbox_create(lv_obj_t * parent, const char * title, const char * mbox->content = lv_obj_class_create_obj(&lv_msgbox_content_class, obj); bool has_txt = txt && strlen(txt) > 0; - if (has_txt) { + if(has_txt) { mbox->text = lv_label_create(mbox->content); lv_label_set_text(mbox->text, txt); lv_label_set_long_mode(mbox->text, LV_LABEL_LONG_WRAP); diff --git a/src/extra/widgets/spinbox/lv_spinbox.c b/src/extra/widgets/spinbox/lv_spinbox.c index 97d00404e..c7d7b19fd 100644 --- a/src/extra/widgets/spinbox/lv_spinbox.c +++ b/src/extra/widgets/spinbox/lv_spinbox.c @@ -175,7 +175,7 @@ void lv_spinbox_set_pos(lv_obj_t * obj, uint8_t pos) * @param spinbox pointer to spinbox * @param direction the direction (LV_DIR_RIGHT or LV_DIR_LEFT) */ -void lv_spinbox_set_digit_step_direction(lv_obj_t *obj, lv_dir_t direction) +void lv_spinbox_set_digit_step_direction(lv_obj_t * obj, lv_dir_t direction) { LV_ASSERT_OBJ(obj, MY_CLASS); lv_spinbox_t * spinbox = (lv_spinbox_t *)obj; @@ -360,10 +360,10 @@ static void lv_spinbox_event(const lv_obj_class_t * class_p, lv_event_t * e) lv_indev_t * indev = lv_indev_get_act(); if(lv_indev_get_type(indev) == LV_INDEV_TYPE_ENCODER) { if(lv_group_get_editing(lv_obj_get_group(obj))) { - if (spinbox->digit_count > 1) { - if (spinbox->digit_step_dir == LV_DIR_RIGHT) { + if(spinbox->digit_count > 1) { + if(spinbox->digit_step_dir == LV_DIR_RIGHT) { if(spinbox->step > 1) { - lv_spinbox_step_next(obj); + lv_spinbox_step_next(obj); } else { /*Restart from the MSB*/ diff --git a/src/extra/widgets/spinbox/lv_spinbox.h b/src/extra/widgets/spinbox/lv_spinbox.h index 71856c917..dfcba8940 100644 --- a/src/extra/widgets/spinbox/lv_spinbox.h +++ b/src/extra/widgets/spinbox/lv_spinbox.h @@ -122,7 +122,7 @@ void lv_spinbox_set_digit_step_direction(lv_obj_t * obj, lv_dir_t direction); * Get spinbox rollover function status * @param spinbox pointer to spinbox */ -bool lv_spinbox_get_rollover(lv_obj_t *obj); +bool lv_spinbox_get_rollover(lv_obj_t * obj); /** * Get the spinbox numeral value (user has to convert to float according to its digit format) diff --git a/src/font/lv_font.c b/src/font/lv_font.c index 72a4188c4..0e7a2fe74 100644 --- a/src/font/lv_font.c +++ b/src/font/lv_font.c @@ -71,7 +71,7 @@ bool lv_font_get_glyph_dsc(const lv_font_t * font_p, lv_font_glyph_dsc_t * dsc_o bool found = false; while(f) { found = f->get_glyph_dsc(f, dsc_out, letter, letter_next); - if (found && !dsc_out->is_placeholder) { + if(found && !dsc_out->is_placeholder) { dsc_out->resolved_font = f; break; } diff --git a/src/font/lv_font.h b/src/font/lv_font.h index 5ed204baf..3d716dd46 100644 --- a/src/font/lv_font.h +++ b/src/font/lv_font.h @@ -36,14 +36,15 @@ extern "C" { struct _lv_font_t; /** Describes the properties of a glyph.*/ typedef struct { - const struct _lv_font_t *resolved_font; /**< Pointer to a font where the gylph was actually found after handling fallbacks*/ + const struct _lv_font_t * + resolved_font; /**< Pointer to a font where the gylph was actually found after handling fallbacks*/ uint16_t adv_w; /**< The glyph needs this space. Draw the next glyph after this width.*/ uint16_t box_w; /**< Width of the glyph's bounding box*/ uint16_t box_h; /**< Height of the glyph's bounding box*/ int16_t ofs_x; /**< x offset of the bounding box*/ int16_t ofs_y; /**< y offset of the bounding box*/ - uint8_t bpp:4; /**< Bit-per-pixel: 1, 2, 4, 8*/ - uint8_t is_placeholder:1; /** Glyph is missing. But placeholder will still be displayed */ + uint8_t bpp: 4; /**< Bit-per-pixel: 1, 2, 4, 8*/ + uint8_t is_placeholder: 1; /** Glyph is missing. But placeholder will still be displayed */ } lv_font_glyph_dsc_t; /** The bitmaps might be upscaled by 3 to achieve subpixel rendering.*/ diff --git a/src/gpu/lv_gpu_sdl.h b/src/gpu/lv_gpu_sdl.h index d5c22b3fc..2cc34aa58 100644 --- a/src/gpu/lv_gpu_sdl.h +++ b/src/gpu/lv_gpu_sdl.h @@ -40,7 +40,7 @@ void lv_gpu_sdl_init(); /** * @brief Free caches - * + * */ void lv_gpu_sdl_deinit(); diff --git a/src/gpu/sdl/lv_gpu_sdl_draw_label.c b/src/gpu/sdl/lv_gpu_sdl_draw_label.c index 30d5cff94..c64ef6856 100644 --- a/src/gpu/sdl/lv_gpu_sdl_draw_label.c +++ b/src/gpu/sdl/lv_gpu_sdl_draw_label.c @@ -102,13 +102,13 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * clip_area, lv_font_glyph_key_t glyph_key = font_key_glyph_create(font_p, letter); bool glyph_found = false; - SDL_Texture *texture = lv_gpu_draw_cache_get(&glyph_key, sizeof(glyph_key), &glyph_found); - if (!glyph_found) { - if (g.resolved_font) { + SDL_Texture * texture = lv_gpu_draw_cache_get(&glyph_key, sizeof(glyph_key), &glyph_found); + if(!glyph_found) { + if(g.resolved_font) { font_p = g.resolved_font; } - const uint8_t *bmp = lv_font_get_glyph_bitmap(font_p, letter); - uint8_t *buf = lv_mem_alloc(g.box_w * g.box_h); + const uint8_t * bmp = lv_font_get_glyph_bitmap(font_p, letter); + uint8_t * buf = lv_mem_alloc(g.box_w * g.box_h); lv_sdl_to_8bpp(buf, bmp, g.box_w, g.box_h, g.box_w, g.bpp); SDL_Surface * mask = lv_sdl_create_mask_surface(buf, g.box_w, g.box_h, g.box_w); texture = SDL_CreateTextureFromSurface(renderer, mask); @@ -116,7 +116,7 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * clip_area, lv_mem_free(buf); lv_gpu_draw_cache_put(&glyph_key, sizeof(glyph_key), texture); } - if (!texture) { + if(!texture) { return; } lv_area_t dst = {pos_x, pos_y, pos_x + g.box_w - 1, pos_y + g.box_h - 1}; diff --git a/src/gpu/sdl/lv_gpu_sdl_lru.c b/src/gpu/sdl/lv_gpu_sdl_lru.c index 5e67e8a17..deefb949c 100644 --- a/src/gpu/sdl/lv_gpu_sdl_lru.c +++ b/src/gpu/sdl/lv_gpu_sdl_lru.c @@ -294,7 +294,7 @@ static uint32_t lv_lru_hash(lv_lru_t * cache, const void * key, uint32_t key_len case 1: h ^= data[0]; h *= m; - break; + break; }; h ^= h >> 13; diff --git a/src/hal/lv_hal_disp.c b/src/hal/lv_hal_disp.c index 036ed2261..4bbf20adf 100644 --- a/src/hal/lv_hal_disp.c +++ b/src/hal/lv_hal_disp.c @@ -157,7 +157,8 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver) if(lv_theme_default_is_inited() == false) { disp->theme = lv_theme_default_init(disp, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED), LV_THEME_DEFAULT_DARK, LV_FONT_DEFAULT); - } else { + } + else { disp->theme = lv_theme_default_get(); } #endif diff --git a/src/hal/lv_hal_disp.h b/src/hal/lv_hal_disp.h index 3626a34ef..76679b1fc 100644 --- a/src/hal/lv_hal_disp.h +++ b/src/hal/lv_hal_disp.h @@ -80,9 +80,12 @@ typedef struct _lv_disp_drv_t { lv_coord_t hor_res; /**< Horizontal resolution.*/ lv_coord_t ver_res; /**< Vertical resolution.*/ - lv_coord_t physical_hor_res; /**< Horizontal resolution of the full / physical display. Set to -1 for fullscreen mode.*/ - lv_coord_t physical_ver_res; /**< Vertical resolution of the full / physical display. Set to -1 for fullscreen mode.*/ - lv_coord_t offset_x; /**< Horizontal offset from the full / physical display. Set to 0 for fullscreen mode.*/ + lv_coord_t + physical_hor_res; /**< Horizontal resolution of the full / physical display. Set to -1 for fullscreen mode.*/ + lv_coord_t + physical_ver_res; /**< Vertical resolution of the full / physical display. Set to -1 for fullscreen mode.*/ + lv_coord_t + offset_x; /**< Horizontal offset from the full / physical display. Set to 0 for fullscreen mode.*/ lv_coord_t offset_y; /**< Vertical offset from the full / physical display. Set to 0 for fullscreen mode.*/ /** Pointer to a buffer initialized with `lv_disp_draw_buf_init()`. @@ -173,7 +176,7 @@ uint8_t del_prev : lv_opa_t bg_opa; /**anim_dsc_cnt; i++) { uint32_t end = lv_anim_get_playtime(&at->anim_dsc[i].anim); - if (end == LV_ANIM_PLAYTIME_INFINITE) + if(end == LV_ANIM_PLAYTIME_INFINITE) return end; end += at->anim_dsc[i].start_time; if(end > playtime) { diff --git a/src/misc/lv_bidi.c b/src/misc/lv_bidi.c index 3b084d3d7..b207f9d9e 100644 --- a/src/misc/lv_bidi.c +++ b/src/misc/lv_bidi.c @@ -440,13 +440,13 @@ static lv_base_dir_t get_next_run(const char * txt, lv_base_dir_t base_dir, uint /*Find the first strong char. Skip the neutrals*/ while(dir == LV_BASE_DIR_NEUTRAL || dir == LV_BASE_DIR_WEAK) { letter = _lv_txt_encoded_next(txt, &i); - + pos_conv_i++; dir = lv_bidi_get_letter_dir(letter); if(dir == LV_BASE_DIR_NEUTRAL) dir = bracket_process(txt, i, max_len, letter, base_dir); - - if(dir==LV_BASE_DIR_LTR || dir==LV_BASE_DIR_RTL) break; - + + if(dir == LV_BASE_DIR_LTR || dir == LV_BASE_DIR_RTL) break; + if(i >= max_len || txt[i] == '\0' || txt[i] == '\n' || txt[i] == '\r') { *len = i; *pos_conv_len = pos_conv_i; @@ -468,14 +468,14 @@ static lv_base_dir_t get_next_run(const char * txt, lv_base_dir_t base_dir, uint pos_conv_i++; next_dir = lv_bidi_get_letter_dir(letter); if(next_dir == LV_BASE_DIR_NEUTRAL) next_dir = bracket_process(txt, i, max_len, letter, base_dir); - - if(next_dir == LV_BASE_DIR_WEAK){ - if(run_dir == LV_BASE_DIR_RTL){ - if(base_dir == LV_BASE_DIR_RTL){ - next_dir = LV_BASE_DIR_LTR; - } - } - } + + if(next_dir == LV_BASE_DIR_WEAK) { + if(run_dir == LV_BASE_DIR_RTL) { + if(base_dir == LV_BASE_DIR_RTL) { + next_dir = LV_BASE_DIR_LTR; + } + } + } /*New dir found?*/ if((next_dir == LV_BASE_DIR_RTL || next_dir == LV_BASE_DIR_LTR) && next_dir != run_dir) { diff --git a/src/misc/lv_log.c b/src/misc/lv_log.c index 777849f9b..cc62c84b9 100644 --- a/src/misc/lv_log.c +++ b/src/misc/lv_log.c @@ -91,7 +91,7 @@ void _lv_log_add(lv_log_level_t level, const char * file, int line, const char * vprintf(format, args); printf(" \t(in %s line #%d)\n", &file[p], line); #else - if (custom_print_cb) { + if(custom_print_cb) { char buf[512]; #if LV_SPRINTF_CUSTOM char msg[256]; diff --git a/src/misc/lv_printf.c b/src/misc/lv_printf.c index ebe8a55c0..9077a7a11 100644 --- a/src/misc/lv_printf.c +++ b/src/misc/lv_printf.c @@ -749,7 +749,7 @@ static int _vsnprintf(out_fct_type out, char * buffer, const size_t maxlen, cons width, flags); } } - else if (*format == 'V') { + else if(*format == 'V') { lv_vaformat_t * vaf = va_arg(va, lv_vaformat_t *); va_list copy; diff --git a/src/misc/lv_printf.h b/src/misc/lv_printf.h index 304c5b9cc..4cbbd84c0 100644 --- a/src/misc/lv_printf.h +++ b/src/misc/lv_printf.h @@ -35,19 +35,19 @@ #define _LV_PRINTF_H_ #if defined(__has_include) -# if __has_include() -# include - /* platform-specific printf format for int32_t, usually "d" or "ld" */ -# define LV_PRId32 PRId32 -# define LV_PRIu32 PRIu32 -# else -# define LV_PRId32 "d" -# define LV_PRIu32 "u" -# endif + #if __has_include() + #include + /* platform-specific printf format for int32_t, usually "d" or "ld" */ + #define LV_PRId32 PRId32 + #define LV_PRIu32 PRIu32 + #else + #define LV_PRId32 "d" + #define LV_PRIu32 "u" + #endif #else - /* hope this is correct for ports without __has_include or without inttypes.h */ -# define LV_PRId32 "d" -# define LV_PRIu32 "u" + /* hope this is correct for ports without __has_include or without inttypes.h */ + #define LV_PRId32 "d" + #define LV_PRIu32 "u" #endif #ifdef __cplusplus @@ -64,8 +64,8 @@ extern "C" { #include "lv_types.h" typedef struct { - const char * fmt; - va_list * va; + const char * fmt; + va_list * va; } lv_vaformat_t; /** diff --git a/src/misc/lv_types.h b/src/misc/lv_types.h index 172f21c43..9f8ef4ca6 100644 --- a/src/misc/lv_types.h +++ b/src/misc/lv_types.h @@ -88,7 +88,7 @@ typedef uint32_t lv_uintptr_t; #endif #ifdef __cplusplus -} /*extern "C"*/ +} /*extern "C"*/ #endif #endif /*LV_TYPES_H*/ diff --git a/src/widgets/lv_arc.c b/src/widgets/lv_arc.c index 08cfe03f5..e7fd037b5 100644 --- a/src/widgets/lv_arc.c +++ b/src/widgets/lv_arc.c @@ -384,7 +384,8 @@ static void lv_arc_event(const lv_obj_class_t * class_p, lv_event_t * e) if(lv_obj_has_flag(obj, LV_OBJ_FLAG_ADV_HITTEST)) { r -= indic_width; - } else { + } + else { r -= LV_MAX(r / 4, indic_width); } if(r < 1) r = 1; @@ -515,7 +516,7 @@ static void lv_arc_event(const lv_obj_class_t * class_p, lv_event_t * e) lv_area_set(&a, p.x - r, p.y - r, p.x + r, p.y + r); if(_lv_area_is_point_on(&a, info->point, LV_RADIUS_CIRCLE)) { info->res = false; - return; + return; } /*Valid if no clicked outside*/ diff --git a/src/widgets/lv_btnmatrix.c b/src/widgets/lv_btnmatrix.c index 0108a8ec5..05adfde3d 100644 --- a/src/widgets/lv_btnmatrix.c +++ b/src/widgets/lv_btnmatrix.c @@ -219,7 +219,7 @@ void lv_btnmatrix_set_btn_ctrl(lv_obj_t * obj, uint16_t btn_id, lv_btnmatrix_ctr btnm->ctrl_bits[btn_id] |= ctrl; invalidate_button_area(obj, btn_id); - if (ctrl & LV_BTNMATRIX_CTRL_POPOVER) { + if(ctrl & LV_BTNMATRIX_CTRL_POPOVER) { lv_obj_refresh_ext_draw_size(obj); } } @@ -235,7 +235,7 @@ void lv_btnmatrix_clear_btn_ctrl(lv_obj_t * obj, uint16_t btn_id, lv_btnmatrix_c btnm->ctrl_bits[btn_id] &= (~ctrl); invalidate_button_area(obj, btn_id); - if (ctrl & LV_BTNMATRIX_CTRL_POPOVER) { + if(ctrl & LV_BTNMATRIX_CTRL_POPOVER) { lv_obj_refresh_ext_draw_size(obj); } } @@ -400,10 +400,11 @@ static void lv_btnmatrix_event(const lv_obj_class_t * class_p, lv_event_t * e) if(code == LV_EVENT_REFR_EXT_DRAW_SIZE) { lv_coord_t * s = lv_event_get_param(e); - if (has_popovers_in_top_row(obj)) { + if(has_popovers_in_top_row(obj)) { /*reserve one row worth of extra space to account for popovers in the top row*/ *s = btnm->row_cnt > 0 ? lv_obj_get_content_height(obj) / btnm->row_cnt : 0; - } else { + } + else { *s = 0; } } @@ -765,7 +766,7 @@ static void draw_main(lv_event_t * e) lv_coord_t btn_height = lv_area_get_height(&btn_area); - if ((btn_state & LV_STATE_PRESSED) && (btnm->ctrl_bits[btn_i] & LV_BTNMATRIX_CTRL_POPOVER)) { + if((btn_state & LV_STATE_PRESSED) && (btnm->ctrl_bits[btn_i] & LV_BTNMATRIX_CTRL_POPOVER)) { /*Push up the upper boundary of the btn area to create the popover*/ btn_area.y1 -= btn_height; } @@ -796,7 +797,7 @@ static void draw_main(lv_event_t * e) btn_area.x2 = btn_area.x1 + txt_size.x; btn_area.y2 = btn_area.y1 + txt_size.y; - if ((btn_state & LV_STATE_PRESSED) && (btnm->ctrl_bits[btn_i] & LV_BTNMATRIX_CTRL_POPOVER)) { + if((btn_state & LV_STATE_PRESSED) && (btnm->ctrl_bits[btn_i] & LV_BTNMATRIX_CTRL_POPOVER)) { /*Push up the button text into the popover*/ btn_area.y1 -= btn_height / 2; btn_area.y2 -= btn_height / 2; @@ -828,7 +829,8 @@ static void allocate_btn_areas_and_controls(const lv_obj_t * obj, const char ** while(map[i] && map[i][0] != '\0') { if(strcmp(map[i], "\n") != 0) { /*Do not count line breaks*/ btn_cnt++; - } else { + } + else { btnm->row_cnt++; } i++; @@ -998,7 +1000,7 @@ static void invalidate_button_area(const lv_obj_t * obj, uint16_t btn_idx) btn_area.x2 += obj_area.x1 + row_gap; btn_area.y2 += obj_area.y1 + col_gap; - if ((btn_idx == btnm->btn_id_sel) && (btnm->ctrl_bits[btn_idx] & LV_BTNMATRIX_CTRL_POPOVER)) { + if((btn_idx == btnm->btn_id_sel) && (btnm->ctrl_bits[btn_idx] & LV_BTNMATRIX_CTRL_POPOVER)) { /*Push up the upper boundary of the btn area to also invalidate the popover*/ btn_area.y1 -= lv_area_get_height(&btn_area); } @@ -1031,15 +1033,15 @@ static bool has_popovers_in_top_row(lv_obj_t * obj) { lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj; - if (btnm->row_cnt <= 0) { + if(btnm->row_cnt <= 0) { return false; } const char ** map_row = btnm->map_p; uint16_t btn_cnt = 0; - while (map_row[btn_cnt] && strcmp(map_row[btn_cnt], "\n") != 0 && map_row[btn_cnt][0] != '\0') { - if (button_is_popover(btnm->ctrl_bits[btn_cnt])) { + while(map_row[btn_cnt] && strcmp(map_row[btn_cnt], "\n") != 0 && map_row[btn_cnt][0] != '\0') { + if(button_is_popover(btnm->ctrl_bits[btn_cnt])) { return true; } btn_cnt++; diff --git a/src/widgets/lv_label.c b/src/widgets/lv_label.c index 39161fb88..452aa4da6 100644 --- a/src/widgets/lv_label.c +++ b/src/widgets/lv_label.c @@ -852,7 +852,8 @@ static void draw_main(lv_event_t * e) if(label->long_mode == LV_LABEL_LONG_SCROLL || label->long_mode == LV_LABEL_LONG_SCROLL_CIRCULAR) { lv_draw_label(&txt_coords, &txt_clip, &label_draw_dsc, label->text, hint); - } else { + } + else { lv_draw_label(&txt_coords, clip_area, &label_draw_dsc, label->text, hint); } @@ -1123,7 +1124,7 @@ static void lv_label_refr_text(lv_obj_t * obj) for(i = 0; i <= LV_LABEL_DOT_NUM; i++) { len += _lv_txt_encoded_size(&label->text[byte_id]); _lv_txt_encoded_next(label->text, &byte_id); - if (len > LV_LABEL_DOT_NUM || byte_id > txt_len) { + if(len > LV_LABEL_DOT_NUM || byte_id > txt_len) { break; } }