init lvgl code

This commit is contained in:
ShallowGreen123
2022-08-07 15:24:16 +08:00
parent d5ebbd8eb9
commit 77ddc13604
1963 changed files with 719922 additions and 318 deletions

View File

@@ -0,0 +1,69 @@
from building import *
import rtconfig
import os
src = []
inc = []
group = []
cwd = GetCurrentDir() # get current dir path
port_src = Glob('*.c')
port_inc = [cwd]
group = group + DefineGroup('LVGL-port', port_src, depend = ['PKG_USING_LVGL'], CPPPATH = port_inc)
# check if .h or .hpp files exsit
def check_h_hpp_exsit(path):
file_dirs = os.listdir(path)
for file_dir in file_dirs:
if os.path.splitext(file_dir)[1] in ['.h', '.hpp']:
return True
return False
lvgl_cwd = cwd + '/../../'
lvgl_src_cwd = lvgl_cwd + 'src/'
inc = inc + [lvgl_src_cwd]
for root, dirs, files in os.walk(lvgl_src_cwd):
for dir in dirs:
current_path = os.path.join(root, dir)
src = src + Glob(os.path.join(current_path,'*.c')) # add all .c files
if check_h_hpp_exsit(current_path): # add .h and .hpp path
inc = inc + [current_path]
if GetDepend('PKG_USING_LVGL_EXAMPLES'):
lvgl_src_cwd = lvgl_cwd + 'examples/'
inc = inc + [lvgl_src_cwd]
for root, dirs, files in os.walk(lvgl_src_cwd):
for dir in dirs:
current_path = os.path.join(root, dir)
src = src + Glob(os.path.join(current_path,'*.c'))
if check_h_hpp_exsit(current_path):
inc = inc + [current_path]
if GetDepend('PKG_USING_LVGL_DEMOS'):
lvgl_src_cwd = lvgl_cwd + 'demos/'
inc = inc + [lvgl_src_cwd]
for root, dirs, files in os.walk(lvgl_src_cwd):
for dir in dirs:
current_path = os.path.join(root, dir)
src = src + Glob(os.path.join(current_path,'*.c'))
if check_h_hpp_exsit(current_path):
inc = inc + [current_path]
LOCAL_CFLAGS = ''
if rtconfig.PLATFORM == 'gcc' or rtconfig.PLATFORM == 'armclang': # GCC or Keil AC6
LOCAL_CFLAGS += ' -std=c99'
elif rtconfig.PLATFORM == 'armcc': # Keil AC5
LOCAL_CFLAGS += ' --c99 --gnu'
group = group + DefineGroup('LVGL', src, depend = ['PKG_USING_LVGL'], CPPPATH = inc, LOCAL_CFLAGS = LOCAL_CFLAGS)
list = os.listdir(cwd)
for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
group = group + SConscript(os.path.join(d, 'SConscript'))
Return('group')

View File

@@ -0,0 +1,94 @@
/*
* 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 <rtthread.h>
#include LV_RTTHREAD_INCLUDE
/*=========================
MEMORY SETTINGS
*=========================*/
#ifdef RT_USING_HEAP
# 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
*====================*/
#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
*-----------*/
#ifdef PKG_LVGL_ENABLE_LOG
# define LV_USE_LOG 1
#else
# define LV_USE_LOG 0
#endif
/*-------------
* Asserts
*-----------*/
#define LV_ASSERT_HANDLER_INCLUDE LV_RTTHREAD_INCLUDE
#define LV_ASSERT_HANDLER RT_ASSERT(0);
/*-------------
* Others
*-----------*/
#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
*====================*/
#ifdef ARCH_CPU_BIG_ENDIAN
# define LV_BIG_ENDIAN_SYSTEM 1
#else
# define LV_BIG_ENDIAN_SYSTEM 0
#endif
#define LV_ATTRIBUTE_MEM_ALIGN ALIGN(4)
/*==================
* EXAMPLES
*==================*/
#ifdef PKG_USING_LVGL_EXAMPLES
# define LV_BUILD_EXAMPLES 1
#endif
/*--END OF LV_RT_THREAD_CONF_H--*/
#endif /*__RTTHREAD__*/
#endif /*LV_CONF_H*/

View File

@@ -0,0 +1,44 @@
/*
* 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
*/
#ifdef __RTTHREAD__
#include <rtthread.h>
#define DBG_TAG "LVGL"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
#include <lvgl.h>
#include <lv_port_disp.h>
#include <lv_port_indev.h>
#if LV_USE_LOG
static void lv_rt_log(const char *buf)
{
LOG_I(buf);
}
#endif
static int lv_port_init(void)
{
#if LV_USE_LOG
lv_log_register_print_cb(lv_rt_log);
#endif
lv_init();
lv_port_disp_init();
lv_port_indev_init();
return 0;
}
INIT_COMPONENT_EXPORT(lv_port_init);
#endif /*__RTTHREAD__*/