mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-02-21 02:27:10 +08:00
[lvgl][stm32f407] 优化LVGL初始化流程
This commit is contained in:
parent
1b4f16f729
commit
6fe83d4a77
@ -12,5 +12,6 @@ for d in list:
|
|||||||
if os.path.isfile(os.path.join(path, 'SConscript')):
|
if os.path.isfile(os.path.join(path, 'SConscript')):
|
||||||
group = group + SConscript(os.path.join(d, 'SConscript'))
|
group = group + SConscript(os.path.join(d, 'SConscript'))
|
||||||
|
|
||||||
group = group + DefineGroup('LVGL-port', src, depend = ['BSP_USING_LVGL'], CPPPATH = CPPPATH)
|
group = group + DefineGroup('LVGL-demo', src, depend = ['BSP_USING_LVGL', 'BSP_USING_LVGL_DEMO'], CPPPATH = CPPPATH)
|
||||||
|
|
||||||
Return('group')
|
Return('group')
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2021-10-17 Meco Man first version
|
||||||
|
* 2022-05-10 Meco Man improve rt-thread initialization process
|
||||||
|
*/
|
||||||
|
#include <lvgl.h>
|
||||||
|
|
||||||
|
void lv_user_gui_init(void)
|
||||||
|
{
|
||||||
|
/* display demo; you may replace with your LVGL application at here */
|
||||||
|
extern void lv_demo_calendar(void);
|
||||||
|
lv_demo_calendar();
|
||||||
|
}
|
@ -1,5 +1,4 @@
|
|||||||
#include <lvgl.h>
|
#include <lvgl.h>
|
||||||
#include "lv_demo_calendar.h"
|
|
||||||
#include <board.h>
|
#include <board.h>
|
||||||
#include <drv_lcd.h>
|
#include <drv_lcd.h>
|
||||||
|
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
#ifndef __LV_DEMO_CALENDAR_H__
|
|
||||||
#define __LV_DEMO_CALENDAR_H__
|
|
||||||
|
|
||||||
void lv_demo_calendar(void);
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* Change Logs:
|
|
||||||
* Date Author Notes
|
|
||||||
* 2021-10-17 Meco Man First version
|
|
||||||
*/
|
|
||||||
#include <rtthread.h>
|
|
||||||
#include <lvgl.h>
|
|
||||||
#include <lv_port_indev.h>
|
|
||||||
#include <lv_demo_calendar.h>
|
|
||||||
#define DBG_TAG "LVGL.demo"
|
|
||||||
#define DBG_LVL DBG_INFO
|
|
||||||
#include <rtdbg.h>
|
|
||||||
|
|
||||||
#ifndef LV_THREAD_STACK_SIZE
|
|
||||||
#define LV_THREAD_STACK_SIZE 4096
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef LV_THREAD_PRIO
|
|
||||||
#define LV_THREAD_PRIO (RT_THREAD_PRIORITY_MAX*2/3)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void lvgl_thread(void *parameter)
|
|
||||||
{
|
|
||||||
/*assign buttons to coordinates*/
|
|
||||||
const lv_point_t points_array[] = {{200,35},{0,0},{70,35},{0,0}};
|
|
||||||
lv_indev_set_button_points(button_indev, points_array);
|
|
||||||
|
|
||||||
/* display demo; you may replace with your LVGL application at here */
|
|
||||||
#ifdef PKG_USING_LV_MUSIC_DEMO
|
|
||||||
extern void lv_demo_music(void);
|
|
||||||
lv_demo_music();
|
|
||||||
#else
|
|
||||||
lv_demo_calendar();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* handle the tasks of LVGL */
|
|
||||||
while(1)
|
|
||||||
{
|
|
||||||
lv_task_handler();
|
|
||||||
rt_thread_mdelay(10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int lvgl_demo_init(void)
|
|
||||||
{
|
|
||||||
rt_thread_t tid;
|
|
||||||
rt_device_t lcd = RT_NULL;
|
|
||||||
|
|
||||||
lcd = rt_device_find("lcd");
|
|
||||||
rt_device_init(lcd);
|
|
||||||
|
|
||||||
tid = rt_thread_create("LVGL", lvgl_thread, RT_NULL, LV_THREAD_STACK_SIZE, LV_THREAD_PRIO, 0);
|
|
||||||
if(tid == RT_NULL)
|
|
||||||
{
|
|
||||||
LOG_E("Fail to create 'LVGL' thread");
|
|
||||||
}
|
|
||||||
rt_thread_startup(tid);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
INIT_APP_EXPORT(lvgl_demo_init);
|
|
@ -1,23 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* Change Logs:
|
|
||||||
* Date Author Notes
|
|
||||||
* 2021-10-18 Meco Man The first version
|
|
||||||
*/
|
|
||||||
#ifndef LV_PORT_DISP_H
|
|
||||||
#define LV_PORT_DISP_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void lv_port_disp_init(void);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
} /*extern "C"*/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -13,6 +13,8 @@
|
|||||||
#include <board.h>
|
#include <board.h>
|
||||||
#include <drv_lcd.h>
|
#include <drv_lcd.h>
|
||||||
|
|
||||||
|
lv_indev_t *touch_indev;
|
||||||
|
|
||||||
static lv_indev_state_t last_state = LV_INDEV_STATE_REL;
|
static lv_indev_state_t last_state = LV_INDEV_STATE_REL;
|
||||||
static rt_int16_t last_x = 0;
|
static rt_int16_t last_x = 0;
|
||||||
static rt_int16_t last_y = 0;
|
static rt_int16_t last_y = 0;
|
||||||
@ -31,8 +33,6 @@ void lv_port_indev_input(rt_int16_t x, rt_int16_t y, lv_indev_state_t state)
|
|||||||
last_y = x;
|
last_y = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
lv_indev_t * button_indev;
|
|
||||||
|
|
||||||
void lv_port_indev_init(void)
|
void lv_port_indev_init(void)
|
||||||
{
|
{
|
||||||
static lv_indev_drv_t indev_drv;
|
static lv_indev_drv_t indev_drv;
|
||||||
@ -42,5 +42,5 @@ void lv_port_indev_init(void)
|
|||||||
indev_drv.read_cb = input_read;
|
indev_drv.read_cb = input_read;
|
||||||
|
|
||||||
/*Register the driver in LVGL and save the created input device object*/
|
/*Register the driver in LVGL and save the created input device object*/
|
||||||
button_indev = lv_indev_drv_register(&indev_drv);
|
touch_indev = lv_indev_drv_register(&indev_drv);
|
||||||
}
|
}
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* Change Logs:
|
|
||||||
* Date Author Notes
|
|
||||||
* 2021-10-18 Meco Man The first version
|
|
||||||
*/
|
|
||||||
#ifndef LV_PORT_INDEV_H
|
|
||||||
#define LV_PORT_INDEV_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <lv_hal_indev.h>
|
|
||||||
|
|
||||||
extern lv_indev_t * button_indev;
|
|
||||||
|
|
||||||
void lv_port_indev_init(void);
|
|
||||||
void lv_port_indev_input(rt_int16_t x, rt_int16_t y, lv_indev_state_t state);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
} /*extern "C"*/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -38,12 +38,12 @@ menu "Onboard Peripheral Drivers"
|
|||||||
select BSP_USING_FMC
|
select BSP_USING_FMC
|
||||||
default n
|
default n
|
||||||
|
|
||||||
config BSP_USING_MCU_LCD
|
config BSP_USING_ONBOARD_LCD
|
||||||
bool "Enable ATK LCD"
|
bool "Enable ATK LCD"
|
||||||
select BSP_USING_SRAM
|
select BSP_USING_SRAM
|
||||||
default n
|
default n
|
||||||
if BSP_USING_MCU_LCD
|
if BSP_USING_ONBOARD_LCD
|
||||||
config BSP_USING_MCU_LCD_TEST
|
config BSP_USING_ONBOARD_LCD_TEST
|
||||||
bool "Enable lcd fill test"
|
bool "Enable lcd fill test"
|
||||||
default y
|
default y
|
||||||
endif
|
endif
|
||||||
@ -60,11 +60,17 @@ menu "Onboard Peripheral Drivers"
|
|||||||
|
|
||||||
config BSP_USING_LVGL
|
config BSP_USING_LVGL
|
||||||
bool "Enable LVGL for LCD"
|
bool "Enable LVGL for LCD"
|
||||||
select BSP_USING_MCU_LCD
|
select BSP_USING_ONBOARD_LCD
|
||||||
select BSP_USING_TOUCH
|
select BSP_USING_TOUCH
|
||||||
select PKG_USING_LVGL
|
select PKG_USING_LVGL
|
||||||
default n
|
default n
|
||||||
|
|
||||||
|
if BSP_USING_LVGL
|
||||||
|
config BSP_USING_LVGL_DEMO
|
||||||
|
bool "Enable LVGL demo"
|
||||||
|
default n
|
||||||
|
endif
|
||||||
|
|
||||||
config BSP_USING_SPI_FLASH
|
config BSP_USING_SPI_FLASH
|
||||||
bool "Enable SPI FLASH (W25Q128 spi1)"
|
bool "Enable SPI FLASH (W25Q128 spi1)"
|
||||||
select BSP_USING_SPI
|
select BSP_USING_SPI
|
||||||
|
@ -29,7 +29,7 @@ if GetDepend(['BSP_USING_FS']):
|
|||||||
if GetDepend(['BSP_USING_SRAM']):
|
if GetDepend(['BSP_USING_SRAM']):
|
||||||
src += Glob('ports/drv_sram.c')
|
src += Glob('ports/drv_sram.c')
|
||||||
|
|
||||||
if GetDepend(['BSP_USING_MCU_LCD']):
|
if GetDepend(['BSP_USING_ONBOARD_LCD']):
|
||||||
src += Glob('ports/drv_lcd.c')
|
src += Glob('ports/drv_lcd.c')
|
||||||
|
|
||||||
if GetDepend(['BSP_USING_TOUCH']):
|
if GetDepend(['BSP_USING_TOUCH']):
|
||||||
|
@ -1945,7 +1945,7 @@ int drv_lcd_hw_init(void)
|
|||||||
}
|
}
|
||||||
INIT_DEVICE_EXPORT(drv_lcd_hw_init);
|
INIT_DEVICE_EXPORT(drv_lcd_hw_init);
|
||||||
|
|
||||||
#ifdef BSP_USING_MCU_LCD_TEST
|
#ifdef BSP_USING_ONBOARD_LCD_TEST
|
||||||
void lcd_auto_fill(void *para)
|
void lcd_auto_fill(void *para)
|
||||||
{
|
{
|
||||||
int num = (int)para;
|
int num = (int)para;
|
||||||
|
@ -8,9 +8,18 @@
|
|||||||
* 2018-02-08 Zhangyihong the first version
|
* 2018-02-08 Zhangyihong the first version
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <rtconfig.h>
|
||||||
|
|
||||||
|
#ifdef BSP_USING_TOUCH
|
||||||
#include "drv_touch.h"
|
#include "drv_touch.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#ifdef BSP_USING_TOUCH
|
|
||||||
|
#define DBG_ENABLE
|
||||||
|
#define DBG_SECTION_NAME "touch"
|
||||||
|
#define DBG_LEVEL DBG_INFO
|
||||||
|
#define DBG_COLOR
|
||||||
|
#include <rtdbg.h>
|
||||||
|
|
||||||
#ifdef PKG_USING_GUIENGINE
|
#ifdef PKG_USING_GUIENGINE
|
||||||
#include <rtgui/event.h>
|
#include <rtgui/event.h>
|
||||||
#include <rtgui/rtgui_server.h>
|
#include <rtgui/rtgui_server.h>
|
||||||
@ -18,20 +27,14 @@
|
|||||||
#include <littlevgl2rtt.h>
|
#include <littlevgl2rtt.h>
|
||||||
#elif defined(PKG_USING_LVGL)
|
#elif defined(PKG_USING_LVGL)
|
||||||
#include <lvgl.h>
|
#include <lvgl.h>
|
||||||
#include <lv_port_indev.h>
|
extern void lv_port_indev_input(rt_int16_t x, rt_int16_t y, lv_indev_state_t state);
|
||||||
static rt_bool_t touch_down = RT_FALSE;
|
static rt_bool_t touch_down = RT_FALSE;
|
||||||
#endif
|
#endif /* PKG_USING_GUIENGINE */
|
||||||
|
|
||||||
#define BSP_TOUCH_SAMPLE_HZ (50)
|
#define BSP_TOUCH_SAMPLE_HZ (50)
|
||||||
|
|
||||||
#define DBG_ENABLE
|
|
||||||
#define DBG_SECTION_NAME "TOUCH"
|
|
||||||
#define DBG_LEVEL DBG_INFO
|
|
||||||
#define DBG_COLOR
|
|
||||||
#include <rtdbg.h>
|
|
||||||
|
|
||||||
static rt_list_t driver_list;
|
static rt_list_t driver_list;
|
||||||
|
|
||||||
|
|
||||||
void rt_touch_drivers_register(touch_drv_t drv)
|
void rt_touch_drivers_register(touch_drv_t drv)
|
||||||
{
|
{
|
||||||
rt_list_insert_before(&driver_list, &drv->list);
|
rt_list_insert_before(&driver_list, &drv->list);
|
||||||
@ -44,7 +47,6 @@ static void post_down_event(rt_uint16_t x, rt_uint16_t y, rt_tick_t ts)
|
|||||||
|
|
||||||
emouse.parent.sender = RT_NULL;
|
emouse.parent.sender = RT_NULL;
|
||||||
emouse.wid = RT_NULL;
|
emouse.wid = RT_NULL;
|
||||||
|
|
||||||
emouse.parent.type = RTGUI_EVENT_MOUSE_BUTTON;
|
emouse.parent.type = RTGUI_EVENT_MOUSE_BUTTON;
|
||||||
emouse.button = RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_DOWN;
|
emouse.button = RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_DOWN;
|
||||||
emouse.x = x;
|
emouse.x = x;
|
||||||
@ -67,7 +69,6 @@ static void post_motion_event(rt_uint16_t x, rt_uint16_t y, rt_tick_t ts)
|
|||||||
|
|
||||||
emouse.parent.sender = RT_NULL;
|
emouse.parent.sender = RT_NULL;
|
||||||
emouse.wid = RT_NULL;
|
emouse.wid = RT_NULL;
|
||||||
|
|
||||||
emouse.button = RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_DOWN;
|
emouse.button = RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_DOWN;
|
||||||
emouse.parent.type = RTGUI_EVENT_MOUSE_MOTION;
|
emouse.parent.type = RTGUI_EVENT_MOUSE_MOTION;
|
||||||
emouse.x = x;
|
emouse.x = x;
|
||||||
@ -79,7 +80,7 @@ static void post_motion_event(rt_uint16_t x, rt_uint16_t y, rt_tick_t ts)
|
|||||||
littlevgl2rtt_send_input_event(x, y, LITTLEVGL2RTT_INPUT_MOVE);
|
littlevgl2rtt_send_input_event(x, y, LITTLEVGL2RTT_INPUT_MOVE);
|
||||||
#elif defined(PKG_USING_LVGL)
|
#elif defined(PKG_USING_LVGL)
|
||||||
lv_port_indev_input(x, y, (touch_down == RT_TRUE) ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL);
|
lv_port_indev_input(x, y, (touch_down == RT_TRUE) ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL);
|
||||||
#endif
|
#endif /* PKG_USING_GUIENGINE */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void post_up_event(rt_uint16_t x, rt_uint16_t y, rt_tick_t ts)
|
static void post_up_event(rt_uint16_t x, rt_uint16_t y, rt_tick_t ts)
|
||||||
@ -89,7 +90,6 @@ static void post_up_event(rt_uint16_t x, rt_uint16_t y, rt_tick_t ts)
|
|||||||
|
|
||||||
emouse.parent.sender = RT_NULL;
|
emouse.parent.sender = RT_NULL;
|
||||||
emouse.wid = RT_NULL;
|
emouse.wid = RT_NULL;
|
||||||
|
|
||||||
emouse.parent.type = RTGUI_EVENT_MOUSE_BUTTON;
|
emouse.parent.type = RTGUI_EVENT_MOUSE_BUTTON;
|
||||||
emouse.button = RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_UP;
|
emouse.button = RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_UP;
|
||||||
emouse.x = x;
|
emouse.x = x;
|
||||||
@ -102,7 +102,7 @@ static void post_up_event(rt_uint16_t x, rt_uint16_t y, rt_tick_t ts)
|
|||||||
#elif defined(PKG_USING_LVGL)
|
#elif defined(PKG_USING_LVGL)
|
||||||
touch_down = RT_FALSE;
|
touch_down = RT_FALSE;
|
||||||
lv_port_indev_input(x, y, (touch_down == RT_TRUE) ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL);
|
lv_port_indev_input(x, y, (touch_down == RT_TRUE) ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL);
|
||||||
#endif
|
#endif /* PKG_USING_GUIENGINE */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void touch_thread_entry(void *parameter)
|
static void touch_thread_entry(void *parameter)
|
||||||
@ -204,5 +204,4 @@ static int touc_bg_init(void)
|
|||||||
}
|
}
|
||||||
INIT_APP_EXPORT(touc_bg_init);
|
INIT_APP_EXPORT(touc_bg_init);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user