diff --git a/lvgl.h b/lvgl.h index 7b6591904..63c6211fd 100644 --- a/lvgl.h +++ b/lvgl.h @@ -25,15 +25,16 @@ extern "C" { #include "src/misc/lv_log.h" #include "src/misc/lv_timer.h" #include "src/misc/lv_math.h" +#include "src/misc/lv_mem.h" #include "src/misc/lv_async.h" #include "src/misc/lv_anim_timeline.h" +#include "src/misc/lv_printf.h" #include "src/hal/lv_hal.h" #include "src/core/lv_obj.h" #include "src/core/lv_group.h" #include "src/core/lv_indev.h" - #include "src/core/lv_refr.h" #include "src/core/lv_disp.h" #include "src/core/lv_theme.h" @@ -41,7 +42,6 @@ extern "C" { #include "src/font/lv_font.h" #include "src/font/lv_font_loader.h" #include "src/font/lv_font_fmt_txt.h" -#include "src/misc/lv_printf.h" #include "src/widgets/lv_arc.h" #include "src/widgets/lv_btn.h" diff --git a/src/misc/lv_anim.c b/src/misc/lv_anim.c index e6b43b130..ecb95840d 100644 --- a/src/misc/lv_anim.c +++ b/src/misc/lv_anim.c @@ -8,10 +8,8 @@ *********************/ #include "lv_anim.h" -#include -#include -#include "../misc/lv_assert.h" #include "../hal/lv_hal_tick.h" +#include "lv_assert.h" #include "lv_timer.h" #include "lv_math.h" #include "lv_mem.h" @@ -67,9 +65,9 @@ void _lv_anim_core_init(void) void lv_anim_init(lv_anim_t * a) { lv_memset_00(a, sizeof(lv_anim_t)); - a->time = 500; - a->start_value = 0; - a->end_value = 100; + a->time = 500; + a->start_value = 0; + a->end_value = 100; a->repeat_cnt = 1; a->path_cb = lv_anim_path_linear; a->early_apply = 1; @@ -100,7 +98,7 @@ lv_anim_t * lv_anim_start(const lv_anim_t * a) /*Set the start value*/ if(new_anim->early_apply) { if(new_anim->get_value_cb) { - int32_t v_ofs = new_anim->get_value_cb(new_anim); + int32_t v_ofs = new_anim->get_value_cb(new_anim); new_anim->start_value += v_ofs; new_anim->end_value += v_ofs; } @@ -151,7 +149,7 @@ bool lv_anim_del(void * var, lv_anim_exec_xcb_t exec_cb) _lv_ll_remove(&LV_GC_ROOT(_lv_anim_ll), a); lv_mem_free(a); anim_mark_list_change(); /*Read by `anim_timer`. It need to know if a delete occurred in - the linked list*/ + the linked list*/ del = true; } @@ -345,7 +343,7 @@ int32_t lv_anim_path_step(const lv_anim_t * a) */ static void anim_timer(lv_timer_t * param) { - (void)param; + LV_UNUSED(param); uint32_t elaps = lv_tick_elaps(last_timer_run); @@ -368,7 +366,7 @@ static void anim_timer(lv_timer_t * param) int32_t new_act_time = a->act_time + elaps; if(!a->start_cb_called && a->act_time <= 0 && new_act_time >= 0) { if(a->early_apply == 0 && a->get_value_cb) { - int32_t v_ofs = a->get_value_cb(a); + int32_t v_ofs = a->get_value_cb(a); a->start_value += v_ofs; a->end_value += v_ofs; } @@ -444,8 +442,7 @@ static void anim_ready_handler(lv_anim_t * a) /*Toggle the play back state*/ a->playback_now = a->playback_now == 0 ? 1 : 0; /*Swap the start and end values*/ - int32_t tmp; - tmp = a->start_value; + int32_t tmp = a->start_value; a->start_value = a->end_value; a->end_value = tmp; /*Swap the time and playback_time*/ @@ -455,6 +452,7 @@ static void anim_ready_handler(lv_anim_t * a) } } } + static void anim_mark_list_change(void) { anim_list_changed = true; diff --git a/src/misc/lv_anim.h b/src/misc/lv_anim.h index 2b7307dbf..6f51bf001 100644 --- a/src/misc/lv_anim.h +++ b/src/misc/lv_anim.h @@ -17,7 +17,7 @@ extern "C" { #include #include -#include +#include /********************* * DEFINES @@ -173,7 +173,7 @@ static inline void lv_anim_set_values(lv_anim_t * a, int32_t start, int32_t end) * `lv_anim_t * ` as its first parameter instead of `void *`. * This function might be used when LVGL is bound to other languages because * it's more consistent to have `lv_anim_t *` as first parameter. - * The variable to animate can be stored in the animation's `user_sata` + * The variable to animate can be stored in the animation's `user_data` * @param a pointer to an initialized `lv_anim_t` variable * @param exec_cb a function to execute. */ @@ -223,10 +223,11 @@ static inline void lv_anim_set_ready_cb(lv_anim_t * a, lv_anim_ready_cb_t ready_ { a->ready_cb = ready_cb; } + /** * Make the animation to play back to when the forward direction is ready * @param a pointer to an initialized `lv_anim_t` variable - * @param time the duration of the playback animation in in milliseconds. 0: disable playback + * @param time the duration of the playback animation in milliseconds. 0: disable playback */ static inline void lv_anim_set_playback_time(lv_anim_t * a, uint32_t time) { diff --git a/src/misc/lv_anim_timeline.c b/src/misc/lv_anim_timeline.c index cc7462006..930b6952c 100644 --- a/src/misc/lv_anim_timeline.c +++ b/src/misc/lv_anim_timeline.c @@ -8,7 +8,7 @@ *********************/ #include "lv_anim_timeline.h" #include "lv_mem.h" -#include "../misc/lv_assert.h" +#include "lv_assert.h" /********************* * DEFINES diff --git a/src/misc/lv_area.c b/src/misc/lv_area.c index 4b6a6d65c..08a8f16e1 100644 --- a/src/misc/lv_area.c +++ b/src/misc/lv_area.c @@ -142,6 +142,7 @@ bool _lv_area_intersect(lv_area_t * res_p, const lv_area_t * a1_p, const lv_area return union_ok; } + /** * Join two areas into a third which involves the other two * @param res_p pointer to an area, the result will be stored here diff --git a/src/misc/lv_area.h b/src/misc/lv_area.h index d2cb7437a..e2a70eb4c 100644 --- a/src/misc/lv_area.h +++ b/src/misc/lv_area.h @@ -14,7 +14,6 @@ extern "C" { * INCLUDES *********************/ #include "../lv_conf_internal.h" -#include #include #include diff --git a/src/misc/lv_assert.h b/src/misc/lv_assert.h index 4e74690f1..d1fbb8c5d 100644 --- a/src/misc/lv_assert.h +++ b/src/misc/lv_assert.h @@ -16,6 +16,7 @@ extern "C" { #include "../lv_conf_internal.h" #include "lv_log.h" #include "lv_mem.h" +#include #include LV_ASSERT_HANDLER_INCLUDE /********************* @@ -34,21 +35,21 @@ extern "C" { * MACROS **********************/ -#define LV_ASSERT(expr) \ - do { \ - if(!(expr)) { \ - LV_LOG_ERROR("Asserted at expression: %s", #expr); \ - LV_ASSERT_HANDLER \ - } \ - } while(0) +#define LV_ASSERT(expr) \ + do { \ + if(!(expr)) { \ + LV_LOG_ERROR("Asserted at expression: %s", #expr); \ + LV_ASSERT_HANDLER \ + } \ + } while (0) -#define LV_ASSERT_MSG(expr, msg) \ - do { \ - if(!(expr)) { \ - LV_LOG_ERROR("Asserted at expression: %s (%s)", #expr, msg); \ - LV_ASSERT_HANDLER \ - } \ - } while(0) +#define LV_ASSERT_MSG(expr, msg) \ + do { \ + if(!(expr)) { \ + LV_LOG_ERROR("Asserted at expression: %s (%s)", #expr, msg); \ + LV_ASSERT_HANDLER \ + } \ + } while (0) /*----------------- * ASSERTS diff --git a/src/misc/lv_async.c b/src/misc/lv_async.c index 0a98c30e9..45a043154 100644 --- a/src/misc/lv_async.c +++ b/src/misc/lv_async.c @@ -8,6 +8,8 @@ *********************/ #include "lv_async.h" +#include "lv_mem.h" +#include "lv_timer.h" /********************* * DEFINES @@ -72,6 +74,5 @@ static void lv_async_timer_cb(lv_timer_t * timer) lv_async_info_t * info = (lv_async_info_t *)timer->user_data; info->cb(info->user_data); - lv_mem_free(info); } diff --git a/src/misc/lv_async.h b/src/misc/lv_async.h index fc8dee05b..3e6cb638d 100644 --- a/src/misc/lv_async.h +++ b/src/misc/lv_async.h @@ -14,7 +14,6 @@ extern "C" { * INCLUDES *********************/ -#include "lv_timer.h" #include "lv_types.h" /********************* diff --git a/src/misc/lv_color.c b/src/misc/lv_color.c index 5be799997..0e26624fb 100644 --- a/src/misc/lv_color.c +++ b/src/misc/lv_color.c @@ -36,7 +36,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_color_fill(lv_color_t * buf, lv_color_t color, uint32_t px_num) { #if LV_COLOR_DEPTH == 16 - uintptr_t buf_int = (uintptr_t) buf; + uintptr_t buf_int = (uintptr_t)buf; if(buf_int & 0x3) { *buf = color; buf++; @@ -73,7 +73,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_color_fill(lv_color_t * buf, lv_color_t color, uin while(px_num) { *buf = color; buf++; - px_num --; + px_num--; } #else while(px_num > 16) { @@ -118,7 +118,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_color_fill(lv_color_t * buf, lv_color_t color, uin while(px_num) { *buf = color; buf++; - px_num --; + px_num--; } #endif } @@ -367,5 +367,3 @@ lv_color_t lv_palette_darken(lv_palette_t p, uint8_t lvl) return colors[p][lvl]; } - - diff --git a/src/misc/lv_color.h b/src/misc/lv_color.h index 20e735088..a0178bedb 100644 --- a/src/misc/lv_color.h +++ b/src/misc/lv_color.h @@ -471,11 +471,11 @@ LV_ATTRIBUTE_FAST_MEM static inline lv_color_t lv_color_mix(lv_color_t c1, lv_co ret.full = (uint16_t)((result >> 16) | result); #elif LV_COLOR_DEPTH != 1 /*LV_COLOR_DEPTH == 8, 16 or 32*/ - LV_COLOR_SET_R(ret, LV_UDIV255((uint16_t) LV_COLOR_GET_R(c1) * mix + LV_COLOR_GET_R(c2) * + LV_COLOR_SET_R(ret, LV_UDIV255((uint16_t)LV_COLOR_GET_R(c1) * mix + LV_COLOR_GET_R(c2) * (255 - mix) + LV_COLOR_MIX_ROUND_OFS)); - LV_COLOR_SET_G(ret, LV_UDIV255((uint16_t) LV_COLOR_GET_G(c1) * mix + LV_COLOR_GET_G(c2) * + LV_COLOR_SET_G(ret, LV_UDIV255((uint16_t)LV_COLOR_GET_G(c1) * mix + LV_COLOR_GET_G(c2) * (255 - mix) + LV_COLOR_MIX_ROUND_OFS)); - LV_COLOR_SET_B(ret, LV_UDIV255((uint16_t) LV_COLOR_GET_B(c1) * mix + LV_COLOR_GET_B(c2) * + LV_COLOR_SET_B(ret, LV_UDIV255((uint16_t)LV_COLOR_GET_B(c1) * mix + LV_COLOR_GET_B(c2) * (255 - mix) + LV_COLOR_MIX_ROUND_OFS)); LV_COLOR_SET_A(ret, 0xFF); #else @@ -489,9 +489,9 @@ LV_ATTRIBUTE_FAST_MEM static inline lv_color_t lv_color_mix(lv_color_t c1, lv_co LV_ATTRIBUTE_FAST_MEM static inline void lv_color_premult(lv_color_t c, uint8_t mix, uint16_t * out) { #if LV_COLOR_DEPTH != 1 - out[0] = (uint16_t) LV_COLOR_GET_R(c) * mix; - out[1] = (uint16_t) LV_COLOR_GET_G(c) * mix; - out[2] = (uint16_t) LV_COLOR_GET_B(c) * mix; + out[0] = (uint16_t)LV_COLOR_GET_R(c) * mix; + out[1] = (uint16_t)LV_COLOR_GET_G(c) * mix; + out[2] = (uint16_t)LV_COLOR_GET_B(c) * mix; #else (void) mix; /*Pre-multiplication can't be used with 1 bpp*/ diff --git a/src/misc/lv_fs.c b/src/misc/lv_fs.c index 652889127..8011b4cf4 100644 --- a/src/misc/lv_fs.c +++ b/src/misc/lv_fs.c @@ -8,9 +8,9 @@ *********************/ #include "lv_fs.h" -#include "../misc/lv_assert.h" -#include "lv_ll.h" #include +#include "lv_assert.h" +#include "lv_ll.h" #include "lv_gc.h" /********************* @@ -163,26 +163,22 @@ lv_fs_res_t lv_fs_seek(lv_fs_file_t * file_p, uint32_t pos, lv_fs_whence_t whenc return LV_FS_RES_NOT_IMP; } - lv_fs_res_t res = file_p->drv->seek_cb(file_p->drv, file_p->file_d, pos, whence); - - return res; + return file_p->drv->seek_cb(file_p->drv, file_p->file_d, pos, whence); } lv_fs_res_t lv_fs_tell(lv_fs_file_t * file_p, uint32_t * pos) { + *pos = 0; + if(file_p->drv == NULL) { - *pos = 0; return LV_FS_RES_INV_PARAM; } if(file_p->drv->tell_cb == NULL) { - *pos = 0; return LV_FS_RES_NOT_IMP; } - lv_fs_res_t res = file_p->drv->tell_cb(file_p->drv, file_p->file_d, pos); - - return res; + return file_p->drv->tell_cb(file_p->drv, file_p->file_d, pos); } lv_fs_res_t lv_fs_dir_open(lv_fs_dir_t * rddir_p, const char * path) @@ -221,19 +217,17 @@ lv_fs_res_t lv_fs_dir_open(lv_fs_dir_t * rddir_p, const char * path) lv_fs_res_t lv_fs_dir_read(lv_fs_dir_t * rddir_p, char * fn) { + fn[0] = '\0'; + if(rddir_p->drv == NULL || rddir_p->dir_d == NULL) { - fn[0] = '\0'; return LV_FS_RES_INV_PARAM; } if(rddir_p->drv->dir_read_cb == NULL) { - fn[0] = '\0'; return LV_FS_RES_NOT_IMP; } - lv_fs_res_t res = rddir_p->drv->dir_read_cb(rddir_p->drv, rddir_p->dir_d, fn); - - return res; + return rddir_p->drv->dir_read_cb(rddir_p->drv, rddir_p->dir_d, fn); } lv_fs_res_t lv_fs_dir_close(lv_fs_dir_t * rddir_p) @@ -362,6 +356,7 @@ const char * lv_fs_get_last(const char * path) return &path[i]; } + /********************** * STATIC FUNCTIONS **********************/ diff --git a/src/misc/lv_gc.c b/src/misc/lv_gc.c index ca163fee0..95bb5499a 100644 --- a/src/misc/lv_gc.c +++ b/src/misc/lv_gc.c @@ -6,9 +6,7 @@ /********************* * INCLUDES *********************/ - #include "lv_gc.h" -#include "string.h" /********************* * DEFINES diff --git a/src/misc/lv_gc.h b/src/misc/lv_gc.h index a5f7a19fd..dac62be26 100644 --- a/src/misc/lv_gc.h +++ b/src/misc/lv_gc.h @@ -13,11 +13,12 @@ extern "C" { /********************* * INCLUDES *********************/ +#include "../lv_conf_internal.h" #include -#include #include "lv_mem.h" #include "lv_ll.h" #include "lv_timer.h" +#include "lv_types.h" #include "../draw/lv_img_cache.h" #include "../draw/lv_draw_mask.h" #include "../core/lv_obj_pos.h" @@ -39,23 +40,23 @@ extern "C" { #define LV_DISPATCH10(f, t, n) #define LV_DISPATCH11(f, t, n) LV_DISPATCH(f, t, n) -#define LV_ITERATE_ROOTS(f) \ - LV_DISPATCH(f, lv_ll_t, _lv_timer_ll) /*Linked list to store the lv_timers*/ \ - LV_DISPATCH(f, lv_ll_t, _lv_disp_ll) /*Linked list of display device*/ \ - LV_DISPATCH(f, lv_ll_t, _lv_indev_ll) /*Linked list of input device*/ \ - LV_DISPATCH(f, lv_ll_t, _lv_fsdrv_ll) \ - LV_DISPATCH(f, lv_ll_t, _lv_anim_ll) \ - LV_DISPATCH(f, lv_ll_t, _lv_group_ll) \ - LV_DISPATCH(f, lv_ll_t, _lv_img_decoder_ll) \ - LV_DISPATCH(f, lv_ll_t, _lv_obj_style_trans_ll) \ - LV_DISPATCH(f, lv_layout_dsc_t *, _lv_layout_list) \ - LV_DISPATCH_COND(f, _lv_img_cache_entry_t*, _lv_img_cache_array, LV_IMG_CACHE_DEF, 1) \ - LV_DISPATCH_COND(f, _lv_img_cache_entry_t, _lv_img_cache_single, LV_IMG_CACHE_DEF, 0) \ - LV_DISPATCH(f, lv_timer_t*, _lv_timer_act) \ - LV_DISPATCH(f, lv_mem_buf_arr_t , lv_mem_buf) \ +#define LV_ITERATE_ROOTS(f) \ + LV_DISPATCH(f, lv_ll_t, _lv_timer_ll) /*Linked list to store the lv_timers*/ \ + LV_DISPATCH(f, lv_ll_t, _lv_disp_ll) /*Linked list of display device*/ \ + LV_DISPATCH(f, lv_ll_t, _lv_indev_ll) /*Linked list of input device*/ \ + LV_DISPATCH(f, lv_ll_t, _lv_fsdrv_ll) \ + LV_DISPATCH(f, lv_ll_t, _lv_anim_ll) \ + LV_DISPATCH(f, lv_ll_t, _lv_group_ll) \ + LV_DISPATCH(f, lv_ll_t, _lv_img_decoder_ll) \ + LV_DISPATCH(f, lv_ll_t, _lv_obj_style_trans_ll) \ + LV_DISPATCH(f, lv_layout_dsc_t *, _lv_layout_list) \ + LV_DISPATCH_COND(f, _lv_img_cache_entry_t*, _lv_img_cache_array, LV_IMG_CACHE_DEF, 1) \ + LV_DISPATCH_COND(f, _lv_img_cache_entry_t, _lv_img_cache_single, LV_IMG_CACHE_DEF, 0) \ + LV_DISPATCH(f, lv_timer_t*, _lv_timer_act) \ + LV_DISPATCH(f, lv_mem_buf_arr_t , lv_mem_buf) \ LV_DISPATCH_COND(f, _lv_draw_mask_radius_circle_dsc_arr_t , _lv_circle_cache, LV_DRAW_COMPLEX, 1) \ - LV_DISPATCH_COND(f, _lv_draw_mask_saved_arr_t , _lv_draw_mask_list, LV_DRAW_COMPLEX, 1) \ - LV_DISPATCH(f, void * , _lv_theme_default_styles) \ + LV_DISPATCH_COND(f, _lv_draw_mask_saved_arr_t , _lv_draw_mask_list, LV_DRAW_COMPLEX, 1) \ + LV_DISPATCH(f, void * , _lv_theme_default_styles) \ LV_DISPATCH_COND(f, uint8_t *, _lv_font_decompr_buf, LV_USE_FONT_COMPRESSED, 1) #define LV_DEFINE_ROOT(root_type, root_name) root_type root_name; diff --git a/src/misc/lv_ll.c b/src/misc/lv_ll.c index 30fb329a6..c84647ccf 100644 --- a/src/misc/lv_ll.c +++ b/src/misc/lv_ll.c @@ -7,9 +7,6 @@ /********************* * INCLUDES *********************/ -#include -#include - #include "lv_ll.h" #include "lv_mem.h" @@ -44,7 +41,7 @@ static void node_set_next(lv_ll_t * ll_p, lv_ll_node_t * act, lv_ll_node_t * nex /** * Initialize linked list - * @param ll_dsc pointer to ll_dsc variable + * @param ll_p pointer to lv_ll_t variable * @param node_size the size of 1 node in bytes */ void _lv_ll_init(lv_ll_t * ll_p, uint32_t node_size) @@ -94,7 +91,7 @@ void * _lv_ll_ins_head(lv_ll_t * ll_p) * Insert a new node in front of the n_act node * @param ll_p pointer to linked list * @param n_act pointer a node - * @return pointer to the new head + * @return pointer to the new node */ void * _lv_ll_ins_prev(lv_ll_t * ll_p, void * n_act) { @@ -215,7 +212,7 @@ void _lv_ll_clear(lv_ll_t * ll_p) * @param ll_new_p pointer to the new linked list * @param node pointer to a node * @param head true: be the head in the new list - * false be the head in the new list + * false be the tail in the new list */ void _lv_ll_chg_list(lv_ll_t * ll_ori_p, lv_ll_t * ll_new_p, void * node, bool head) { @@ -265,7 +262,7 @@ void * _lv_ll_get_head(const lv_ll_t * ll_p) /** * Return with tail node of the linked list * @param ll_p pointer to linked list - * @return pointer to the head of 'll_p' + * @return pointer to the tail of 'll_p' */ void * _lv_ll_get_tail(const lv_ll_t * ll_p) { diff --git a/src/misc/lv_ll.h b/src/misc/lv_ll.h index f5ce966a6..d38f69285 100644 --- a/src/misc/lv_ll.h +++ b/src/misc/lv_ll.h @@ -41,7 +41,7 @@ typedef struct { /** * Initialize linked list - * @param ll_dsc pointer to ll_dsc variable + * @param ll_p pointer to lv_ll_t variable * @param node_size the size of 1 node in bytes */ void _lv_ll_init(lv_ll_t * ll_p, uint32_t node_size); @@ -57,7 +57,7 @@ void * _lv_ll_ins_head(lv_ll_t * ll_p); * Insert a new node in front of the n_act node * @param ll_p pointer to linked list * @param n_act pointer a node - * @return pointer to the new head + * @return pointer to the new node */ void * _lv_ll_ins_prev(lv_ll_t * ll_p, void * n_act); @@ -88,7 +88,7 @@ void _lv_ll_clear(lv_ll_t * ll_p); * @param ll_new_p pointer to the new linked list * @param node pointer to a node * @param head true: be the head in the new list - * false be the head in the new list + * false be the tail in the new list */ void _lv_ll_chg_list(lv_ll_t * ll_ori_p, lv_ll_t * ll_new_p, void * node, bool head); @@ -102,7 +102,7 @@ void * _lv_ll_get_head(const lv_ll_t * ll_p); /** * Return with tail node of the linked list * @param ll_p pointer to linked list - * @return pointer to the head of 'll_p' + * @return pointer to the tail of 'll_p' */ void * _lv_ll_get_tail(const lv_ll_t * ll_p); diff --git a/src/misc/lv_math.c b/src/misc/lv_math.c index fc107b138..2144a50ca 100644 --- a/src/misc/lv_math.c +++ b/src/misc/lv_math.c @@ -7,7 +7,6 @@ * INCLUDES *********************/ #include "lv_math.h" -#include /********************* * DEFINES diff --git a/src/misc/lv_math.h b/src/misc/lv_math.h index a52391db4..4b2860a90 100644 --- a/src/misc/lv_math.h +++ b/src/misc/lv_math.h @@ -105,7 +105,7 @@ int64_t lv_pow(int64_t base, int8_t exp); * @param max_out max output range * @return the mapped number */ -int32_t lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min, int32_t max); +int32_t lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min_out, int32_t max_out); /** * Get a pseudo random number in the given range @@ -131,10 +131,10 @@ uint32_t lv_rand(uint32_t min, uint32_t max); #define LV_ABS(x) ((x) > 0 ? (x) : (-(x))) #define LV_UDIV255(x) (((x) * 0x8081U) >> 0x17) -#define LV_IS_SIGNED(t) (((t)(-1)) < ((t) 0)) +#define LV_IS_SIGNED(t) (((t)(-1)) < ((t)0)) #define LV_UMAX_OF(t) (((0x1ULL << ((sizeof(t) * 8ULL) - 1ULL)) - 1ULL) | (0xFULL << ((sizeof(t) * 8ULL) - 4ULL))) #define LV_SMAX_OF(t) (((0x1ULL << ((sizeof(t) * 8ULL) - 1ULL)) - 1ULL) | (0x7ULL << ((sizeof(t) * 8ULL) - 4ULL))) -#define LV_MAX_OF(t) ((unsigned long) (LV_IS_SIGNED(t) ? LV_SMAX_OF(t) : LV_UMAX_OF(t))) +#define LV_MAX_OF(t) ((unsigned long)(LV_IS_SIGNED(t) ? LV_SMAX_OF(t) : LV_UMAX_OF(t))) #ifdef __cplusplus } /*extern "C"*/ diff --git a/src/misc/lv_mem.c b/src/misc/lv_mem.c index 219915f9a..91d50678b 100644 --- a/src/misc/lv_mem.c +++ b/src/misc/lv_mem.c @@ -11,7 +11,7 @@ #include "lv_tlsf.h" #include "lv_gc.h" #include "lv_assert.h" -#include +#include "lv_log.h" #if LV_MEM_CUSTOM != 0 #include LV_MEM_CUSTOM_INCLUDE @@ -134,10 +134,6 @@ void * lv_mem_alloc(size_t size) void * alloc = LV_MEM_CUSTOM_ALLOC(size); #endif -#if LV_MEM_ADD_JUNK - if(alloc != NULL) lv_memset(alloc, 0xaa, size); -#endif - if(alloc == NULL) { LV_LOG_ERROR("couldn't allocate memory (%lu bytes)", (unsigned long)size); lv_mem_monitor_t mon; @@ -146,6 +142,11 @@ void * lv_mem_alloc(size_t size) (int)(mon.total_size - mon.free_size), mon.used_pct, mon.frag_pct, (int)mon.free_biggest_size); } +#if LV_MEM_ADD_JUNK + else { + lv_memset(alloc, 0xaa, size); + } +#endif MEM_TRACE("allocated at %p", alloc); return alloc; @@ -227,7 +228,7 @@ lv_res_t lv_mem_test(void) /** * Give information about the work memory of dynamic allocation - * @param mon_p pointer to a dm_mon_p variable, + * @param mon_p pointer to a lv_mem_monitor_t variable, * the result of the analysis will be stored here */ void lv_mem_monitor(lv_mem_monitor_t * mon_p) diff --git a/src/misc/lv_mem.h b/src/misc/lv_mem.h index 0d7d29809..0d1817fed 100644 --- a/src/misc/lv_mem.h +++ b/src/misc/lv_mem.h @@ -17,12 +17,9 @@ extern "C" { #include #include -#include "lv_log.h" -#include "lv_types.h" - -#if LV_MEMCPY_MEMSET_STD #include -#endif + +#include "lv_types.h" /********************* * DEFINES @@ -99,7 +96,7 @@ lv_res_t lv_mem_test(void); /** * Give information about the work memory of dynamic allocation - * @param mon_p pointer to a dm_mon_p variable, + * @param mon_p pointer to a lv_mem_monitor_t variable, * the result of the analysis will be stored here */ void lv_mem_monitor(lv_mem_monitor_t * mon_p); diff --git a/src/misc/lv_printf.c b/src/misc/lv_printf.c index c98faa9d1..ebe8a55c0 100644 --- a/src/misc/lv_printf.c +++ b/src/misc/lv_printf.c @@ -37,7 +37,6 @@ #if LV_SPRINTF_CUSTOM == 0 #include -#include #define PRINTF_DISABLE_SUPPORT_FLOAT (!LV_SPRINTF_USE_FLOAT) diff --git a/src/misc/lv_style.c b/src/misc/lv_style.c index bcf76c948..160c1de53 100644 --- a/src/misc/lv_style.c +++ b/src/misc/lv_style.c @@ -295,6 +295,7 @@ uint8_t _lv_style_get_prop_group(lv_style_prop_t prop) if(group > 7) group = 7; /*The MSB marks all the custom properties*/ return (uint8_t)group; } + /********************** * STATIC FUNCTIONS **********************/ diff --git a/src/misc/lv_timer.c b/src/misc/lv_timer.c index ea4635d70..d8dd55b7a 100644 --- a/src/misc/lv_timer.c +++ b/src/misc/lv_timer.c @@ -6,9 +6,10 @@ * INCLUDES *********************/ #include "lv_timer.h" -#include -#include "../misc/lv_assert.h" #include "../hal/lv_hal_tick.h" +#include "lv_assert.h" +#include "lv_mem.h" +#include "lv_ll.h" #include "lv_gc.h" /********************* @@ -292,7 +293,7 @@ lv_timer_t * lv_timer_get_next(lv_timer_t * timer) **********************/ /** - * Execute timer if its priority is appropriate + * Execute timer if its remaining time is zero * @param timer pointer to lv_timer * @return true: execute, false: not executed */ diff --git a/src/misc/lv_timer.h b/src/misc/lv_timer.h index 71c63655f..ce94c7b04 100644 --- a/src/misc/lv_timer.h +++ b/src/misc/lv_timer.h @@ -16,8 +16,6 @@ extern "C" { #include #include -#include "lv_mem.h" -#include "lv_ll.h" /********************* * DEFINES diff --git a/src/misc/lv_tlsf.c b/src/misc/lv_tlsf.c index 97304aebd..63d1842d6 100644 --- a/src/misc/lv_tlsf.c +++ b/src/misc/lv_tlsf.c @@ -2,11 +2,11 @@ #if LV_MEM_CUSTOM == 0 #include -#include #include "lv_tlsf.h" #include "lv_mem.h" #include "lv_log.h" #include "lv_assert.h" + #undef printf #define printf LV_LOG_ERROR @@ -887,7 +887,7 @@ int lv_tlsf_check(lv_tlsf_t tlsf) static void default_walker(void * ptr, size_t size, int used, void * user) { - (void)user; + LV_UNUSED(user); printf("\t%p %s size: %x (%p)\n", ptr, used ? "used" : "free", (unsigned int)size, (void *)block_from_ptr(ptr)); } @@ -1087,7 +1087,7 @@ lv_tlsf_t lv_tlsf_create_with_pool(void * mem, size_t bytes) void lv_tlsf_destroy(lv_tlsf_t tlsf) { /* Nothing to do. */ - (void)tlsf; + LV_UNUSED(tlsf); } lv_pool_t lv_tlsf_get_pool(lv_tlsf_t tlsf) diff --git a/src/misc/lv_tlsf.h b/src/misc/lv_tlsf.h index c31e5b493..77424ab83 100644 --- a/src/misc/lv_tlsf.h +++ b/src/misc/lv_tlsf.h @@ -1,8 +1,8 @@ #include "../lv_conf_internal.h" #if LV_MEM_CUSTOM == 0 -#ifndef INCLUDED_tlsf -#define INCLUDED_tlsf +#ifndef LV_TLSF_H +#define LV_TLSF_H /* ** Two Level Segregated Fit memory allocator, version 3.1. @@ -90,6 +90,6 @@ int lv_tlsf_check_pool(lv_pool_t pool); }; #endif -#endif +#endif /*LV_TLSF_H*/ #endif /* LV_MEM_CUSTOM == 0 */ diff --git a/src/misc/lv_txt.c b/src/misc/lv_txt.c index 21cf8d04b..b8c31e5b7 100644 --- a/src/misc/lv_txt.c +++ b/src/misc/lv_txt.c @@ -813,7 +813,7 @@ static uint32_t lv_txt_iso8859_1_prev(const char * txt, uint32_t * i) */ static uint32_t lv_txt_iso8859_1_get_byte_id(const char * txt, uint32_t utf8_id) { - (void)txt; /*Unused*/ + LV_UNUSED(txt); /*Unused*/ return utf8_id; /*In Non encoded no difference*/ } @@ -826,7 +826,7 @@ static uint32_t lv_txt_iso8859_1_get_byte_id(const char * txt, uint32_t utf8_id) */ static uint32_t lv_txt_iso8859_1_get_char_id(const char * txt, uint32_t byte_id) { - (void)txt; /*Unused*/ + LV_UNUSED(txt); /*Unused*/ return byte_id; /*In Non encoded no difference*/ } diff --git a/src/misc/lv_types.h b/src/misc/lv_types.h index 155a76b37..172f21c43 100644 --- a/src/misc/lv_types.h +++ b/src/misc/lv_types.h @@ -41,7 +41,7 @@ extern "C" { */ enum { LV_RES_INV = 0, /*Typically indicates that the object is deleted (become invalid) in the action - function or an operation was failed*/ + function or an operation was failed*/ LV_RES_OK, /*The object is valid (no deleted) after the action*/ }; typedef uint8_t lv_res_t; @@ -69,7 +69,7 @@ typedef uint32_t lv_uintptr_t; * MACROS **********************/ -#define LV_UNUSED(x) ((void) x) +#define LV_UNUSED(x) ((void)x) #define _LV_CONCAT(x, y) x ## y #define LV_CONCAT(x, y) _LV_CONCAT(x, y)