From 9ece84de16b3829c97cbcd649e4b15f41d876fda Mon Sep 17 00:00:00 2001 From: "Jianting (Meco) Man" <920369182@qq.com> Date: Mon, 18 Oct 2021 07:55:20 -0500 Subject: [PATCH] feat(rt-thread): implement rt-thread sconscirpt (#2674) --- rt-thread/SConscript | 60 +++++++++++++++++--- rt-thread/lv_rt_thread_conf.h | 104 ++++++++++++++++++++++++++++++++++ rt-thread/lv_rt_thread_port.c | 32 +++++++++++ src/lv_conf_kconfig.h | 2 + 4 files changed, 191 insertions(+), 7 deletions(-) create mode 100644 rt-thread/lv_rt_thread_conf.h create mode 100644 rt-thread/lv_rt_thread_port.c diff --git a/rt-thread/SConscript b/rt-thread/SConscript index 4c815c49b..0e45f1d16 100644 --- a/rt-thread/SConscript +++ b/rt-thread/SConscript @@ -1,15 +1,61 @@ -# RT-Thread building script for bridge - -import os from building import * +import rtconfig +import os +import shutil +# get current dir path cwd = GetCurrentDir() -objs = [] -list = os.listdir(cwd) +src = [] +inc = [] +LOCAL_CCFLAGS = '' + +lvgl_cwd = cwd + '/../' +lvgl_src_cwd = lvgl_cwd + 'src/' + +src = src + Glob('*.c') +inc = inc + [cwd] +inc = inc + [lvgl_src_cwd] + +for root, dirs, files in os.walk(lvgl_src_cwd): + for dir in dirs: + src = src + Glob(os.path.join(root,dir,'*.c')) + inc = inc + [os.path.join(root,dir)] + +if rtconfig.CROSS_TOOL == 'gcc': + LOCAL_CCFLAGS += ' -std=c99' +elif rtconfig.CROSS_TOOL == 'keil': + LOCAL_CCFLAGS += ' --c99 --gnu -g -W' + +group = DefineGroup('LVGL', src, depend = ['PKG_USING_LVGL'], CPPPATH = inc, LOCAL_CCFLAGS = LOCAL_CCFLAGS) + +list = os.listdir(cwd) for d in list: path = os.path.join(cwd, d) if os.path.isfile(os.path.join(path, 'SConscript')): - objs = objs + SConscript(os.path.join(d, 'SConscript')) + group = group + SConscript(os.path.join(d, 'SConscript')) -Return('objs') +# +# try: +# shutil.rmtree(os.path.join(lvgl_cwd, '.github')) +# shutil.rmtree(os.path.join(lvgl_cwd, 'docs')) +# shutil.rmtree(os.path.join(lvgl_cwd, 'scripts')) +# shutil.rmtree(os.path.join(lvgl_cwd, 'tests')) +# shutil.rmtree(os.path.join(lvgl_cwd, 'zephyr')) +# os.remove(os.path.join(lvgl_cwd, '.codecov.yml')) +# os.remove(os.path.join(lvgl_cwd, '.editorconfig')) +# os.remove(os.path.join(lvgl_cwd, '.gitignore')) +# os.remove(os.path.join(lvgl_cwd, '.gitmodules')) +# os.remove(os.path.join(lvgl_cwd, 'CMakeLists.txt')) +# os.remove(os.path.join(lvgl_cwd, 'component.mk')) +# os.remove(os.path.join(lvgl_cwd, 'idf_component.yml')) +# os.remove(os.path.join(lvgl_cwd, 'Kconfig')) +# os.remove(os.path.join(lvgl_cwd, 'library.json')) +# os.remove(os.path.join(lvgl_cwd, 'library.properties')) +# os.remove(os.path.join(lvgl_cwd, 'lv_conf_template.h')) +# os.remove(os.path.join(lvgl_cwd, 'lvgl.mk')) +# except: +# pass +# + +Return('group') diff --git a/rt-thread/lv_rt_thread_conf.h b/rt-thread/lv_rt_thread_conf.h new file mode 100644 index 000000000..4d85e584c --- /dev/null +++ b/rt-thread/lv_rt_thread_conf.h @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: MIT + * + * Change Logs: + * Date Author Notes + * 2021-10-15 Meco Man The first version + */ + +#ifndef LV_RT_THREAD_CONF_H +#define LV_RT_THREAD_CONF_H + +#ifdef __RTTHREAD__ + +#define LV_RTTHREAD_INCLUDE +#include LV_RTTHREAD_INCLUDE + +/*==================== + COLOR SETTINGS + *====================*/ + +#ifdef PKG_LVGL_ENABLE_COLOR_16_SWAP +#define LV_COLOR_16_SWAP 1 +#else +#define LV_COLOR_16_SWAP 0 +#endif + +/*========================= + MEMORY SETTINGS + *=========================*/ + +#ifdef RT_USING_HEAP +/*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/ +# define LV_MEM_CUSTOM 1 +# define LV_MEM_CUSTOM_INCLUDE LV_RTTHREAD_INCLUDE +# define LV_MEM_CUSTOM_ALLOC rt_malloc +# define LV_MEM_CUSTOM_FREE rt_free +# define LV_MEM_CUSTOM_REALLOC rt_realloc +#endif + +/*==================== + HAL SETTINGS + *====================*/ + +/*Use a custom tick source that tells the elapsed time in milliseconds. + *It removes the need to manually update the tick with `lv_tick_inc()`)*/ +#define LV_TICK_CUSTOM 1 +#define LV_TICK_CUSTOM_INCLUDE LV_RTTHREAD_INCLUDE +#define LV_TICK_CUSTOM_SYS_TIME_EXPR (rt_tick_get_millisecond()) /*Expression evaluating to current system time in ms*/ + +/*======================= + * FEATURE CONFIGURATION + *=======================*/ + +/*------------- + * Logging + *-----------*/ + +/*Enable the log module*/ +#ifdef PKG_LVGL_ENABLE_LOG +# define LV_USE_LOG 1 +# define LV_LOG_PRINTF 0 +#else +# define LV_USE_LOG 0 +#endif + +/*------------- + * Asserts + *-----------*/ + +#define LV_ASSERT_HANDLER_INCLUDE LV_RTTHREAD_INCLUDE +#define LV_ASSERT_HANDLER RT_ASSERT(0); + +/*------------- + * Others + *-----------*/ + +/*Change the built in (v)snprintf functions*/ +#define LV_SPRINTF_CUSTOM 1 +#define LV_SPRINTF_INCLUDE LV_RTTHREAD_INCLUDE +#define lv_snprintf rt_snprintf +#define lv_vsnprintf rt_vsnprintf +#define LV_SPRINTF_USE_FLOAT 0 + +/*===================== + * COMPILER SETTINGS + *====================*/ + +/*For big endian systems set to 1*/ +#ifdef RT_USING_BIG_ENDIAN +# define LV_BIG_ENDIAN_SYSTEM 1 +#else +# define LV_BIG_ENDIAN_SYSTEM 0 +#endif + +/*Will be added where memories needs to be aligned*/ +#define LV_ATTRIBUTE_MEM_ALIGN ALIGN(4) + +/*--END OF LV_RT_THREAD_CONF_H--*/ + +#endif /*__RTTHREAD__*/ + +#endif /*LV_CONF_H*/ diff --git a/rt-thread/lv_rt_thread_port.c b/rt-thread/lv_rt_thread_port.c new file mode 100644 index 000000000..dcebedba2 --- /dev/null +++ b/rt-thread/lv_rt_thread_port.c @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: MIT + * + * Change Logs: + * Date Author Notes + * 2021-10-18 Meco Man The first version + */ + +#include +#include +#define DBG_TAG "LVGL" +#define DBG_LVL DBG_INFO +#include + +#if LV_USE_LOG && LV_LOG_PRINTF +static void lv_rt_log(const char *buf) +{ + LOG_I(buf); +} +#endif + +static int lv_port_init(void) +{ +#if LV_USE_LOG && LV_LOG_PRINTF + lv_log_register_print_cb(lv_rt_log); +#endif + + return 0; +} +INIT_COMPONENT_EXPORT(lv_port_init); diff --git a/src/lv_conf_kconfig.h b/src/lv_conf_kconfig.h index 2dfef685e..d05f75903 100644 --- a/src/lv_conf_kconfig.h +++ b/src/lv_conf_kconfig.h @@ -18,6 +18,8 @@ extern "C" { # ifdef __NuttX__ # include +# elif defined(__RTTHREAD__) +# define LV_CONF_SKIP # endif #endif /*LV_CONF_KCONFIG_EXTERNAL_INCLUDE*/