1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-02-04 07:13:00 +08:00

Merge branch 'master' of https://github.com/littlevgl/lvgl into dev

This commit is contained in:
Gabor Kiss-Vamosi 2021-01-12 19:27:21 +01:00
commit 4c93793fe5
30 changed files with 207 additions and 279 deletions

53
Kconfig
View File

@ -50,9 +50,11 @@ menu "LVGL configuration"
config LV_COLOR_16_SWAP config LV_COLOR_16_SWAP
bool "Swap the 2 bytes of RGB565 color. Useful if the display has a 8 bit interface (e.g. SPI)." bool "Swap the 2 bytes of RGB565 color. Useful if the display has a 8 bit interface (e.g. SPI)."
depends on LV_COLOR_DEPTH_16
config LV_COLOR_SCREEN_TRANSP config LV_COLOR_SCREEN_TRANSP
bool "Enable screen transparency." bool "Enable screen transparency."
depends on LV_COLOR_DEPTH_32
help help
Useful for OSD or other overlapping GUIs. Useful for OSD or other overlapping GUIs.
Requires `LV_COLOR_DEPTH = 32` colors and the screen's style Requires `LV_COLOR_DEPTH = 32` colors and the screen's style
@ -106,8 +108,8 @@ menu "LVGL configuration"
menu "Memory manager settings" menu "Memory manager settings"
config LV_MEM_CUSTOM config LV_MEM_CUSTOM
bool bool
prompt "If true use custom malloc/free, otherwise use the built-in `lv_mem_alloc` and `lv_mem_free`" prompt "If true use custom malloc/free, otherwise use the built-in `lv_mem_alloc` and `lv_mem_free`"
config LV_MEM_CUSTOM_INCLUDE config LV_MEM_CUSTOM_INCLUDE
string string
@ -127,10 +129,10 @@ menu "LVGL configuration"
default "free" default "free"
depends on LV_MEM_CUSTOM depends on LV_MEM_CUSTOM
config LV_MEM_SIZE_BYTES config LV_MEM_SIZE_KILOBYTES
int int
prompt "Size of the memory used by `lv_mem_alloc` in kilobytes (>= 2kB)" prompt "Size of the memory used by `lv_mem_alloc` in kilobytes (>= 2kB)"
range 2 128 range 2 128
default 32 default 32
depends on !LV_MEM_CUSTOM depends on !LV_MEM_CUSTOM
@ -208,6 +210,7 @@ menu "LVGL configuration"
bool "Enable STM32 DMA2D." bool "Enable STM32 DMA2D."
config LV_GPU_DMA2D_CMSIS_INCLUDE config LV_GPU_DMA2D_CMSIS_INCLUDE
string "include path of CMSIS header of target processor" string "include path of CMSIS header of target processor"
depends on LV_USE_GPU_STM32_DMA2D
default "" default ""
help help
e.g. "stm32f769xx.h" or "stm32f429xx.h" e.g. "stm32f769xx.h" or "stm32f429xx.h"
@ -215,6 +218,7 @@ menu "LVGL configuration"
bool "Use PXP for CPU off-load on NXP RTxxx platforms." bool "Use PXP for CPU off-load on NXP RTxxx platforms."
config LV_USE_GPU_NXP_PXP_AUTO_INIT config LV_USE_GPU_NXP_PXP_AUTO_INIT
bool "Call lv_gpu_nxp_pxp_init() automatically or manually." bool "Call lv_gpu_nxp_pxp_init() automatically or manually."
depends on LV_USE_GPU_NXP_PXP
help help
1: Add default bare metal and FreeRTOS interrupt handling 1: Add default bare metal and FreeRTOS interrupt handling
routines for PXP (lv_gpu_nxp_pxp_osa.c) and call routines for PXP (lv_gpu_nxp_pxp_osa.c) and call
@ -372,8 +376,12 @@ menu "LVGL configuration"
but with > 10,000 characters if you see issues probably you but with > 10,000 characters if you see issues probably you
need to enable it. need to enable it.
config LV_USE_FONT_SUBPX
bool "Enable subpixel rendering."
config LV_FONT_SUBPX_BGR config LV_FONT_SUBPX_BGR
bool "Use BGR instead RGB for sub-pixel rendering." bool "Use BGR instead RGB for sub-pixel rendering."
depends on LV_USE_FONT_SUBPX
help help
Set the pixel order of the display. Set the pixel order of the display.
Important only if "subpx fonts" are used. Important only if "subpx fonts" are used.
@ -797,7 +805,7 @@ menu "LVGL configuration"
endmenu endmenu
menu "Theme usage" menu "Theme usage"
menu "Enable theme usage, always enable at least one theme" menu "Enable theme usage, always enable at least one theme"
config LV_THEME_EMPTY config LV_THEME_EMPTY
bool "Empty: No theme, you can apply your styles as you need." bool "Empty: No theme, you can apply your styles as you need."
default y if LV_CONF_MINIMAL default y if LV_CONF_MINIMAL
@ -808,7 +816,7 @@ menu "LVGL configuration"
default y if !LV_CONF_MINIMAL default y if !LV_CONF_MINIMAL
config LV_THEME_MONO config LV_THEME_MONO
bool "Mono: Mono-color theme for monochrome displays" bool "Mono: Mono-color theme for monochrome displays"
endmenu endmenu
choice LV_THEME_DEFAULT_INIT choice LV_THEME_DEFAULT_INIT
prompt "Select theme default init" prompt "Select theme default init"
@ -857,10 +865,8 @@ menu "LVGL configuration"
config LV_THEME_DEFAULT_FLAG_LIGHT config LV_THEME_DEFAULT_FLAG_LIGHT
bool "Light theme" bool "Light theme"
depends on LV_THEME_MATERIAL
config LV_THEME_DEFAULT_FLAG_DARK config LV_THEME_DEFAULT_FLAG_DARK
bool "Dark theme" bool "Dark theme"
depends on LV_THEME_MATERIAL
endchoice endchoice
endmenu endmenu
@ -893,16 +899,16 @@ menu "LVGL configuration"
config LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN config LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN
int "Min num chars before break" int "Min num chars before break"
default 3 default 3
depends on LV_TXT_LINE_BREAK_LONG_LEN > 0
help help
Minimum number of characters in a long word to put on a line before a break. Minimum number of characters in a long word to put on a line before a break.
Depends on LV_TXT_LINE_BREAK_LONG_LEN
config LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN config LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN
int "Min num chars after break" int "Min num chars after break"
default 3 default 3
depends on LV_TXT_LINE_BREAK_LONG_LEN > 0
help help
Minimum number of characters in a long word to put on a line after a break. Minimum number of characters in a long word to put on a line after a break.
Depends on LV_TXT_LINE_BREAK_LONG_LEN
config LV_TXT_COLOR_CMD config LV_TXT_COLOR_CMD
string "The control character to use for signalling text recoloring" string "The control character to use for signalling text recoloring"
@ -976,6 +982,7 @@ menu "LVGL configuration"
default y if !LV_CONF_MINIMAL default y if !LV_CONF_MINIMAL
config LV_CALENDAR_WEEK_STARTS_MONDAY config LV_CALENDAR_WEEK_STARTS_MONDAY
bool "Calendar week starts monday." bool "Calendar week starts monday."
depends on LV_USE_CALENDAR
config LV_USE_CANVAS config LV_USE_CANVAS
bool "Canvas. Dependencies: lv_img." bool "Canvas. Dependencies: lv_img."
select LV_USE_IMG select LV_USE_IMG
@ -1005,7 +1012,7 @@ menu "LVGL configuration"
default y if !LV_CONF_MINIMAL default y if !LV_CONF_MINIMAL
config LV_DROPDOWN_DEF_ANIM_TIME config LV_DROPDOWN_DEF_ANIM_TIME
int "Drop down animation time. 0: no animation." int "Drop down animation time. 0: no animation."
depends on LV_USE_DROPBOX depends on LV_USE_DROPDOWN
default 200 default 200
config LV_USE_GAUGE config LV_USE_GAUGE
bool "Gauge. Dependencies: lv_bar, lv_linemeter." bool "Gauge. Dependencies: lv_bar, lv_linemeter."
@ -1033,13 +1040,17 @@ menu "LVGL configuration"
config LV_LABEL_DEF_SCROLL_SPEED config LV_LABEL_DEF_SCROLL_SPEED
int "Hor. or ver. scroll speed [px/sec] in LV_LABEL_LONG_ROLL/ROLL_CIRC mode." int "Hor. or ver. scroll speed [px/sec] in LV_LABEL_LONG_ROLL/ROLL_CIRC mode."
default 25 default 25
depends on LV_USE_LABEL
config LV_LABEL_WAIT_CHAR_COUNT config LV_LABEL_WAIT_CHAR_COUNT
int "Waiting period at beginning/end of animation cycle." int "Waiting period at beginning/end of animation cycle."
default 3 default 3
depends on LV_USE_LABEL
config LV_LABEL_TEXT_SEL config LV_LABEL_TEXT_SEL
bool "Enable selecting text of the label." bool "Enable selecting text of the label."
depends on LV_USE_LABEL
config LV_LABEL_LONG_TXT_HINT config LV_LABEL_LONG_TXT_HINT
bool "Store extra some info in labels (12 bytes) to speed up drawing of very long texts." bool "Store extra some info in labels (12 bytes) to speed up drawing of very long texts."
depends on LV_USE_LABEL
config LV_USE_LED config LV_USE_LED
bool "LED." bool "LED."
default y if !LV_CONF_MINIMAL default y if !LV_CONF_MINIMAL
@ -1047,10 +1058,12 @@ menu "LVGL configuration"
int "LED minimal brightness." int "LED minimal brightness."
range 0 255 range 0 255
default 120 default 120
depends on LV_USE_LED
config LV_LED_BRIGHT_MAX config LV_LED_BRIGHT_MAX
int "LED maximal brightness." int "LED maximal brightness."
range 0 255 range 0 255
default 255 default 255
depends on LV_USE_LED
config LV_USE_LINE config LV_USE_LINE
bool "Line." bool "Line."
default y if !LV_CONF_MINIMAL default y if !LV_CONF_MINIMAL
@ -1064,12 +1077,14 @@ menu "LVGL configuration"
config LV_LIST_DEF_ANIM_TIME config LV_LIST_DEF_ANIM_TIME
int "List default animation time of focusing to a list element [ms]. 0: no animation." int "List default animation time of focusing to a list element [ms]. 0: no animation."
default 100 default 100
depends on LV_USE_LIST
config LV_USE_LINEMETER config LV_USE_LINEMETER
bool "Line meter." bool "Line meter."
default y if !LV_CONF_MINIMAL default y if !LV_CONF_MINIMAL
choice choice
prompt "Draw line more precisely at cost of performance." prompt "Draw line more precisely at cost of performance."
default LV_LINEMETER_PRECISE_NO_EXTRA_PRECISION default LV_LINEMETER_PRECISE_NO_EXTRA_PRECISION
depends on LV_USE_LINEMETER
config LV_LINEMETER_PRECISE_NO_EXTRA_PRECISION config LV_LINEMETER_PRECISE_NO_EXTRA_PRECISION
bool "0: No extra precision." bool "0: No extra precision."
config LV_LINEMETER_PRECISE_SOME_EXTRA_PRECISION config LV_LINEMETER_PRECISE_SOME_EXTRA_PRECISION
@ -1093,6 +1108,7 @@ menu "LVGL configuration"
config LV_PAGE_DEF_ANIM_TIME config LV_PAGE_DEF_ANIM_TIME
int "Focus default animation time [ms]. 0: No animation." int "Focus default animation time [ms]. 0: No animation."
default 100 default 100
depends on LV_USE_PAGE
config LV_USE_SPINNER config LV_USE_SPINNER
bool "Spinner. Dependencies: lv_arc, lv_anim." bool "Spinner. Dependencies: lv_arc, lv_anim."
select LV_USE_ARC select LV_USE_ARC
@ -1101,12 +1117,15 @@ menu "LVGL configuration"
config LV_SPINNER_DEF_ARC_LENGTH config LV_SPINNER_DEF_ARC_LENGTH
int "Spinner def. arc length [deg]." int "Spinner def. arc length [deg]."
default 60 default 60
depends on LV_USE_SPINNER
config LV_SPINNER_DEF_SPIN_TIME config LV_SPINNER_DEF_SPIN_TIME
int "Spinner def. spin time [ms]." int "Spinner def. spin time [ms]."
default 1000 default 1000
depends on LV_USE_SPINNER
choice choice
prompt "Type of spinner (animation type)." prompt "Type of spinner (animation type)."
default LV_SPINNER_TYPE_SPINNING_ARC default LV_SPINNER_TYPE_SPINNING_ARC
depends on LV_USE_SPINNER
config LV_SPINNER_TYPE_SPINNING_ARC config LV_SPINNER_TYPE_SPINNING_ARC
bool "0: Spinner type spinning arc." bool "0: Spinner type spinning arc."
config LV_SPINNER_TYPE_FILLSPIN_ARC config LV_SPINNER_TYPE_FILLSPIN_ARC
@ -1121,9 +1140,11 @@ menu "LVGL configuration"
config LV_ROLLER_DEF_ANIM_TIME config LV_ROLLER_DEF_ANIM_TIME
int "Focus animation time [ms]. 0: no animation." int "Focus animation time [ms]. 0: no animation."
default 200 default 200
depends on LV_USE_ROLLER
config LV_ROLLER_INF_PAGES config LV_ROLLER_INF_PAGES
int "Number of extra 'pages' when the controller is infinite." int "Number of extra 'pages' when the controller is infinite."
default 7 default 7
depends on LV_USE_ROLLER
config LV_USE_SLIDER config LV_USE_SLIDER
bool "Slider. Dependencies: lv_bar." bool "Slider. Dependencies: lv_bar."
select LV_USE_BAR select LV_USE_BAR
@ -1144,9 +1165,11 @@ menu "LVGL configuration"
config LV_TEXTAREA_DEF_CURSOR_BLINK_TIME config LV_TEXTAREA_DEF_CURSOR_BLINK_TIME
int "Text area def. cursor blink time [ms]." int "Text area def. cursor blink time [ms]."
default 400 default 400
depends on LV_USE_TEXTAREA
config LV_TEXTAREA_DEF_PWN_SHOW_TIME config LV_TEXTAREA_DEF_PWN_SHOW_TIME
int "Text area def. pwn show time [ms]." int "Text area def. pwn show time [ms]."
default 1500 default 1500
depends on LV_USE_TEXTAREA
config LV_USE_TABLE config LV_USE_TABLE
bool "Table. Dependencies: lv_label." bool "Table. Dependencies: lv_label."
select LV_USE_LABEL select LV_USE_LABEL
@ -1154,9 +1177,11 @@ menu "LVGL configuration"
config LV_TABLE_COL_MAX config LV_TABLE_COL_MAX
int "Table col max." int "Table col max."
default 12 default 12
depends on LV_USE_TABLE
config LV_TABLE_CELL_STYLE_CNT config LV_TABLE_CELL_STYLE_CNT
int "Table cell style count." int "Table cell style count."
default 4 default 4
depends on LV_USE_TABLE
config LV_USE_TABVIEW config LV_USE_TABVIEW
bool "Tab. Dependencies: lv_page, lv_btnm." bool "Tab. Dependencies: lv_page, lv_btnm."
select LV_USE_PAGE select LV_USE_PAGE
@ -1165,6 +1190,7 @@ menu "LVGL configuration"
config LV_TABVIEW_DEF_ANIM_TIME config LV_TABVIEW_DEF_ANIM_TIME
int "Time of slide animation [ms]. 0: No animation." int "Time of slide animation [ms]. 0: No animation."
default 300 default 300
depends on LV_USE_TABVIEW
config LV_USE_TILEVIEW config LV_USE_TILEVIEW
bool "Tileview. Dependencies: lv_page." bool "Tileview. Dependencies: lv_page."
select LV_USE_PAGE select LV_USE_PAGE
@ -1172,6 +1198,7 @@ menu "LVGL configuration"
config LV_TILEVIEW_DEF_ANIM_TIME config LV_TILEVIEW_DEF_ANIM_TIME
int "Time of slide animation [ms]. 0: No animation." int "Time of slide animation [ms]. 0: No animation."
default 300 default 300
depends on LV_USE_TILEVIEW
config LV_USE_WIN config LV_USE_WIN
bool "Window. Dependencies: lv_cont, lv_btn, lv_label, lv_img, lv_page." bool "Window. Dependencies: lv_cont, lv_btn, lv_label, lv_img, lv_page."
select LV_USE_CONT select LV_USE_CONT

View File

@ -30,8 +30,8 @@ extern "C" {
*******************/ *******************/
#ifndef LV_MEM_SIZE #ifndef LV_MEM_SIZE
#if defined (CONFIG_LV_MEM_SIZE_BYTES) #if defined (CONFIG_LV_MEM_SIZE_KILOBYTES)
#define CONFIG_LV_MEM_SIZE (CONFIG_LV_MEM_SIZE_BYTES * 1024U) #define CONFIG_LV_MEM_SIZE (CONFIG_LV_MEM_SIZE_KILOBYTES * 1024U)
#endif #endif
#endif #endif

View File

@ -13,10 +13,6 @@
#include "../lv_themes/lv_theme.h" #include "../lv_themes/lv_theme.h"
#include "../lv_misc/lv_gc.h" #include "../lv_misc/lv_gc.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/

View File

@ -30,10 +30,6 @@
#include "../lv_gpu/lv_gpu_nxp_pxp_osa.h" #include "../lv_gpu/lv_gpu_nxp_pxp_osa.h"
#endif #endif
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
#if defined(LV_USER_DATA_FREE_INCLUDE) #if defined(LV_USER_DATA_FREE_INCLUDE)
#include LV_USER_DATA_FREE_INCLUDE #include LV_USER_DATA_FREE_INCLUDE
#endif /* LV_USE_USER_DATA_FREE */ #endif /* LV_USE_USER_DATA_FREE */

View File

@ -23,10 +23,6 @@
#include "../lv_widgets/lv_label.h" #include "../lv_widgets/lv_label.h"
#endif #endif
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/

View File

@ -12,10 +12,6 @@
#include "../lv_misc/lv_debug.h" #include "../lv_misc/lv_debug.h"
#include "../lv_misc/lv_gc.h" #include "../lv_misc/lv_gc.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/

View File

@ -13,9 +13,6 @@
#include "../lv_hal/lv_hal_tick.h" #include "../lv_hal/lv_hal_tick.h"
#include "../lv_misc/lv_gc.h" #include "../lv_misc/lv_gc.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/

View File

@ -13,10 +13,6 @@
#include "../lv_misc/lv_color.h" #include "../lv_misc/lv_color.h"
#include "../lv_misc/lv_gc.h" #include "../lv_misc/lv_gc.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/

View File

@ -16,10 +16,6 @@
#include "../lv_misc/lv_utils.h" #include "../lv_misc/lv_utils.h"
#include "../lv_misc/lv_mem.h" #include "../lv_misc/lv_mem.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/

View File

@ -19,10 +19,6 @@
#include "../lv_core/lv_refr.h" #include "../lv_core/lv_refr.h"
#include "../lv_themes/lv_theme.h" #include "../lv_themes/lv_theme.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/

View File

@ -15,10 +15,6 @@
#include "../lv_misc/lv_gc.h" #include "../lv_misc/lv_gc.h"
#include "lv_hal_disp.h" #include "lv_hal_disp.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/

View File

@ -1,5 +1,5 @@
/** /**
* @file systick.c * @file lv_hal_tick.c
* Provide access to the system tick with 1 millisecond resolution * Provide access to the system tick with 1 millisecond resolution
*/ */
@ -76,7 +76,7 @@ uint32_t lv_tick_get(void)
/** /**
* Get the elapsed milliseconds since a previous time stamp * Get the elapsed milliseconds since a previous time stamp
* @param prev_tick a previous time stamp (return value of systick_get() ) * @param prev_tick a previous time stamp (return value of lv_tick_get() )
* @return the elapsed milliseconds since 'prev_tick' * @return the elapsed milliseconds since 'prev_tick'
*/ */
uint32_t lv_tick_elaps(uint32_t prev_tick) uint32_t lv_tick_elaps(uint32_t prev_tick)

View File

@ -51,7 +51,7 @@ uint32_t lv_tick_get(void);
/** /**
* Get the elapsed milliseconds since a previous time stamp * Get the elapsed milliseconds since a previous time stamp
* @param prev_tick a previous time stamp (return value of systick_get() ) * @param prev_tick a previous time stamp (return value of lv_tick_get() )
* @return the elapsed milliseconds since 'prev_tick' * @return the elapsed milliseconds since 'prev_tick'
*/ */
uint32_t lv_tick_elaps(uint32_t prev_tick); uint32_t lv_tick_elaps(uint32_t prev_tick);

View File

@ -17,10 +17,6 @@
#include "lv_math.h" #include "lv_math.h"
#include "lv_gc.h" #include "lv_gc.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/

View File

@ -17,6 +17,11 @@
* TYPEDEFS * TYPEDEFS
**********************/ **********************/
typedef struct _lv_async_info_t {
lv_async_cb_t cb;
void * user_data;
} lv_async_info_t;
/********************** /**********************
* STATIC PROTOTYPES * STATIC PROTOTYPES
**********************/ **********************/
@ -55,8 +60,6 @@ lv_res_t lv_async_call(lv_async_cb_t async_xcb, void * user_data)
info->cb = async_xcb; info->cb = async_xcb;
info->user_data = user_data; info->user_data = user_data;
/* Set the task's user data */
task->user_data = info;
lv_task_set_repeat_count(task, 1); lv_task_set_repeat_count(task, 1);
return LV_RES_OK; return LV_RES_OK;
} }

View File

@ -30,13 +30,6 @@ extern "C" {
*/ */
typedef void (*lv_async_cb_t)(void *); typedef void (*lv_async_cb_t)(void *);
typedef struct _lv_async_info_t {
lv_async_cb_t cb;
void * user_data;
} lv_async_info_t;
struct _lv_obj_t;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES
**********************/ **********************/

View File

@ -14,10 +14,6 @@
#include <string.h> #include <string.h>
#include "lv_gc.h" #include "lv_gc.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/
@ -95,18 +91,28 @@ lv_fs_res_t lv_fs_open(lv_fs_file_t * file_p, const char * path, lv_fs_mode_t mo
file_p->drv = lv_fs_get_drv(letter); file_p->drv = lv_fs_get_drv(letter);
if(file_p->drv == NULL) { if(file_p->drv == NULL) {
file_p->file_d = NULL;
return LV_FS_RES_NOT_EX; return LV_FS_RES_NOT_EX;
} }
if(file_p->drv->ready_cb != NULL) { if(file_p->drv->ready_cb != NULL) {
if(file_p->drv->ready_cb(file_p->drv) == false) { if(file_p->drv->ready_cb(file_p->drv) == false) {
file_p->drv = NULL; file_p->drv = NULL;
file_p->file_d = NULL;
return LV_FS_RES_HW_ERR; return LV_FS_RES_HW_ERR;
} }
} }
if(file_p->drv->open_cb == NULL) {
file_p->drv = NULL;
return LV_FS_RES_NOT_IMP;
}
const char * real_path = lv_fs_get_real_path(path);
if (file_p->drv->file_size == 0) { /*Is file_d zero size?*/
/*Pass file_d's address to open_cb, so the implementor can allocate memory byself*/
return file_p->drv->open_cb(file_p->drv, &file_p->file_d, real_path, mode);
}
file_p->file_d = lv_mem_alloc(file_p->drv->file_size); file_p->file_d = lv_mem_alloc(file_p->drv->file_size);
LV_ASSERT_MEM(file_p->file_d); LV_ASSERT_MEM(file_p->file_d);
if(file_p->file_d == NULL) { if(file_p->file_d == NULL) {
@ -114,12 +120,7 @@ lv_fs_res_t lv_fs_open(lv_fs_file_t * file_p, const char * path, lv_fs_mode_t mo
return LV_FS_RES_OUT_OF_MEM; /* Out of memory */ return LV_FS_RES_OUT_OF_MEM; /* Out of memory */
} }
if(file_p->drv->open_cb == NULL) { lv_fs_res_t res = file_p->drv->open_cb(file_p->drv, file_p->file_d, real_path, mode);
return LV_FS_RES_NOT_IMP;
}
const char * real_path = lv_fs_get_real_path(path);
lv_fs_res_t res = file_p->drv->open_cb(file_p->drv, file_p->file_d, real_path, mode);
if(res != LV_FS_RES_OK) { if(res != LV_FS_RES_OK) {
lv_mem_free(file_p->file_d); lv_mem_free(file_p->file_d);
@ -150,7 +151,6 @@ lv_fs_res_t lv_fs_close(lv_fs_file_t * file_p)
lv_mem_free(file_p->file_d); /*Clean up*/ lv_mem_free(file_p->file_d); /*Clean up*/
file_p->file_d = NULL; file_p->file_d = NULL;
file_p->drv = NULL; file_p->drv = NULL;
file_p->file_d = NULL;
return res; return res;
} }
@ -258,12 +258,12 @@ lv_fs_res_t lv_fs_seek(lv_fs_file_t * file_p, uint32_t pos)
lv_fs_res_t lv_fs_tell(lv_fs_file_t * file_p, uint32_t * pos) lv_fs_res_t lv_fs_tell(lv_fs_file_t * file_p, uint32_t * pos)
{ {
if(file_p->drv == NULL) { if(file_p->drv == NULL) {
pos = 0; *pos = 0;
return LV_FS_RES_INV_PARAM; return LV_FS_RES_INV_PARAM;
} }
if(file_p->drv->tell_cb == NULL) { if(file_p->drv->tell_cb == NULL) {
pos = 0; *pos = 0;
return LV_FS_RES_NOT_IMP; return LV_FS_RES_NOT_IMP;
} }
@ -284,7 +284,7 @@ lv_fs_res_t lv_fs_trunc(lv_fs_file_t * file_p)
return LV_FS_RES_INV_PARAM; return LV_FS_RES_INV_PARAM;
} }
if(file_p->drv->tell_cb == NULL) { if(file_p->drv->trunc_cb == NULL) {
return LV_FS_RES_NOT_IMP; return LV_FS_RES_NOT_IMP;
} }
@ -355,6 +355,9 @@ lv_fs_res_t lv_fs_rename(const char * oldname, const char * newname)
*/ */
lv_fs_res_t lv_fs_dir_open(lv_fs_dir_t * rddir_p, const char * path) lv_fs_res_t lv_fs_dir_open(lv_fs_dir_t * rddir_p, const char * path)
{ {
rddir_p->drv = NULL;
rddir_p->dir_d = NULL;
if(path == NULL) return LV_FS_RES_INV_PARAM; if(path == NULL) return LV_FS_RES_INV_PARAM;
char letter = path[0]; char letter = path[0];
@ -362,25 +365,43 @@ lv_fs_res_t lv_fs_dir_open(lv_fs_dir_t * rddir_p, const char * path)
rddir_p->drv = lv_fs_get_drv(letter); rddir_p->drv = lv_fs_get_drv(letter);
if(rddir_p->drv == NULL) { if(rddir_p->drv == NULL) {
rddir_p->dir_d = NULL;
return LV_FS_RES_NOT_EX; return LV_FS_RES_NOT_EX;
} }
rddir_p->dir_d = lv_mem_alloc(rddir_p->drv->rddir_size); if(rddir_p->drv->ready_cb != NULL) {
LV_ASSERT_MEM(rddir_p->dir_d); if(rddir_p->drv->ready_cb(rddir_p->drv) == false) {
if(rddir_p->dir_d == NULL) { rddir_p->drv = NULL;
rddir_p->dir_d = NULL; return LV_FS_RES_HW_ERR;
return LV_FS_RES_OUT_OF_MEM; /* Out of memory */ }
} }
if(rddir_p->drv->dir_open_cb == NULL) { if(rddir_p->drv->dir_open_cb == NULL) {
rddir_p->drv = NULL;
return LV_FS_RES_NOT_IMP; return LV_FS_RES_NOT_IMP;
} }
const char * real_path = lv_fs_get_real_path(path); const char * real_path = lv_fs_get_real_path(path);
if (rddir_p->drv->rddir_size == 0) { /*Is dir_d zero size?*/
/*Pass dir_d's address to dir_open_cb, so the implementor can allocate memory byself*/
return rddir_p->drv->dir_open_cb(rddir_p->drv, &rddir_p->dir_d, real_path);
}
rddir_p->dir_d = lv_mem_alloc(rddir_p->drv->rddir_size);
LV_ASSERT_MEM(rddir_p->dir_d);
if(rddir_p->dir_d == NULL) {
rddir_p->drv = NULL;
return LV_FS_RES_OUT_OF_MEM; /* Out of memory */
}
lv_fs_res_t res = rddir_p->drv->dir_open_cb(rddir_p->drv, rddir_p->dir_d, real_path); lv_fs_res_t res = rddir_p->drv->dir_open_cb(rddir_p->drv, rddir_p->dir_d, real_path);
if(res != LV_FS_RES_OK) {
lv_mem_free(rddir_p->dir_d);
rddir_p->dir_d = NULL;
rddir_p->drv = NULL;
}
return res; return res;
} }
@ -399,6 +420,7 @@ lv_fs_res_t lv_fs_dir_read(lv_fs_dir_t * rddir_p, char * fn)
} }
if(rddir_p->drv->dir_read_cb == NULL) { if(rddir_p->drv->dir_read_cb == NULL) {
fn[0] = '\0';
return LV_FS_RES_NOT_IMP; return LV_FS_RES_NOT_IMP;
} }
@ -418,19 +440,15 @@ lv_fs_res_t lv_fs_dir_close(lv_fs_dir_t * rddir_p)
return LV_FS_RES_INV_PARAM; return LV_FS_RES_INV_PARAM;
} }
lv_fs_res_t res;
if(rddir_p->drv->dir_close_cb == NULL) { if(rddir_p->drv->dir_close_cb == NULL) {
res = LV_FS_RES_NOT_IMP; return LV_FS_RES_NOT_IMP;
}
else {
res = rddir_p->drv->dir_close_cb(rddir_p->drv, rddir_p->dir_d);
} }
lv_fs_res_t res = rddir_p->drv->dir_close_cb(rddir_p->drv, rddir_p->dir_d);
lv_mem_free(rddir_p->dir_d); /*Clean up*/ lv_mem_free(rddir_p->dir_d); /*Clean up*/
rddir_p->dir_d = NULL; rddir_p->dir_d = NULL;
rddir_p->drv = NULL; rddir_p->drv = NULL;
rddir_p->dir_d = NULL;
return res; return res;
} }
@ -450,19 +468,22 @@ lv_fs_res_t lv_fs_free_space(char letter, uint32_t * total_p, uint32_t * free_p)
return LV_FS_RES_INV_PARAM; return LV_FS_RES_INV_PARAM;
} }
lv_fs_res_t res; if(drv->ready_cb != NULL) {
if(drv->ready_cb(drv) == false) {
return LV_FS_RES_HW_ERR;
}
}
if(drv->free_space_cb == NULL) { if(drv->free_space_cb == NULL) {
res = LV_FS_RES_NOT_IMP; return LV_FS_RES_NOT_IMP;
} }
else {
uint32_t total_tmp = 0;
uint32_t free_tmp = 0;
res = drv->free_space_cb(drv, &total_tmp, &free_tmp);
if(total_p != NULL) *total_p = total_tmp; uint32_t total_tmp = 0;
if(free_p != NULL) *free_p = free_tmp; uint32_t free_tmp = 0;
} lv_fs_res_t res = drv->free_space_cb(drv, &total_tmp, &free_tmp);
if(total_p != NULL) *total_p = total_tmp;
if(free_p != NULL) *free_p = free_tmp;
return res; return res;
} }

View File

@ -10,10 +10,6 @@
#include "lv_gc.h" #include "lv_gc.h"
#include "string.h" #include "string.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/

View File

@ -28,7 +28,7 @@ extern "C" {
#define LV_ITERATE_ROOTS(f) \ #define LV_ITERATE_ROOTS(f) \
f(lv_ll_t, _lv_task_ll) /*Linked list to store the lv_tasks*/ \ f(lv_ll_t, _lv_task_ll) /*Linked list to store the lv_tasks*/ \
f(lv_ll_t, _lv_disp_ll) /*Linked list of screens*/ \ f(lv_ll_t, _lv_disp_ll) /*Linked list of screens*/ \
f(lv_ll_t, _lv_indev_ll) /*Linked list of screens*/ \ f(lv_ll_t, _lv_indev_ll) /*Linked list of input device*/ \
f(lv_ll_t, _lv_drv_ll) \ f(lv_ll_t, _lv_drv_ll) \
f(lv_ll_t, _lv_file_ll) \ f(lv_ll_t, _lv_file_ll) \
f(lv_ll_t, _lv_anim_ll) \ f(lv_ll_t, _lv_anim_ll) \
@ -52,6 +52,7 @@ extern "C" {
#if LV_MEM_CUSTOM != 1 #if LV_MEM_CUSTOM != 1
#error "GC requires CUSTOM_MEM" #error "GC requires CUSTOM_MEM"
#endif /* LV_MEM_CUSTOM */ #endif /* LV_MEM_CUSTOM */
#include LV_GC_INCLUDE
#else /* LV_ENABLE_GC */ #else /* LV_ENABLE_GC */
#define LV_GC_ROOT(x) x #define LV_GC_ROOT(x) x
#define LV_EXTERN_ROOT(root_type, root_name) extern root_type root_name; #define LV_EXTERN_ROOT(root_type, root_name) extern root_type root_name;

View File

@ -1,5 +1,5 @@
/** /**
* @file lv_ll.c * @file lv_ll.h
* Handle linked lists. The nodes are dynamically allocated by the 'lv_mem' module. * Handle linked lists. The nodes are dynamically allocated by the 'lv_mem' module.
*/ */

View File

@ -23,12 +23,12 @@ extern "C" {
/*Possible log level. For compatibility declare it independently from `LV_USE_LOG`*/ /*Possible log level. For compatibility declare it independently from `LV_USE_LOG`*/
#define LV_LOG_LEVEL_TRACE 0 /**< A lot of logs to give detailed information*/ #define LV_LOG_LEVEL_TRACE 0 /**< A lot of logs to give detailed information*/
#define LV_LOG_LEVEL_INFO 1 /**< Log important events*/ #define LV_LOG_LEVEL_INFO 1 /**< Log important events*/
#define LV_LOG_LEVEL_WARN 2 /**< Log if something unwanted happened but didn't caused problem*/ #define LV_LOG_LEVEL_WARN 2 /**< Log if something unwanted happened but didn't caused problem*/
#define LV_LOG_LEVEL_ERROR 3 /**< Only critical issue, when the system may fail*/ #define LV_LOG_LEVEL_ERROR 3 /**< Only critical issue, when the system may fail*/
#define LV_LOG_LEVEL_USER 4 /**< Custom logs from the user*/ #define LV_LOG_LEVEL_USER 4 /**< Custom logs from the user*/
#define LV_LOG_LEVEL_NONE 5 /**< Do not log anything*/ #define LV_LOG_LEVEL_NONE 5 /**< Do not log anything*/
#define _LV_LOG_LEVEL_NUM 6 /**< Number of log levels */ #define _LV_LOG_LEVEL_NUM 6 /**< Number of log levels */
LV_EXPORT_CONST_INT(LV_LOG_LEVEL_TRACE); LV_EXPORT_CONST_INT(LV_LOG_LEVEL_TRACE);
LV_EXPORT_CONST_INT(LV_LOG_LEVEL_INFO); LV_EXPORT_CONST_INT(LV_LOG_LEVEL_INFO);

View File

@ -83,7 +83,7 @@ LV_ATTRIBUTE_FAST_MEM int16_t _lv_trigo_sin(int16_t angle)
* @param u3 end values in range of [0..LV_BEZIER_VAL_MAX] * @param u3 end values in range of [0..LV_BEZIER_VAL_MAX]
* @return the value calculated from the given parameters in range of [0..LV_BEZIER_VAL_MAX] * @return the value calculated from the given parameters in range of [0..LV_BEZIER_VAL_MAX]
*/ */
int32_t _lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3) uint32_t _lv_bezier3(uint32_t t, uint32_t u0, uint32_t u1, uint32_t u2, uint32_t u3)
{ {
uint32_t t_rem = 1024 - t; uint32_t t_rem = 1024 - t;
uint32_t t_rem2 = (t_rem * t_rem) >> 10; uint32_t t_rem2 = (t_rem * t_rem) >> 10;
@ -91,10 +91,10 @@ int32_t _lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3)
uint32_t t2 = (t * t) >> 10; uint32_t t2 = (t * t) >> 10;
uint32_t t3 = (t2 * t) >> 10; uint32_t t3 = (t2 * t) >> 10;
uint32_t v1 = ((uint32_t)t_rem3 * u0) >> 10; uint32_t v1 = (t_rem3 * u0) >> 10;
uint32_t v2 = ((uint32_t)3 * t_rem2 * t * u1) >> 20; uint32_t v2 = (3 * t_rem2 * t * u1) >> 20;
uint32_t v3 = ((uint32_t)3 * t_rem * t2 * u2) >> 20; uint32_t v3 = (3 * t_rem * t2 * u2) >> 20;
uint32_t v4 = ((uint32_t)t3 * u3) >> 10; uint32_t v4 = (t3 * u3) >> 10;
return v1 + v2 + v3 + v4; return v1 + v2 + v3 + v4;
} }
@ -118,12 +118,12 @@ LV_ATTRIBUTE_FAST_MEM void _lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask
// http://ww1.microchip.com/...en/AppNotes/91040a.pdf // http://ww1.microchip.com/...en/AppNotes/91040a.pdf
do { do {
trial = root + mask; trial = root + mask;
if((uint32_t)trial * trial <= x) root = trial; if(trial * trial <= x) root = trial;
mask = mask >> 1; mask = mask >> 1;
} while(mask); } while(mask);
q->i = (uint32_t) root >> 4; q->i = root >> 4;
q->f = (uint32_t)(root & 0xf) << 4; q->f = (root & 0xf) << 4;
} }
/** /**
@ -238,7 +238,7 @@ int64_t _lv_pow(int64_t base, int8_t exp)
* @param max_out max output range * @param max_out max output range
* @return the mapped number * @return the mapped number
*/ */
int16_t _lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min_out, int32_t max_out) int32_t _lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min_out, int32_t max_out)
{ {
if(x <= min_in) return min_out; if(x <= min_in) return min_out;
if(x >= max_in) return max_out; if(x >= max_in) return max_out;

View File

@ -1,5 +1,5 @@
/** /**
* @file math_base.h * @file lv_math.h
* *
*/ */
@ -74,7 +74,7 @@ LV_ATTRIBUTE_FAST_MEM int16_t _lv_trigo_sin(int16_t angle);
* @param u3 end values in range of [0..LV_BEZIER_VAL_MAX] * @param u3 end values in range of [0..LV_BEZIER_VAL_MAX]
* @return the value calculated from the given parameters in range of [0..LV_BEZIER_VAL_MAX] * @return the value calculated from the given parameters in range of [0..LV_BEZIER_VAL_MAX]
*/ */
int32_t _lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3); uint32_t _lv_bezier3(uint32_t t, uint32_t u0, uint32_t u1, uint32_t u2, uint32_t u3);
/** /**
* Calculate the atan2 of a vector. * Calculate the atan2 of a vector.
@ -117,7 +117,7 @@ int64_t _lv_pow(int64_t base, int8_t exp);
* @param max_out max output range * @param max_out max output range
* @return the mapped number * @return the mapped number
*/ */
int16_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, int32_t max);
/********************** /**********************
* MACROS * MACROS

View File

@ -16,10 +16,6 @@
#include LV_MEM_CUSTOM_INCLUDE #include LV_MEM_CUSTOM_INCLUDE
#endif #endif
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/
@ -44,11 +40,11 @@
#if LV_ENABLE_GC == 0 /*gc custom allocations must not include header*/ #if LV_ENABLE_GC == 0 /*gc custom allocations must not include header*/
/*The size of this union must be 4 bytes (uint32_t)*/ /*The size of this union must be 4/8 bytes (uint32_t/uint64_t)*/
typedef union { typedef union {
struct { struct {
MEM_UNIT used : 1; /* 1: if the entry is used*/ MEM_UNIT used : 1; /* 1: if the entry is used*/
MEM_UNIT d_size : 31; /* Size off the data (1 means 4 bytes)*/ MEM_UNIT d_size : 31; /* Size of the data*/
} s; } s;
MEM_UNIT header; /* The header (used + d_size)*/ MEM_UNIT header; /* The header (used + d_size)*/
} lv_mem_header_t; } lv_mem_header_t;
@ -104,6 +100,7 @@ static lv_mem_buf_t mem_buf_small[] = {{.p = mem_buf1_32, .size = MEM_BUF_SMALL_
#define COPY32 *d32 = *s32; d32++; s32++; #define COPY32 *d32 = *s32; d32++; s32++;
#define COPY8 *d8 = *s8; d8++; s8++; #define COPY8 *d8 = *s8; d8++; s8++;
#define SET32(x) *d32 = x; d32++; #define SET32(x) *d32 = x; d32++;
#define SET8(x) *d8 = x; d8++;
#define REPEAT8(expr) expr expr expr expr expr expr expr expr #define REPEAT8(expr) expr expr expr expr expr expr expr expr
/********************** /**********************
@ -121,14 +118,13 @@ void _lv_mem_init(void)
/*Allocate a large array to store the dynamically allocated data*/ /*Allocate a large array to store the dynamically allocated data*/
static LV_MEM_ATTR MEM_UNIT work_mem_int[LV_MEM_SIZE / sizeof(MEM_UNIT)]; static LV_MEM_ATTR MEM_UNIT work_mem_int[LV_MEM_SIZE / sizeof(MEM_UNIT)];
work_mem = (uint8_t *)work_mem_int; work_mem = (uint8_t *)work_mem_int;
mem_max_size = 0;
#else #else
work_mem = (uint8_t *)LV_MEM_ADR; work_mem = (uint8_t *)LV_MEM_ADR;
#endif #endif
lv_mem_ent_t * full = (lv_mem_ent_t *)work_mem; lv_mem_ent_t * full = (lv_mem_ent_t *)work_mem;
full->header.s.used = 0; full->header.s.used = 0;
/*The total mem size id reduced by the first header and the close patterns */ /*The total mem size reduced by the first header and the close patterns */
full->header.s.d_size = LV_MEM_SIZE - sizeof(lv_mem_header_t); full->header.s.d_size = LV_MEM_SIZE - sizeof(lv_mem_header_t);
#endif #endif
} }
@ -140,10 +136,9 @@ void _lv_mem_init(void)
void _lv_mem_deinit(void) void _lv_mem_deinit(void)
{ {
#if LV_MEM_CUSTOM == 0 #if LV_MEM_CUSTOM == 0
_lv_memset_00(work_mem, (LV_MEM_SIZE / sizeof(MEM_UNIT)) * sizeof(MEM_UNIT));
lv_mem_ent_t * full = (lv_mem_ent_t *)work_mem; lv_mem_ent_t * full = (lv_mem_ent_t *)work_mem;
full->header.s.used = 0; full->header.s.used = 0;
/*The total mem size id reduced by the first header and the close patterns */ /*The total mem size reduced by the first header and the close patterns */
full->header.s.d_size = LV_MEM_SIZE - sizeof(lv_mem_header_t); full->header.s.d_size = LV_MEM_SIZE - sizeof(lv_mem_header_t);
#endif #endif
} }
@ -159,13 +154,8 @@ void * lv_mem_alloc(size_t size)
return &zero_mem; return &zero_mem;
} }
#ifdef LV_ARCH_64 /*Round the size up to ALIGN_MASK*/
/*Round the size up to 8*/ size = (size + ALIGN_MASK) & (~ALIGN_MASK);
size = (size + 7) & (~0x7);
#else
/*Round the size up to 4*/
size = (size + 3) & (~0x3);
#endif
void * alloc = NULL; void * alloc = NULL;
#if LV_MEM_CUSTOM == 0 #if LV_MEM_CUSTOM == 0
@ -264,7 +254,6 @@ void lv_mem_free(const void * data)
lv_mem_defrag(); lv_mem_defrag();
} }
#endif /*LV_MEM_AUTO_DEFRAG*/ #endif /*LV_MEM_AUTO_DEFRAG*/
#else /*Use custom, user defined free function*/ #else /*Use custom, user defined free function*/
#if LV_ENABLE_GC == 0 #if LV_ENABLE_GC == 0
@ -287,14 +276,8 @@ void lv_mem_free(const void * data)
void * lv_mem_realloc(void * data_p, size_t new_size) void * lv_mem_realloc(void * data_p, size_t new_size)
{ {
/*Round the size up to ALIGN_MASK*/
#ifdef LV_ARCH_64 new_size = (new_size + ALIGN_MASK) & (~ALIGN_MASK);
/*Round the size up to 8*/
new_size = (new_size + 7) & (~0x7);
#else
/*Round the size up to 4*/
new_size = (new_size + 3) & (~0x3);
#endif
/*data_p could be previously freed pointer (in this case it is invalid)*/ /*data_p could be previously freed pointer (in this case it is invalid)*/
if(data_p != NULL) { if(data_p != NULL) {
@ -325,10 +308,10 @@ void * lv_mem_realloc(void * data_p, size_t new_size)
if(data_p != NULL) { if(data_p != NULL) {
/*Copy the old data to the new. Use the smaller size*/ /*Copy the old data to the new. Use the smaller size*/
if(old_size != 0) { if(old_size != 0 && new_size != 0) {
_lv_memcpy(new_p, data_p, LV_MATH_MIN(new_size, old_size)); _lv_memcpy(new_p, data_p, LV_MATH_MIN(new_size, old_size));
lv_mem_free(data_p);
} }
lv_mem_free(data_p);
} }
return new_p; return new_p;
@ -419,9 +402,8 @@ void lv_mem_monitor(lv_mem_monitor_t * mon_p)
_lv_memset(mon_p, 0, sizeof(lv_mem_monitor_t)); _lv_memset(mon_p, 0, sizeof(lv_mem_monitor_t));
#if LV_MEM_CUSTOM == 0 #if LV_MEM_CUSTOM == 0
lv_mem_ent_t * e; lv_mem_ent_t * e;
e = NULL;
e = ent_get_next(e); e = ent_get_next(NULL);
while(e != NULL) { while(e != NULL) {
if(e->header.s.used == 0) { if(e->header.s.used == 0) {
@ -439,13 +421,13 @@ void lv_mem_monitor(lv_mem_monitor_t * mon_p)
} }
mon_p->total_size = LV_MEM_SIZE; mon_p->total_size = LV_MEM_SIZE;
mon_p->max_used = mem_max_size; mon_p->max_used = mem_max_size;
mon_p->used_pct = 100 - (100U * mon_p->free_size) / mon_p->total_size; mon_p->used_pct = 100 - (100U * mon_p->free_size) / mon_p->total_size;
if(mon_p->free_size > 0) { if(mon_p->free_size > 0) {
mon_p->frag_pct = (uint32_t)mon_p->free_biggest_size * 100U / mon_p->free_size; mon_p->frag_pct = mon_p->free_biggest_size * 100U / mon_p->free_size;
mon_p->frag_pct = 100 - mon_p->frag_pct; mon_p->frag_pct = 100 - mon_p->frag_pct;
} }
else { else {
mon_p->frag_pct = 0; /*no fragmentation if all the RAM is used*/ mon_p->frag_pct = 0; /*no fragmentation if all the RAM is used*/
} }
#endif #endif
} }
@ -522,14 +504,16 @@ void * _lv_mem_buf_get(uint32_t size)
/*Reallocate a free buffer*/ /*Reallocate a free buffer*/
for(i = 0; i < LV_MEM_BUF_MAX_NUM; i++) { for(i = 0; i < LV_MEM_BUF_MAX_NUM; i++) {
if(LV_GC_ROOT(_lv_mem_buf[i]).used == 0) { if(LV_GC_ROOT(_lv_mem_buf[i]).used == 0) {
/*if this fails you probably need to increase your LV_MEM_SIZE/heap size*/
void * buf = lv_mem_realloc(LV_GC_ROOT(_lv_mem_buf[i]).p, size);
if(buf == NULL) {
LV_DEBUG_ASSERT(false, "Out of memory, can't allocate a new buffer (increase your LV_MEM_SIZE/heap size)", 0x00);
return NULL;
}
LV_GC_ROOT(_lv_mem_buf[i]).used = 1; LV_GC_ROOT(_lv_mem_buf[i]).used = 1;
LV_GC_ROOT(_lv_mem_buf[i]).size = size; LV_GC_ROOT(_lv_mem_buf[i]).size = size;
/*if this fails you probably need to increase your LV_MEM_SIZE/heap size*/ LV_GC_ROOT(_lv_mem_buf[i]).p = buf;
LV_GC_ROOT(_lv_mem_buf[i]).p = lv_mem_realloc(LV_GC_ROOT(_lv_mem_buf[i]).p, size); return LV_GC_ROOT(_lv_mem_buf[i]).p;
if(LV_GC_ROOT(_lv_mem_buf[i]).p == NULL) {
LV_DEBUG_ASSERT(false, "Out of memory, can't allocate a new buffer (increase your LV_MEM_SIZE/heap size", 0x00);
}
return LV_GC_ROOT(_lv_mem_buf[i]).p;
} }
} }
@ -663,8 +647,7 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset(void * dst, uint8_t v, size_t len)
if(d_align) { if(d_align) {
d_align = ALIGN_MASK + 1 - d_align; d_align = ALIGN_MASK + 1 - d_align;
while(d_align && len) { while(d_align && len) {
*d8 = v; SET8(v);
d8++;
len--; len--;
d_align--; d_align--;
} }
@ -675,14 +658,7 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset(void * dst, uint8_t v, size_t len)
uint32_t * d32 = (uint32_t *)d8; uint32_t * d32 = (uint32_t *)d8;
while(len > 32) { while(len > 32) {
SET32(v32); REPEAT8(SET32(v32));
SET32(v32);
SET32(v32);
SET32(v32);
SET32(v32);
SET32(v32);
SET32(v32);
SET32(v32);
len -= 32; len -= 32;
} }
@ -693,8 +669,7 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset(void * dst, uint8_t v, size_t len)
d8 = (uint8_t *)d32; d8 = (uint8_t *)d32;
while(len) { while(len) {
*d8 = v; SET8(v);
d8++;
len--; len--;
} }
} }
@ -713,8 +688,7 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset_00(void * dst, size_t len)
if(d_align) { if(d_align) {
d_align = ALIGN_MASK + 1 - d_align; d_align = ALIGN_MASK + 1 - d_align;
while(d_align && len) { while(d_align && len) {
*d8 = 0x00; SET8(0);
d8++;
len--; len--;
d_align--; d_align--;
} }
@ -722,14 +696,7 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset_00(void * dst, size_t len)
uint32_t * d32 = (uint32_t *)d8; uint32_t * d32 = (uint32_t *)d8;
while(len > 32) { while(len > 32) {
SET32(0); REPEAT8(SET32(0));
SET32(0);
SET32(0);
SET32(0);
SET32(0);
SET32(0);
SET32(0);
SET32(0);
len -= 32; len -= 32;
} }
@ -740,8 +707,7 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset_00(void * dst, size_t len)
d8 = (uint8_t *)d32; d8 = (uint8_t *)d32;
while(len) { while(len) {
*d8 = 0; SET8(0);
d8++;
len--; len--;
} }
} }
@ -760,8 +726,7 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset_ff(void * dst, size_t len)
if(d_align) { if(d_align) {
d_align = ALIGN_MASK + 1 - d_align; d_align = ALIGN_MASK + 1 - d_align;
while(d_align && len) { while(d_align && len) {
*d8 = 0xFF; SET8(0xFF);
d8++;
len--; len--;
d_align--; d_align--;
} }
@ -769,14 +734,7 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset_ff(void * dst, size_t len)
uint32_t * d32 = (uint32_t *)d8; uint32_t * d32 = (uint32_t *)d8;
while(len > 32) { while(len > 32) {
SET32(0xFFFFFFFF); REPEAT8(SET32(0xFFFFFFFF));
SET32(0xFFFFFFFF);
SET32(0xFFFFFFFF);
SET32(0xFFFFFFFF);
SET32(0xFFFFFFFF);
SET32(0xFFFFFFFF);
SET32(0xFFFFFFFF);
SET32(0xFFFFFFFF);
len -= 32; len -= 32;
} }
@ -787,8 +745,7 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset_ff(void * dst, size_t len)
d8 = (uint8_t *)d32; d8 = (uint8_t *)d32;
while(len) { while(len) {
*d8 = 0xFF; SET8(0xFF);
d8++;
len--; len--;
} }
} }
@ -851,14 +808,8 @@ static void * ent_alloc(lv_mem_ent_t * e, size_t size)
*/ */
static void ent_trunc(lv_mem_ent_t * e, size_t size) static void ent_trunc(lv_mem_ent_t * e, size_t size)
{ {
/*Round the size up to ALIGN_MASK*/
#ifdef LV_ARCH_64 size = (size + ALIGN_MASK) & (~ALIGN_MASK);
/*Round the size up to 8*/
size = (size + 7) & (~0x7);
#else
/*Round the size up to 4*/
size = (size + 3) & (~0x3);
#endif
/*Don't let empty space only for a header without data*/ /*Don't let empty space only for a header without data*/
if(e->header.s.d_size == size + sizeof(lv_mem_header_t)) { if(e->header.s.d_size == size + sizeof(lv_mem_header_t)) {
@ -871,10 +822,10 @@ static void ent_trunc(lv_mem_ent_t * e, size_t size)
lv_mem_ent_t * after_new_e = (lv_mem_ent_t *)&e_data[size]; lv_mem_ent_t * after_new_e = (lv_mem_ent_t *)&e_data[size];
after_new_e->header.s.used = 0; after_new_e->header.s.used = 0;
after_new_e->header.s.d_size = (uint32_t)e->header.s.d_size - size - sizeof(lv_mem_header_t); after_new_e->header.s.d_size = (uint32_t)e->header.s.d_size - size - sizeof(lv_mem_header_t);
}
/* Set the new size for the original entry */ /* Set the new size for the original entry */
e->header.s.d_size = (uint32_t)size; e->header.s.d_size = (uint32_t)size;
}
} }
#endif #endif

View File

@ -64,4 +64,4 @@ int lv_vsnprintf(char * buffer, size_t count, const char * format, va_list va);
} }
#endif #endif
#endif // _PRINTF_H_ #endif // _LV_PRINTF_H_

View File

@ -13,10 +13,6 @@
#include "../lv_hal/lv_hal_tick.h" #include "../lv_hal/lv_hal_tick.h"
#include "lv_gc.h" #include "lv_gc.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/

View File

@ -13,10 +13,6 @@
#include "../lv_misc/lv_gc.h" #include "../lv_misc/lv_gc.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/

View File

@ -12,10 +12,6 @@
#include "../lv_misc/lv_gc.h" #include "../lv_misc/lv_gc.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/

View File

@ -12,10 +12,6 @@
#include "../lv_misc/lv_gc.h" #include "../lv_misc/lv_gc.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/

View File

@ -12,10 +12,6 @@
#include "../lv_misc/lv_gc.h" #include "../lv_misc/lv_gc.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/
@ -342,13 +338,8 @@ lv_theme_t * lv_theme_template_init(lv_color_t color_primary, lv_color_t color_s
* styles' data if LVGL is used in a binding (e.g. Micropython) * styles' data if LVGL is used in a binding (e.g. Micropython)
* In a general case styles could be simple `static lv_style_t my style` variables or allocated directly into `styles`*/ * In a general case styles could be simple `static lv_style_t my style` variables or allocated directly into `styles`*/
if(!inited) { if(!inited) {
#if defined(LV_GC_INCLUDE)
LV_GC_ROOT(_lv_theme_template_styles) = lv_mem_alloc(sizeof(theme_styles_t)); LV_GC_ROOT(_lv_theme_template_styles) = lv_mem_alloc(sizeof(theme_styles_t));
styles = (theme_styles_t *)LV_GC_ROOT(_lv_theme_template_styles); styles = (theme_styles_t *)LV_GC_ROOT(_lv_theme_template_styles);
#else
styles = lv_mem_alloc(sizeof(theme_styles_t));
#endif
} }
theme.color_primary = color_primary; theme.color_primary = color_primary;