Skip to content

Commit a6b62d3

Browse files
authored
Merge pull request #5394 from mysterywolf/simu
2 parents d724eed + d4a72f2 commit a6b62d3

File tree

17 files changed

+1288
-13
lines changed

17 files changed

+1288
-13
lines changed

bsp/qemu-vexpress-a9/drivers/drv_clcd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ int drv_clcd_hw_init(void)
109109

110110
_lcd.width = CLCD_WIDTH;
111111
_lcd.height = CLCD_HEIGHT;
112-
_lcd.fb = rt_malloc_align(_lcd.width * _lcd.height * 2, 32);
112+
_lcd.fb = rt_malloc(_lcd.width * _lcd.height * 2);
113113
if (_lcd.fb == NULL)
114114
{
115115
rt_kprintf("initialize frame buffer failed!\n");

bsp/qemu-vexpress-a9/drivers/lvgl/SConscript

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ cwd = GetCurrentDir()
55
group = []
66
src = Glob('*.c')
77
CPPPATH = [cwd]
8-
CPPDEFINES = ['STM32F4']
98

109
list = os.listdir(cwd)
1110
for d in list:
1211
path = os.path.join(cwd, d)
1312
if os.path.isfile(os.path.join(path, 'SConscript')):
1413
group = group + SConscript(os.path.join(d, 'SConscript'))
1514

16-
group += DefineGroup('LVGL-port', src, depend = ['BSP_USING_LVGL'], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES)
15+
group += DefineGroup('LVGL-port', src, depend = ['BSP_USING_LVGL'], CPPPATH = CPPPATH)
1716

1817
Return('group')

bsp/qemu-vexpress-a9/drivers/lvgl/lv_demo.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
*/
1010
#include <rtthread.h>
1111
#include <lvgl.h>
12-
#include <lv_port_indev.h>
1312
#define DBG_TAG "LVGL.demo"
1413
#define DBG_LVL DBG_INFO
1514
#include <rtdbg.h>
@@ -24,9 +23,11 @@
2423

2524
static void lvgl_thread(void *parameter)
2625
{
26+
/* display demo; you may replace with your LVGL application at here */
2727
extern void lv_demo_music(void);
2828
lv_demo_music();
2929

30+
/* handle the tasks of LVGL */
3031
while(1)
3132
{
3233
lv_task_handler();

bsp/qemu-vexpress-a9/drivers/lvgl/lv_port_disp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,14 @@ void lv_port_disp_init(void)
116116
RT_ASSERT(info.bits_per_pixel == 8 || info.bits_per_pixel == 16 ||
117117
info.bits_per_pixel == 24 || info.bits_per_pixel == 32);
118118

119-
fbuf1 = rt_malloc_align(info.width * info.height * sizeof(lv_color_t), 32);
119+
fbuf1 = rt_malloc(info.width * info.height * sizeof(lv_color_t));
120120
if (fbuf1 == RT_NULL)
121121
{
122122
rt_kprintf("Error: alloc disp buf fail\n");
123123
return;
124124
}
125125

126-
fbuf2 = rt_malloc_align(info.width * info.height * sizeof(lv_color_t), 32);
126+
fbuf2 = rt_malloc(info.width * info.height * sizeof(lv_color_t));
127127
if (fbuf2 == RT_NULL)
128128
{
129129
rt_kprintf("Error: alloc disp buf fail\n");

bsp/qemu-vexpress-a9/drivers/lvgl/lv_port_indev.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@
1414
extern "C" {
1515
#endif
1616

17-
#include <lv_hal_indev.h>
18-
19-
extern lv_indev_t * button_indev;
20-
2117
void lv_port_indev_init(void);
22-
void lv_port_indev_input(rt_int16_t x, rt_int16_t y, lv_indev_state_t state);
2318

2419
#ifdef __cplusplus
2520
} /*extern "C"*/

bsp/simulator/Kconfig

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,23 @@ config SOC_SIMULATOR
2626

2727
if RT_USING_DFS
2828
config RT_USING_DFS_WINSHAREDIR
29-
bool "Enable shared file system between windows"
30-
default n
29+
bool "Enable shared file system between windows"
30+
default n
3131
endif
3232

33+
config BSP_USING_LVGL
34+
bool "Enable LVGL for LCD"
35+
select PKG_USING_LVGL
36+
select PKG_USING_LV_MUSIC_DEMO
37+
default n
38+
39+
if BSP_USING_LVGL
40+
config BSP_LCD_WIDTH
41+
int "LCD width"
42+
default 800
3343

44+
config BSP_LCD_HEIGHT
45+
int "LCD height"
46+
default 480
47+
48+
endif

bsp/simulator/drivers/SConscript

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
import os
23
from building import *
34

45
cwd = GetCurrentDir()
@@ -34,4 +35,9 @@ if sys.platform[0:5]=="linux": #check whether under linux
3435
group = DefineGroup('Drivers', src, depend = [''],
3536
CPPPATH = CPPPATH, LIBS=LIBS, LIBPATH=LIBPATH, CPPDEFINES = CPPDEFINES)
3637

38+
list = os.listdir(cwd)
39+
for item in list:
40+
if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
41+
group = group + SConscript(os.path.join(item, 'SConscript'))
42+
3743
Return('group')

bsp/simulator/drivers/lvgl/SConscript

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from building import *
2+
import os
3+
4+
cwd = GetCurrentDir()
5+
group = []
6+
src = Glob('*.c')
7+
CPPPATH = [cwd]
8+
9+
list = os.listdir(cwd)
10+
for d in list:
11+
path = os.path.join(cwd, d)
12+
if os.path.isfile(os.path.join(path, 'SConscript')):
13+
group = group + SConscript(os.path.join(d, 'SConscript'))
14+
15+
group += DefineGroup('LVGL-port', src, depend = ['BSP_USING_LVGL'], CPPPATH = CPPPATH)
16+
17+
Return('group')

bsp/simulator/drivers/lvgl/lv_conf.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2021-10-18 Meco Man First version
9+
*/
10+
11+
#ifndef LV_CONF_H
12+
#define LV_CONF_H
13+
14+
#define LV_USE_PERF_MONITOR 1
15+
#define LV_COLOR_DEPTH 32
16+
17+
# define USE_WIN32DRV 1
18+
# define WIN32DRV_MONITOR_ZOOM 1
19+
20+
/* music player demo */
21+
#include <rtconfig.h>
22+
#define LV_DISP_DEF_REFR_PERIOD 10
23+
#define LV_HOR_RES_MAX BSP_LCD_WIDTH
24+
#define LV_VER_RES_MAX BSP_LCD_HEIGHT
25+
#define LV_USE_DEMO_RTT_MUSIC 1
26+
#define LV_DEMO_RTT_MUSIC_AUTO_PLAY 1
27+
#define LV_FONT_MONTSERRAT_12 1
28+
#define LV_FONT_MONTSERRAT_16 1
29+
30+
#endif

bsp/simulator/drivers/lvgl/lv_demo.c

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2021-10-17 Meco Man First version
9+
*/
10+
#include <rtthread.h>
11+
#define DBG_TAG "LVGL.demo"
12+
#define DBG_LVL DBG_INFO
13+
#include <rtdbg.h>
14+
#include <lvgl.h>
15+
#include <win32drv.h>
16+
17+
#ifndef LV_THREAD_STACK_SIZE
18+
#define LV_THREAD_STACK_SIZE 4096
19+
#endif
20+
21+
#ifndef LV_THREAD_PRIO
22+
#define LV_THREAD_PRIO (RT_THREAD_PRIORITY_MAX*2/3)
23+
#endif
24+
25+
static void lvgl_thread(void *parameter)
26+
{
27+
/* initialize win32 driver; don't put this in lv_port_disp() */
28+
if (!lv_win32_init(GetModuleHandleW(NULL), SW_SHOW, BSP_LCD_WIDTH, BSP_LCD_HEIGHT, NULL))
29+
{
30+
LOG_E("lv_win32_init failure!");
31+
return;
32+
}
33+
lv_win32_add_all_input_devices_to_group(NULL);
34+
35+
/* display demo; you may replace with your LVGL application at here */
36+
extern void lv_demo_music(void);
37+
lv_demo_music();
38+
39+
/* handle the tasks of LVGL */
40+
while (!lv_win32_quit_signal)
41+
{
42+
lv_task_handler();
43+
rt_thread_mdelay(1);
44+
}
45+
46+
LOG_W("LVGL simulator window closed!");
47+
}
48+
49+
static int lvgl_demo_init(void)
50+
{
51+
rt_thread_t tid;
52+
53+
tid = rt_thread_create("LVGL", lvgl_thread, RT_NULL, LV_THREAD_STACK_SIZE, LV_THREAD_PRIO, 10);
54+
if(tid == RT_NULL)
55+
{
56+
LOG_E("Fail to create 'LVGL' thread");
57+
}
58+
rt_thread_startup(tid);
59+
60+
return 0;
61+
}
62+
INIT_APP_EXPORT(lvgl_demo_init);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2021-10-18 Meco Man The first version
9+
*/
10+
11+
void lv_port_disp_init(void)
12+
{
13+
/* do nothing*/
14+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2021-10-18 Meco Man The first version
9+
*/
10+
#ifndef LV_PORT_DISP_H
11+
#define LV_PORT_DISP_H
12+
13+
#ifdef __cplusplus
14+
extern "C" {
15+
#endif
16+
17+
void lv_port_disp_init(void);
18+
19+
#ifdef __cplusplus
20+
} /*extern "C"*/
21+
#endif
22+
23+
#endif
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2021-10-18 Meco Man The first version
9+
*/
10+
11+
void lv_port_indev_init(void)
12+
{
13+
/* do nothing */
14+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2021-10-18 Meco Man The first version
9+
*/
10+
#ifndef LV_PORT_INDEV_H
11+
#define LV_PORT_INDEV_H
12+
13+
#ifdef __cplusplus
14+
extern "C" {
15+
#endif
16+
17+
void lv_port_indev_init(void);
18+
19+
#ifdef __cplusplus
20+
} /*extern "C"*/
21+
#endif
22+
23+
#endif

0 commit comments

Comments
 (0)