init Files
This commit is contained in:
70
libraries/lvgl/env_support/rt-thread/SConscript
Normal file
70
libraries/lvgl/env_support/rt-thread/SConscript
Normal file
@@ -0,0 +1,70 @@
|
||||
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 exists
|
||||
def check_h_hpp_exists(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]
|
||||
src = src + Glob(os.path.join(lvgl_src_cwd,'*.c'))
|
||||
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_exists(current_path): # add .h and .hpp path
|
||||
inc = inc + [current_path]
|
||||
|
||||
|
||||
if GetDepend('PKG_LVGL_USING_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_exists(current_path):
|
||||
inc = inc + [current_path]
|
||||
|
||||
if GetDepend('PKG_LVGL_USING_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_exists(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')
|
||||
82
libraries/lvgl/env_support/rt-thread/lv_rt_thread_conf.h
Normal file
82
libraries/lvgl/env_support/rt-thread/lv_rt_thread_conf.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
/*=========================
|
||||
STDLIB WRAPPER SETTINGS
|
||||
*=========================*/
|
||||
|
||||
#ifdef RT_USING_HEAP
|
||||
#define LV_USE_STDLIB_MALLOC LV_STDLIB_RTTHREAD
|
||||
#endif
|
||||
|
||||
#define LV_USE_STDLIB_STRING LV_STDLIB_RTTHREAD
|
||||
|
||||
#if LV_USE_FLOAT == 0
|
||||
#define LV_USE_STDLIB_SPRINTF LV_STDLIB_RTTHREAD
|
||||
#endif
|
||||
|
||||
/*=========================
|
||||
CPU usage
|
||||
*=========================*/
|
||||
|
||||
#ifdef PKG_USING_CPU_USAGE
|
||||
#define LV_SYSMON_GET_IDLE lv_timer_os_get_idle
|
||||
#endif /* PKG_USING_CPU_USAGE */
|
||||
|
||||
/*=================
|
||||
* OPERATING SYSTEM
|
||||
*=================*/
|
||||
|
||||
#define LV_USE_OS LV_OS_RTTHREAD
|
||||
|
||||
/*-------------
|
||||
* Asserts
|
||||
*-----------*/
|
||||
|
||||
#define LV_ASSERT_HANDLER_INCLUDE LV_RTTHREAD_INCLUDE
|
||||
#define LV_ASSERT_HANDLER RT_ASSERT(0);
|
||||
|
||||
/*=====================
|
||||
* COMPILER SETTINGS
|
||||
*====================*/
|
||||
|
||||
#ifdef ARCH_CPU_BIG_ENDIAN
|
||||
#define LV_BIG_ENDIAN_SYSTEM 1
|
||||
#else
|
||||
#define LV_BIG_ENDIAN_SYSTEM 0
|
||||
#endif
|
||||
|
||||
#ifdef rt_align /* >= RT-Thread v5.0.0 */
|
||||
#define LV_ATTRIBUTE_MEM_ALIGN rt_align(RT_ALIGN_SIZE)
|
||||
#else
|
||||
#define LV_ATTRIBUTE_MEM_ALIGN ALIGN(RT_ALIGN_SIZE)
|
||||
#endif
|
||||
|
||||
/*==================
|
||||
* EXAMPLES
|
||||
*==================*/
|
||||
|
||||
#ifdef PKG_LVGL_USING_EXAMPLES
|
||||
#define LV_BUILD_EXAMPLES 1
|
||||
#endif
|
||||
|
||||
/*--END OF LV_RT_THREAD_CONF_H--*/
|
||||
|
||||
#endif /*__RTTHREAD__*/
|
||||
|
||||
#endif /*LV_CONF_H*/
|
||||
105
libraries/lvgl/env_support/rt-thread/lv_rt_thread_port.c
Normal file
105
libraries/lvgl/env_support/rt-thread/lv_rt_thread_port.c
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* 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
|
||||
* 2022-05-10 Meco Man improve rt-thread initialization process
|
||||
*/
|
||||
|
||||
#ifdef __RTTHREAD__
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <rtthread.h>
|
||||
#ifdef PKG_USING_CPU_USAGE
|
||||
#include "cpu_usage.h"
|
||||
#endif /* PKG_USING_CPU_USAGE */
|
||||
|
||||
#define DBG_TAG "LVGL"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <rtdbg.h>
|
||||
|
||||
#ifndef PKG_LVGL_THREAD_STACK_SIZE
|
||||
#define PKG_LVGL_THREAD_STACK_SIZE 4096
|
||||
#endif /* PKG_LVGL_THREAD_STACK_SIZE */
|
||||
|
||||
#ifndef PKG_LVGL_THREAD_PRIO
|
||||
#define PKG_LVGL_THREAD_PRIO (RT_THREAD_PRIORITY_MAX*2/3)
|
||||
#endif /* PKG_LVGL_THREAD_PRIO */
|
||||
|
||||
#ifndef PKG_LVGL_DISP_REFR_PERIOD
|
||||
#define PKG_LVGL_DISP_REFR_PERIOD 33
|
||||
#endif /* PKG_LVGL_DISP_REFR_PERIOD */
|
||||
|
||||
extern void lv_port_disp_init(void);
|
||||
extern void lv_port_indev_init(void);
|
||||
extern void lv_user_gui_init(void);
|
||||
|
||||
static struct rt_thread lvgl_thread;
|
||||
|
||||
#ifdef rt_align
|
||||
rt_align(RT_ALIGN_SIZE)
|
||||
#else
|
||||
ALIGN(RT_ALIGN_SIZE)
|
||||
#endif
|
||||
static rt_uint8_t lvgl_thread_stack[PKG_LVGL_THREAD_STACK_SIZE];
|
||||
|
||||
#if LV_USE_LOG
|
||||
static void lv_rt_log(lv_log_level_t level, const char * buf)
|
||||
{
|
||||
(void) level;
|
||||
LOG_I(buf);
|
||||
}
|
||||
#endif /* LV_USE_LOG */
|
||||
|
||||
#ifdef PKG_USING_CPU_USAGE
|
||||
uint32_t lv_timer_os_get_idle(void)
|
||||
{
|
||||
return (100 - (uint32_t)cpu_load_average());
|
||||
}
|
||||
#endif /* PKG_USING_CPU_USAGE */
|
||||
|
||||
static void lvgl_thread_entry(void *parameter)
|
||||
{
|
||||
#if LV_USE_LOG
|
||||
lv_log_register_print_cb(lv_rt_log);
|
||||
#endif /* LV_USE_LOG */
|
||||
lv_init();
|
||||
lv_tick_set_cb(&rt_tick_get_millisecond);
|
||||
lv_port_disp_init();
|
||||
lv_port_indev_init();
|
||||
lv_user_gui_init();
|
||||
|
||||
|
||||
#ifdef PKG_USING_CPU_USAGE
|
||||
cpu_usage_init();
|
||||
#endif /* PKG_USING_CPU_USAGE */
|
||||
|
||||
/* handle the tasks of LVGL */
|
||||
while(1)
|
||||
{
|
||||
lv_timer_handler();
|
||||
rt_thread_mdelay(PKG_LVGL_DISP_REFR_PERIOD);
|
||||
}
|
||||
}
|
||||
|
||||
static int lvgl_thread_init(void)
|
||||
{
|
||||
rt_err_t err;
|
||||
|
||||
err = rt_thread_init(&lvgl_thread, "LVGL", lvgl_thread_entry, RT_NULL,
|
||||
&lvgl_thread_stack[0], sizeof(lvgl_thread_stack), PKG_LVGL_THREAD_PRIO, 10);
|
||||
if(err != RT_EOK)
|
||||
{
|
||||
LOG_E("Failed to create LVGL thread");
|
||||
return -1;
|
||||
}
|
||||
rt_thread_startup(&lvgl_thread);
|
||||
|
||||
return 0;
|
||||
}
|
||||
INIT_ENV_EXPORT(lvgl_thread_init);
|
||||
|
||||
#endif /*__RTTHREAD__*/
|
||||
@@ -0,0 +1,4 @@
|
||||
This folder is for LVGL SquareLine Studio
|
||||
|
||||
SquareLine Studio can automatically put the generated C files into `ui` folder, so that rt-thread will automatically detect them; or, as a user, you can move the generated C files into `ui` folder manually.
|
||||
|
||||
25
libraries/lvgl/env_support/rt-thread/squareline/SConscript
Normal file
25
libraries/lvgl/env_support/rt-thread/squareline/SConscript
Normal file
@@ -0,0 +1,25 @@
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c')
|
||||
inc = [cwd]
|
||||
|
||||
# check if .h or .hpp files exists
|
||||
def check_h_hpp_exists(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
|
||||
|
||||
sls_src_cwd = cwd
|
||||
for root, dirs, files in os.walk(sls_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_exists(current_path): # add .h and .hpp path
|
||||
inc = inc + [current_path]
|
||||
|
||||
group = DefineGroup('LVGL-SquareLine', src, depend = ['PKG_USING_LVGL_SQUARELINE'], CPPPATH = inc)
|
||||
|
||||
Return('group')
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2022, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2022-05-13 Meco Man First version
|
||||
*/
|
||||
|
||||
#ifdef __RTTHREAD__
|
||||
|
||||
void lv_user_gui_init(void)
|
||||
{
|
||||
extern void ui_init(void);
|
||||
ui_init();
|
||||
}
|
||||
|
||||
#endif /* __RTTHREAD__ */
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2022-11-20 Meco Man The first version
|
||||
*/
|
||||
|
||||
#ifdef __RTTHREAD__
|
||||
|
||||
#include "../../../../../lvgl.h" /* back to the root folder's lvgl.h */
|
||||
|
||||
#endif /* __RTTHREAD__ */
|
||||
Reference in New Issue
Block a user