summaryrefslogtreecommitdiff
path: root/bsp
diff options
context:
space:
mode:
authorMeco Man <[email protected]>2022-05-11 13:14:41 -0400
committerguo <[email protected]>2022-05-12 10:10:11 +0800
commit6fe83d4a77f85e0d90ba43b43c8c71994423a57d (patch)
tree14f8169deacd0429ea4bb935675d816b48246fa0 /bsp
parent1b4f16f7292dc84dc2cfad660d2a2911a0c4c641 (diff)
[lvgl][stm32f407] 优化LVGL初始化流程
Diffstat (limited to 'bsp')
-rw-r--r--bsp/stm32/stm32f407-atk-explorer/applications/lvgl/demo/SConscript3
-rw-r--r--bsp/stm32/stm32f407-atk-explorer/applications/lvgl/demo/lv_demo.c18
-rw-r--r--bsp/stm32/stm32f407-atk-explorer/applications/lvgl/demo/lv_demo_calendar.c1
-rw-r--r--bsp/stm32/stm32f407-atk-explorer/applications/lvgl/demo/lv_demo_calendar.h6
-rw-r--r--bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_demo.c65
-rw-r--r--bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_port_disp.h23
-rw-r--r--bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_port_indev.c6
-rw-r--r--bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_port_indev.h28
-rw-r--r--bsp/stm32/stm32f407-atk-explorer/board/Kconfig14
-rw-r--r--bsp/stm32/stm32f407-atk-explorer/board/SConscript2
-rw-r--r--bsp/stm32/stm32f407-atk-explorer/board/ports/drv_lcd.c2
-rw-r--r--bsp/stm32/stm32f407-atk-explorer/board/ports/touch/drv_touch.c31
12 files changed, 50 insertions, 149 deletions
diff --git a/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/demo/SConscript b/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/demo/SConscript
index 79d9772177..9c1b6d1ebd 100644
--- a/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/demo/SConscript
+++ b/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/demo/SConscript
@@ -12,5 +12,6 @@ for d in list:
if os.path.isfile(os.path.join(path, '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')
diff --git a/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/demo/lv_demo.c b/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/demo/lv_demo.c
new file mode 100644
index 0000000000..0d2b0e17f0
--- /dev/null
+++ b/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/demo/lv_demo.c
@@ -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();
+}
diff --git a/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/demo/lv_demo_calendar.c b/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/demo/lv_demo_calendar.c
index 5a2e12ec45..e2a267271a 100644
--- a/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/demo/lv_demo_calendar.c
+++ b/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/demo/lv_demo_calendar.c
@@ -1,5 +1,4 @@
#include <lvgl.h>
-#include "lv_demo_calendar.h"
#include <board.h>
#include <drv_lcd.h>
diff --git a/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/demo/lv_demo_calendar.h b/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/demo/lv_demo_calendar.h
deleted file mode 100644
index b8a7772f2f..0000000000
--- a/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/demo/lv_demo_calendar.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __LV_DEMO_CALENDAR_H__
-#define __LV_DEMO_CALENDAR_H__
-
-void lv_demo_calendar(void);
-
-#endif
diff --git a/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_demo.c b/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_demo.c
deleted file mode 100644
index cbf1e7e6b2..0000000000
--- a/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_demo.c
+++ /dev/null
@@ -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);
diff --git a/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_port_disp.h b/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_port_disp.h
deleted file mode 100644
index ef39eb03cd..0000000000
--- a/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_port_disp.h
+++ /dev/null
@@ -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
diff --git a/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_port_indev.c b/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_port_indev.c
index 4eefd347cd..ba9edd6206 100644
--- a/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_port_indev.c
+++ b/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_port_indev.c
@@ -13,6 +13,8 @@
#include <board.h>
#include <drv_lcd.h>
+lv_indev_t *touch_indev;
+
static lv_indev_state_t last_state = LV_INDEV_STATE_REL;
static rt_int16_t last_x = 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;
}
-lv_indev_t * button_indev;
-
void lv_port_indev_init(void)
{
static lv_indev_drv_t indev_drv;
@@ -42,5 +42,5 @@ void lv_port_indev_init(void)
indev_drv.read_cb = input_read;
/*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);
}
diff --git a/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_port_indev.h b/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_port_indev.h
deleted file mode 100644
index d15f0e5cfa..0000000000
--- a/bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_port_indev.h
+++ /dev/null
@@ -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
diff --git a/bsp/stm32/stm32f407-atk-explorer/board/Kconfig b/bsp/stm32/stm32f407-atk-explorer/board/Kconfig
index 84edfcddc7..dd81f6af4c 100644
--- a/bsp/stm32/stm32f407-atk-explorer/board/Kconfig
+++ b/bsp/stm32/stm32f407-atk-explorer/board/Kconfig
@@ -38,12 +38,12 @@ menu "Onboard Peripheral Drivers"
select BSP_USING_FMC
default n
- config BSP_USING_MCU_LCD
+ config BSP_USING_ONBOARD_LCD
bool "Enable ATK LCD"
select BSP_USING_SRAM
default n
- if BSP_USING_MCU_LCD
- config BSP_USING_MCU_LCD_TEST
+ if BSP_USING_ONBOARD_LCD
+ config BSP_USING_ONBOARD_LCD_TEST
bool "Enable lcd fill test"
default y
endif
@@ -60,11 +60,17 @@ menu "Onboard Peripheral Drivers"
config BSP_USING_LVGL
bool "Enable LVGL for LCD"
- select BSP_USING_MCU_LCD
+ select BSP_USING_ONBOARD_LCD
select BSP_USING_TOUCH
select PKG_USING_LVGL
default n
+ if BSP_USING_LVGL
+ config BSP_USING_LVGL_DEMO
+ bool "Enable LVGL demo"
+ default n
+ endif
+
config BSP_USING_SPI_FLASH
bool "Enable SPI FLASH (W25Q128 spi1)"
select BSP_USING_SPI
diff --git a/bsp/stm32/stm32f407-atk-explorer/board/SConscript b/bsp/stm32/stm32f407-atk-explorer/board/SConscript
index addf40a01f..03bf0e6802 100644
--- a/bsp/stm32/stm32f407-atk-explorer/board/SConscript
+++ b/bsp/stm32/stm32f407-atk-explorer/board/SConscript
@@ -29,7 +29,7 @@ if GetDepend(['BSP_USING_FS']):
if GetDepend(['BSP_USING_SRAM']):
src += Glob('ports/drv_sram.c')
-if GetDepend(['BSP_USING_MCU_LCD']):
+if GetDepend(['BSP_USING_ONBOARD_LCD']):
src += Glob('ports/drv_lcd.c')
if GetDepend(['BSP_USING_TOUCH']):
diff --git a/bsp/stm32/stm32f407-atk-explorer/board/ports/drv_lcd.c b/bsp/stm32/stm32f407-atk-explorer/board/ports/drv_lcd.c
index 0d58050fee..569735e5b8 100644
--- a/bsp/stm32/stm32f407-atk-explorer/board/ports/drv_lcd.c
+++ b/bsp/stm32/stm32f407-atk-explorer/board/ports/drv_lcd.c
@@ -1945,7 +1945,7 @@ int drv_lcd_hw_init(void)
}
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)
{
int num = (int)para;
diff --git a/bsp/stm32/stm32f407-atk-explorer/board/ports/touch/drv_touch.c b/bsp/stm32/stm32f407-atk-explorer/board/ports/touch/drv_touch.c
index 3b54acd48e..652507d7cf 100644
--- a/bsp/stm32/stm32f407-atk-explorer/board/ports/touch/drv_touch.c
+++ b/bsp/stm32/stm32f407-atk-explorer/board/ports/touch/drv_touch.c
@@ -8,9 +8,18 @@
* 2018-02-08 Zhangyihong the first version
*/
+#include <rtconfig.h>
+
+#ifdef BSP_USING_TOUCH
#include "drv_touch.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
#include <rtgui/event.h>
#include <rtgui/rtgui_server.h>
@@ -18,20 +27,14 @@
#include <littlevgl2rtt.h>
#elif defined(PKG_USING_LVGL)
#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;
-#endif
-#define BSP_TOUCH_SAMPLE_HZ (50)
+#endif /* PKG_USING_GUIENGINE */
-#define DBG_ENABLE
-#define DBG_SECTION_NAME "TOUCH"
-#define DBG_LEVEL DBG_INFO
-#define DBG_COLOR
-#include <rtdbg.h>
+#define BSP_TOUCH_SAMPLE_HZ (50)
static rt_list_t driver_list;
-
void rt_touch_drivers_register(touch_drv_t drv)
{
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.wid = RT_NULL;
-
emouse.parent.type = RTGUI_EVENT_MOUSE_BUTTON;
emouse.button = RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_DOWN;
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.wid = RT_NULL;
-
emouse.button = RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_DOWN;
emouse.parent.type = RTGUI_EVENT_MOUSE_MOTION;
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);
#elif defined(PKG_USING_LVGL)
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)
@@ -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.wid = RT_NULL;
-
emouse.parent.type = RTGUI_EVENT_MOUSE_BUTTON;
emouse.button = RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_UP;
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)
touch_down = RT_FALSE;
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)
@@ -204,5 +204,4 @@ static int touc_bg_init(void)
}
INIT_APP_EXPORT(touc_bg_init);
-
#endif