fix(misc): correct the comment and code style (#2769)

and remove the redundant inclusion

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
This commit is contained in:
Xiang Xiao
2021-11-08 04:28:52 -06:00
committed by GitHub
parent a4978d0913
commit dfb036e42c
28 changed files with 108 additions and 123 deletions

4
lvgl.h
View File

@@ -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"

View File

@@ -8,10 +8,8 @@
*********************/
#include "lv_anim.h"
#include <stddef.h>
#include <string.h>
#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"
@@ -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);
@@ -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;

View File

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

View File

@@ -8,7 +8,7 @@
*********************/
#include "lv_anim_timeline.h"
#include "lv_mem.h"
#include "../misc/lv_assert.h"
#include "lv_assert.h"
/*********************
* DEFINES

View File

@@ -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

View File

@@ -14,7 +14,6 @@ extern "C" {
* INCLUDES
*********************/
#include "../lv_conf_internal.h"
#include <string.h>
#include <stdbool.h>
#include <stdint.h>

View File

@@ -16,6 +16,7 @@ extern "C" {
#include "../lv_conf_internal.h"
#include "lv_log.h"
#include "lv_mem.h"
#include <stdbool.h>
#include LV_ASSERT_HANDLER_INCLUDE
/*********************

View File

@@ -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);
}

View File

@@ -14,7 +14,6 @@ extern "C" {
* INCLUDES
*********************/
#include "lv_timer.h"
#include "lv_types.h"
/*********************

View File

@@ -367,5 +367,3 @@ lv_color_t lv_palette_darken(lv_palette_t p, uint8_t lvl)
return colors[p][lvl];
}

View File

@@ -8,9 +8,9 @@
*********************/
#include "lv_fs.h"
#include "../misc/lv_assert.h"
#include "lv_ll.h"
#include <string.h>
#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)
{
if(file_p->drv == NULL) {
*pos = 0;
if(file_p->drv == NULL) {
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)
{
if(rddir_p->drv == NULL || rddir_p->dir_d == NULL) {
fn[0] = '\0';
if(rddir_p->drv == NULL || rddir_p->dir_d == NULL) {
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
**********************/

View File

@@ -6,9 +6,7 @@
/*********************
* INCLUDES
*********************/
#include "lv_gc.h"
#include "string.h"
/*********************
* DEFINES

View File

@@ -13,11 +13,12 @@ extern "C" {
/*********************
* INCLUDES
*********************/
#include "../lv_conf_internal.h"
#include <stdint.h>
#include <stdbool.h>
#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"

View File

@@ -7,9 +7,6 @@
/*********************
* INCLUDES
*********************/
#include <stdint.h>
#include <string.h>
#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)
{

View File

@@ -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);

View File

@@ -7,7 +7,6 @@
* INCLUDES
*********************/
#include "lv_math.h"
#include <stdbool.h>
/*********************
* DEFINES

View File

@@ -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

View File

@@ -11,7 +11,7 @@
#include "lv_tlsf.h"
#include "lv_gc.h"
#include "lv_assert.h"
#include <string.h>
#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)

View File

@@ -17,12 +17,9 @@ extern "C" {
#include <stdint.h>
#include <stddef.h>
#include "lv_log.h"
#include "lv_types.h"
#if LV_MEMCPY_MEMSET_STD
#include <string.h>
#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);

View File

@@ -37,7 +37,6 @@
#if LV_SPRINTF_CUSTOM == 0
#include <stdbool.h>
#include <stdint.h>
#define PRINTF_DISABLE_SUPPORT_FLOAT (!LV_SPRINTF_USE_FLOAT)

View File

@@ -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
**********************/

View File

@@ -6,9 +6,10 @@
* INCLUDES
*********************/
#include "lv_timer.h"
#include <stddef.h>
#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
*/

View File

@@ -16,8 +16,6 @@ extern "C" {
#include <stdint.h>
#include <stdbool.h>
#include "lv_mem.h"
#include "lv_ll.h"
/*********************
* DEFINES

View File

@@ -2,11 +2,11 @@
#if LV_MEM_CUSTOM == 0
#include <limits.h>
#include <stddef.h>
#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)

View File

@@ -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 */

View File

@@ -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*/
}