2023-07-05 13:05:19 +02:00
|
|
|
/**
|
|
|
|
* @file lv_init.c
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* INCLUDES
|
|
|
|
*********************/
|
2023-08-19 01:42:37 +02:00
|
|
|
#include "core/lv_global.h"
|
2023-07-05 13:05:19 +02:00
|
|
|
#include "core/lv_obj.h"
|
2023-09-18 22:57:30 +02:00
|
|
|
#include "display/lv_display_private.h"
|
2023-07-05 13:05:19 +02:00
|
|
|
#include "indev/lv_indev_private.h"
|
2023-08-19 01:42:37 +02:00
|
|
|
#include "layouts/lv_layout.h"
|
2023-11-20 04:53:40 +08:00
|
|
|
#include "libs/bin_decoder/lv_bin_decoder.h"
|
2023-07-05 13:05:19 +02:00
|
|
|
#include "libs/bmp/lv_bmp.h"
|
|
|
|
#include "libs/ffmpeg/lv_ffmpeg.h"
|
|
|
|
#include "libs/freetype/lv_freetype.h"
|
|
|
|
#include "libs/fsdrv/lv_fsdrv.h"
|
|
|
|
#include "libs/gif/lv_gif.h"
|
2023-09-20 16:38:47 +08:00
|
|
|
#include "libs/tjpgd/lv_tjpgd.h"
|
2023-09-22 16:43:59 +08:00
|
|
|
#include "libs/libjpeg_turbo/lv_libjpeg_turbo.h"
|
2023-09-20 16:30:04 +08:00
|
|
|
#include "libs/lodepng/lv_lodepng.h"
|
2023-09-25 16:28:35 +08:00
|
|
|
#include "libs/libpng/lv_libpng.h"
|
2023-07-05 13:05:19 +02:00
|
|
|
#include "draw/lv_draw.h"
|
|
|
|
#include "misc/lv_async.h"
|
|
|
|
#include "misc/lv_fs.h"
|
2023-09-20 13:32:24 +03:00
|
|
|
#if LV_USE_DRAW_VGLITE
|
|
|
|
#include "draw/nxp/vglite/lv_draw_vglite.h"
|
|
|
|
#endif
|
|
|
|
#if LV_USE_DRAW_PXP
|
|
|
|
#include "draw/nxp/pxp/lv_draw_pxp.h"
|
|
|
|
#endif
|
2023-12-12 11:43:21 +01:00
|
|
|
#if LV_USE_DRAW_DAVE2D
|
|
|
|
#include "draw/renesas/dave2d/lv_draw_dave2d.h"
|
|
|
|
#endif
|
2023-11-29 16:01:31 +08:00
|
|
|
#if LV_USE_DRAW_SDL
|
|
|
|
#include "draw/sdl/lv_draw_sdl.h"
|
|
|
|
#endif
|
2023-12-18 21:17:42 +08:00
|
|
|
#if LV_USE_DRAW_VG_LITE
|
|
|
|
#include "draw/vg_lite/lv_draw_vg_lite.h"
|
|
|
|
#endif
|
2024-01-14 23:35:35 +08:00
|
|
|
#if LV_USE_WINDOWS
|
2024-01-18 14:29:39 +01:00
|
|
|
#include "drivers/windows/lv_windows_context.h"
|
2024-01-14 23:35:35 +08:00
|
|
|
#endif
|
2023-07-05 13:05:19 +02:00
|
|
|
|
|
|
|
/*********************
|
|
|
|
* DEFINES
|
|
|
|
*********************/
|
2023-08-19 01:42:37 +02:00
|
|
|
#define lv_initialized LV_GLOBAL_DEFAULT()->inited
|
2023-11-21 20:12:13 +01:00
|
|
|
#define lv_deinit_in_progress LV_GLOBAL_DEFAULT()->deinit_in_progress
|
2023-07-05 13:05:19 +02:00
|
|
|
|
|
|
|
/**********************
|
|
|
|
* TYPEDEFS
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* STATIC PROTOTYPES
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* STATIC VARIABLES
|
|
|
|
**********************/
|
2023-08-19 01:42:37 +02:00
|
|
|
#if LV_ENABLE_GLOBAL_CUSTOM == 0
|
|
|
|
lv_global_t lv_global;
|
|
|
|
#endif
|
2023-07-05 13:05:19 +02:00
|
|
|
|
|
|
|
/**********************
|
|
|
|
* MACROS
|
|
|
|
**********************/
|
|
|
|
|
2023-12-27 03:10:16 +00:00
|
|
|
#ifndef LV_GLOBAL_INIT
|
|
|
|
#define LV_GLOBAL_INIT(__GLOBAL_PTR) lv_global_init((lv_global_t *)(__GLOBAL_PTR))
|
|
|
|
#endif
|
|
|
|
|
2023-07-05 13:05:19 +02:00
|
|
|
/**********************
|
|
|
|
* GLOBAL FUNCTIONS
|
|
|
|
**********************/
|
2023-08-19 01:42:37 +02:00
|
|
|
static inline void lv_global_init(lv_global_t * global)
|
|
|
|
{
|
|
|
|
LV_ASSERT_NULL(global);
|
|
|
|
|
|
|
|
if(global == NULL) {
|
|
|
|
LV_LOG_ERROR("lv_global cannot be null");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-11-06 15:10:56 +01:00
|
|
|
lv_memzero(global, sizeof(lv_global_t));
|
2023-08-19 01:42:37 +02:00
|
|
|
|
2023-09-18 22:57:30 +02:00
|
|
|
_lv_ll_init(&(global->disp_ll), sizeof(lv_display_t));
|
2023-08-19 01:42:37 +02:00
|
|
|
_lv_ll_init(&(global->indev_ll), sizeof(lv_indev_t));
|
|
|
|
|
|
|
|
global->memory_zero = ZERO_MEM_SENTINEL;
|
|
|
|
global->style_refresh = true;
|
|
|
|
global->layout_count = _LV_LAYOUT_LAST;
|
2023-09-21 13:30:33 +02:00
|
|
|
global->style_last_custom_prop_id = (uint32_t)_LV_STYLE_LAST_BUILT_IN_PROP;
|
2023-08-19 01:42:37 +02:00
|
|
|
global->event_last_register_id = _LV_EVENT_LAST;
|
2023-12-14 21:22:54 +08:00
|
|
|
lv_rand_set_seed(0x1234ABCD);
|
2023-08-19 01:42:37 +02:00
|
|
|
|
2024-04-25 17:17:38 +02:00
|
|
|
#ifdef LV_LOG_PRINT_CB
|
|
|
|
void LV_LOG_PRINT_CB(lv_log_level_t, const char * txt);
|
|
|
|
global->custom_log_print_cb = LV_LOG_PRINT_CB;
|
|
|
|
#endif
|
|
|
|
|
2023-08-19 01:42:37 +02:00
|
|
|
#if defined(LV_DRAW_SW_SHADOW_CACHE_SIZE) && LV_DRAW_SW_SHADOW_CACHE_SIZE > 0
|
|
|
|
global->sw_shadow_cache.cache_size = -1;
|
|
|
|
global->sw_shadow_cache.cache_r = -1;
|
|
|
|
#endif
|
|
|
|
}
|
2023-07-05 13:05:19 +02:00
|
|
|
|
2023-11-13 15:23:30 +08:00
|
|
|
static inline void _lv_cleanup_devices(lv_global_t * global)
|
|
|
|
{
|
|
|
|
LV_ASSERT_NULL(global);
|
|
|
|
|
|
|
|
if(global) {
|
|
|
|
/* cleanup indev and display */
|
|
|
|
_lv_ll_clear_custom(&(global->indev_ll), (void (*)(void *)) lv_indev_delete);
|
2023-11-21 20:16:52 +01:00
|
|
|
_lv_ll_clear_custom(&(global->disp_ll), (void (*)(void *)) lv_display_delete);
|
2023-11-13 15:23:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-05 13:05:19 +02:00
|
|
|
bool lv_is_initialized(void)
|
|
|
|
{
|
2023-08-27 21:28:56 +02:00
|
|
|
#if LV_ENABLE_GLOBAL_CUSTOM
|
|
|
|
if(LV_GLOBAL_DEFAULT()) return lv_initialized;
|
|
|
|
else return false;
|
|
|
|
#else
|
2023-07-05 13:05:19 +02:00
|
|
|
return lv_initialized;
|
2023-08-27 21:28:56 +02:00
|
|
|
#endif
|
2023-07-05 13:05:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void lv_init(void)
|
|
|
|
{
|
2023-08-19 01:42:37 +02:00
|
|
|
/*First initialize Garbage Collection if needed*/
|
|
|
|
#ifdef LV_GC_INIT
|
|
|
|
LV_GC_INIT();
|
|
|
|
#endif
|
|
|
|
|
2023-07-05 13:05:19 +02:00
|
|
|
/*Do nothing if already initialized*/
|
|
|
|
if(lv_initialized) {
|
2023-08-19 01:42:37 +02:00
|
|
|
LV_LOG_WARN("lv_init: already initialized");
|
2023-07-05 13:05:19 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
LV_LOG_INFO("begin");
|
|
|
|
|
2023-08-19 01:42:37 +02:00
|
|
|
/*Initialize members of static variable lv_global */
|
2023-12-27 03:10:16 +00:00
|
|
|
LV_GLOBAL_INIT(LV_GLOBAL_DEFAULT());
|
2023-07-05 13:05:19 +02:00
|
|
|
|
|
|
|
lv_mem_init();
|
|
|
|
|
2023-08-25 22:47:59 +02:00
|
|
|
_lv_draw_buf_init_handlers();
|
|
|
|
|
2023-08-19 01:42:37 +02:00
|
|
|
#if LV_USE_SPAN != 0
|
|
|
|
lv_span_stack_init();
|
|
|
|
#endif
|
|
|
|
|
2023-07-05 13:05:19 +02:00
|
|
|
#if LV_USE_PROFILER && LV_USE_PROFILER_BUILTIN
|
|
|
|
lv_profiler_builtin_config_t profiler_config;
|
|
|
|
lv_profiler_builtin_config_init(&profiler_config);
|
|
|
|
lv_profiler_builtin_init(&profiler_config);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
_lv_timer_core_init();
|
|
|
|
|
|
|
|
_lv_fs_init();
|
|
|
|
|
2023-08-19 01:42:37 +02:00
|
|
|
_lv_layout_init();
|
|
|
|
|
2023-07-05 13:05:19 +02:00
|
|
|
_lv_anim_core_init();
|
|
|
|
|
|
|
|
_lv_group_init();
|
|
|
|
|
|
|
|
lv_draw_init();
|
|
|
|
|
|
|
|
#if LV_USE_DRAW_SW
|
|
|
|
lv_draw_sw_init();
|
|
|
|
#endif
|
|
|
|
|
2023-09-20 13:32:24 +03:00
|
|
|
#if LV_USE_DRAW_VGLITE
|
|
|
|
lv_draw_vglite_init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LV_USE_DRAW_PXP
|
|
|
|
lv_draw_pxp_init();
|
|
|
|
#endif
|
|
|
|
|
2023-12-12 11:43:21 +01:00
|
|
|
#if LV_USE_DRAW_DAVE2D
|
|
|
|
lv_draw_dave2d_init();
|
|
|
|
#endif
|
|
|
|
|
2023-11-18 15:33:58 +01:00
|
|
|
#if LV_USE_DRAW_SDL
|
|
|
|
lv_draw_sdl_init();
|
|
|
|
#endif
|
|
|
|
|
2024-01-14 23:35:35 +08:00
|
|
|
#if LV_USE_WINDOWS
|
|
|
|
lv_windows_platform_init();
|
|
|
|
#endif
|
|
|
|
|
2023-07-05 13:05:19 +02:00
|
|
|
_lv_obj_style_init();
|
|
|
|
|
|
|
|
/*Initialize the screen refresh system*/
|
|
|
|
_lv_refr_init();
|
|
|
|
|
|
|
|
#if LV_USE_SYSMON
|
|
|
|
_lv_sysmon_builtin_init();
|
|
|
|
#endif
|
|
|
|
|
2024-03-22 10:51:03 +08:00
|
|
|
_lv_image_decoder_init(LV_CACHE_DEF_SIZE, LV_IMAGE_HEADER_CACHE_DEF_CNT);
|
2023-11-20 04:53:40 +08:00
|
|
|
lv_bin_decoder_init(); /*LVGL built-in binary image decoder*/
|
2023-07-05 13:05:19 +02:00
|
|
|
|
2023-12-18 21:17:42 +08:00
|
|
|
#if LV_USE_DRAW_VG_LITE
|
|
|
|
lv_draw_vg_lite_init();
|
|
|
|
#endif
|
|
|
|
|
2023-07-05 13:05:19 +02:00
|
|
|
/*Test if the IDE has UTF-8 encoding*/
|
|
|
|
const char * txt = "Á";
|
|
|
|
|
|
|
|
uint8_t * txt_u8 = (uint8_t *)txt;
|
|
|
|
if(txt_u8[0] != 0xc3 || txt_u8[1] != 0x81 || txt_u8[2] != 0x00) {
|
|
|
|
LV_LOG_WARN("The strings have no UTF-8 encoding. Non-ASCII characters won't be displayed.");
|
|
|
|
}
|
|
|
|
|
2023-10-22 06:39:43 +02:00
|
|
|
uint32_t endianness_test = 0x11223344;
|
|
|
|
uint8_t * endianness_test_p = (uint8_t *) &endianness_test;
|
|
|
|
bool big_endian = endianness_test_p[0] == 0x11;
|
2023-07-05 13:05:19 +02:00
|
|
|
|
|
|
|
if(big_endian) {
|
|
|
|
LV_ASSERT_MSG(LV_BIG_ENDIAN_SYSTEM == 1,
|
|
|
|
"It's a big endian system but LV_BIG_ENDIAN_SYSTEM is not enabled in lv_conf.h");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
LV_ASSERT_MSG(LV_BIG_ENDIAN_SYSTEM == 0,
|
|
|
|
"It's a little endian system but LV_BIG_ENDIAN_SYSTEM is enabled in lv_conf.h");
|
|
|
|
}
|
|
|
|
|
|
|
|
#if LV_USE_ASSERT_MEM_INTEGRITY
|
|
|
|
LV_LOG_WARN("Memory integrity checks are enabled via LV_USE_ASSERT_MEM_INTEGRITY which makes LVGL much slower");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LV_USE_ASSERT_OBJ
|
|
|
|
LV_LOG_WARN("Object sanity checks are enabled via LV_USE_ASSERT_OBJ which makes LVGL much slower");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LV_USE_ASSERT_STYLE
|
|
|
|
LV_LOG_WARN("Style sanity checks are enabled that uses more RAM");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LV_LOG_LEVEL == LV_LOG_LEVEL_TRACE
|
|
|
|
LV_LOG_WARN("Log level is set to 'Trace' which makes LVGL much slower");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LV_USE_FS_FATFS != '\0'
|
|
|
|
lv_fs_fatfs_init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LV_USE_FS_STDIO != '\0'
|
|
|
|
lv_fs_stdio_init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LV_USE_FS_POSIX != '\0'
|
|
|
|
lv_fs_posix_init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LV_USE_FS_WIN32 != '\0'
|
|
|
|
lv_fs_win32_init();
|
|
|
|
#endif
|
|
|
|
|
2023-08-31 13:00:26 +02:00
|
|
|
#if LV_USE_FS_MEMFS
|
|
|
|
lv_fs_memfs_init();
|
|
|
|
#endif
|
|
|
|
|
2024-02-24 16:10:02 +01:00
|
|
|
#if LV_USE_FS_LITTLEFS
|
|
|
|
lv_fs_littlefs_init();
|
|
|
|
#endif
|
|
|
|
|
2024-03-20 13:51:20 +01:00
|
|
|
#if LV_USE_FS_ARDUINO_ESP_LITTLEFS
|
|
|
|
lv_fs_arduino_esp_littlefs_init();
|
|
|
|
#endif
|
|
|
|
|
2024-04-18 15:06:17 +02:00
|
|
|
#if LV_USE_FS_ARDUINO_SD
|
|
|
|
lv_fs_arduino_sd_init();
|
|
|
|
#endif
|
|
|
|
|
2023-09-20 16:30:04 +08:00
|
|
|
#if LV_USE_LODEPNG
|
|
|
|
lv_lodepng_init();
|
2023-07-05 13:05:19 +02:00
|
|
|
#endif
|
|
|
|
|
2023-09-25 16:28:35 +08:00
|
|
|
#if LV_USE_LIBPNG
|
|
|
|
lv_libpng_init();
|
|
|
|
#endif
|
|
|
|
|
2023-09-20 16:38:47 +08:00
|
|
|
#if LV_USE_TJPGD
|
|
|
|
lv_tjpgd_init();
|
2023-07-05 13:05:19 +02:00
|
|
|
#endif
|
|
|
|
|
2023-09-22 16:43:59 +08:00
|
|
|
#if LV_USE_LIBJPEG_TURBO
|
|
|
|
lv_libjpeg_turbo_init();
|
|
|
|
#endif
|
|
|
|
|
2023-07-05 13:05:19 +02:00
|
|
|
#if LV_USE_BMP
|
|
|
|
lv_bmp_init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*Make FFMPEG last because the last converter will be checked first and
|
|
|
|
*it's superior to any other */
|
|
|
|
#if LV_USE_FFMPEG
|
|
|
|
lv_ffmpeg_init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LV_USE_FREETYPE
|
|
|
|
/*Init freetype library*/
|
2024-03-15 12:41:03 +08:00
|
|
|
lv_freetype_init(LV_FREETYPE_CACHE_FT_GLYPH_CNT);
|
2023-07-05 13:05:19 +02:00
|
|
|
#endif
|
|
|
|
|
2023-12-25 11:37:59 +08:00
|
|
|
#if LV_USE_TINY_TTF
|
|
|
|
lv_tiny_ttf_init();
|
|
|
|
#endif
|
|
|
|
|
2023-07-05 13:05:19 +02:00
|
|
|
lv_initialized = true;
|
|
|
|
|
|
|
|
LV_LOG_TRACE("finished");
|
|
|
|
}
|
|
|
|
|
|
|
|
void lv_deinit(void)
|
|
|
|
{
|
2023-10-11 04:28:17 +08:00
|
|
|
/*Do nothing if already deinit*/
|
|
|
|
if(!lv_initialized) {
|
|
|
|
LV_LOG_WARN("lv_deinit: already deinit!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-11-30 13:36:55 +01:00
|
|
|
if(lv_deinit_in_progress) return;
|
|
|
|
|
2023-11-21 20:12:13 +01:00
|
|
|
lv_deinit_in_progress = true;
|
|
|
|
|
2023-08-19 01:42:37 +02:00
|
|
|
#if LV_USE_SYSMON
|
|
|
|
_lv_sysmon_builtin_deinit();
|
|
|
|
#endif
|
2023-07-05 13:05:19 +02:00
|
|
|
|
2023-09-18 22:57:30 +02:00
|
|
|
lv_display_set_default(NULL);
|
2023-07-05 13:05:19 +02:00
|
|
|
|
2023-11-13 15:23:30 +08:00
|
|
|
_lv_cleanup_devices(LV_GLOBAL_DEFAULT());
|
|
|
|
|
2023-08-19 01:42:37 +02:00
|
|
|
#if LV_USE_SPAN != 0
|
|
|
|
lv_span_stack_deinit();
|
|
|
|
#endif
|
|
|
|
|
2023-11-09 18:37:33 +08:00
|
|
|
#if LV_USE_DRAW_SW
|
|
|
|
lv_draw_sw_deinit();
|
|
|
|
#endif
|
|
|
|
|
2023-08-19 01:42:37 +02:00
|
|
|
#if LV_USE_FREETYPE
|
|
|
|
lv_freetype_uninit();
|
|
|
|
#endif
|
|
|
|
|
2023-12-25 11:37:59 +08:00
|
|
|
#if LV_USE_TINY_TTF
|
|
|
|
lv_tiny_ttf_deinit();
|
|
|
|
#endif
|
|
|
|
|
2023-08-19 01:42:37 +02:00
|
|
|
#if LV_USE_THEME_DEFAULT
|
|
|
|
lv_theme_default_deinit();
|
|
|
|
#endif
|
|
|
|
|
2023-12-15 09:12:54 +01:00
|
|
|
#if LV_USE_THEME_SIMPLE
|
|
|
|
lv_theme_simple_deinit();
|
2023-08-19 01:42:37 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LV_USE_THEME_MONO
|
|
|
|
lv_theme_mono_deinit();
|
|
|
|
#endif
|
|
|
|
|
2023-11-06 21:55:52 +08:00
|
|
|
_lv_image_decoder_deinit();
|
|
|
|
|
|
|
|
_lv_refr_deinit();
|
|
|
|
|
|
|
|
_lv_obj_style_deinit();
|
|
|
|
|
|
|
|
#if LV_USE_DRAW_PXP
|
|
|
|
lv_draw_pxp_deinit();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LV_USE_DRAW_VGLITE
|
|
|
|
lv_draw_vglite_deinit();
|
|
|
|
#endif
|
|
|
|
|
2023-12-18 21:17:42 +08:00
|
|
|
#if LV_USE_DRAW_VG_LITE
|
|
|
|
lv_draw_vg_lite_deinit();
|
|
|
|
#endif
|
|
|
|
|
2023-11-06 21:55:52 +08:00
|
|
|
#if LV_USE_DRAW_SW
|
|
|
|
lv_draw_sw_deinit();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
lv_draw_deinit();
|
|
|
|
|
|
|
|
_lv_group_deinit();
|
|
|
|
|
|
|
|
_lv_anim_core_deinit();
|
|
|
|
|
|
|
|
_lv_layout_deinit();
|
|
|
|
|
|
|
|
_lv_fs_deinit();
|
|
|
|
|
|
|
|
_lv_timer_core_deinit();
|
|
|
|
|
|
|
|
#if LV_USE_PROFILER && LV_USE_PROFILER_BUILTIN
|
|
|
|
lv_profiler_builtin_uninit();
|
2023-07-05 13:05:19 +02:00
|
|
|
#endif
|
2023-09-25 16:58:36 +08:00
|
|
|
|
|
|
|
#if LV_USE_OBJ_ID_BUILTIN
|
|
|
|
lv_objid_builtin_destroy();
|
|
|
|
#endif
|
2023-11-06 21:55:52 +08:00
|
|
|
|
|
|
|
lv_mem_deinit();
|
|
|
|
|
2023-11-13 15:23:30 +08:00
|
|
|
lv_initialized = false;
|
|
|
|
|
|
|
|
LV_LOG_INFO("lv_deinit done");
|
|
|
|
|
2023-11-06 21:55:52 +08:00
|
|
|
#if LV_USE_LOG
|
|
|
|
lv_log_register_print_cb(NULL);
|
|
|
|
#endif
|
|
|
|
|
2023-10-11 04:28:17 +08:00
|
|
|
}
|
|
|
|
|
2023-07-05 13:05:19 +02:00
|
|
|
/**********************
|
|
|
|
* STATIC FUNCTIONS
|
|
|
|
**********************/
|