lvgl移植完毕,加入dma及双缓冲刷新
This commit is contained in:
parent
a708f48a59
commit
2ebe359343
@ -18,12 +18,12 @@
|
|||||||
*********************/
|
*********************/
|
||||||
#ifndef MY_DISP_HOR_RES
|
#ifndef MY_DISP_HOR_RES
|
||||||
#warning Please define or replace the macro MY_DISP_HOR_RES with the actual screen width, default value 320 is used for now.
|
#warning Please define or replace the macro MY_DISP_HOR_RES with the actual screen width, default value 320 is used for now.
|
||||||
#define MY_DISP_HOR_RES 320
|
#define MY_DISP_HOR_RES 240
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MY_DISP_VER_RES
|
#ifndef MY_DISP_VER_RES
|
||||||
#warning Please define or replace the macro MY_DISP_HOR_RES with the actual screen height, default value 240 is used for now.
|
#warning Please define or replace the macro MY_DISP_HOR_RES with the actual screen height, default value 240 is used for now.
|
||||||
#define MY_DISP_VER_RES 240
|
#define MY_DISP_VER_RES 320
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ void lv_port_disp_init(void)
|
|||||||
static lv_disp_draw_buf_t draw_buf_dsc_2;
|
static lv_disp_draw_buf_t draw_buf_dsc_2;
|
||||||
static lv_color_t buf_2_1[MY_DISP_HOR_RES * 20]; /*A buffer for 10 rows*/
|
static lv_color_t buf_2_1[MY_DISP_HOR_RES * 20]; /*A buffer for 10 rows*/
|
||||||
static lv_color_t buf_2_2[MY_DISP_HOR_RES * 20]; /*An other buffer for 10 rows*/
|
static lv_color_t buf_2_2[MY_DISP_HOR_RES * 20]; /*An other buffer for 10 rows*/
|
||||||
lv_disp_draw_buf_init(&draw_buf_dsc_2, buf_2_1, buf_2_2, MY_DISP_HOR_RES * 40); /*Initialize the display buffer*/
|
lv_disp_draw_buf_init(&draw_buf_dsc_2, buf_2_1, buf_2_2, MY_DISP_HOR_RES * 20); /*Initialize the display buffer*/
|
||||||
|
|
||||||
// /* Example for 3) also set disp_drv.full_refresh = 1 below*/
|
// /* Example for 3) also set disp_drv.full_refresh = 1 below*/
|
||||||
// static lv_disp_draw_buf_t draw_buf_dsc_3;
|
// static lv_disp_draw_buf_t draw_buf_dsc_3;
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
- delay: 0
|
- delay: 0
|
||||||
description: ''
|
description: ''
|
||||||
freq_control: false
|
freq_control: true
|
||||||
function: Task_lvgl
|
frequency: 1000.0
|
||||||
name: lvgl
|
function: Task_display
|
||||||
|
name: display
|
||||||
stack: 1024
|
stack: 1024
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
lvgl Task
|
display Task
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -17,33 +17,55 @@
|
|||||||
/* Private macro ------------------------------------------------------------ */
|
/* Private macro ------------------------------------------------------------ */
|
||||||
/* Private variables -------------------------------------------------------- */
|
/* Private variables -------------------------------------------------------- */
|
||||||
/* USER STRUCT BEGIN */
|
/* USER STRUCT BEGIN */
|
||||||
|
void lv_ex_label(void)
|
||||||
|
{
|
||||||
|
char* github_addr = "hahahahahahahahah";
|
||||||
|
lv_obj_t * label = lv_label_create(lv_scr_act());
|
||||||
|
lv_label_set_recolor(label, true);
|
||||||
|
lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR); /*Circular scroll*/
|
||||||
|
lv_obj_set_width(label, 120);
|
||||||
|
lv_label_set_text_fmt(label, "#ff0000 hahahahahahahahaha %s#", github_addr);
|
||||||
|
lv_obj_align(label, LV_ALIGN_CENTER, 0, 10);
|
||||||
|
|
||||||
|
lv_obj_t * label2 = lv_label_create(lv_scr_act());
|
||||||
|
lv_label_set_recolor(label2, true);
|
||||||
|
lv_label_set_long_mode(label2, LV_LABEL_LONG_SCROLL_CIRCULAR); /*Circular scroll*/
|
||||||
|
lv_obj_set_width(label2, 120);
|
||||||
|
lv_label_set_text_fmt(label2, "#ff0000 hahahahahahaha# #0000ff hahahahahahaha#");
|
||||||
|
lv_obj_align(label2, LV_ALIGN_CENTER, 0, -10);
|
||||||
|
}
|
||||||
/* USER STRUCT END */
|
/* USER STRUCT END */
|
||||||
|
|
||||||
/* Private function --------------------------------------------------------- */
|
/* Private function --------------------------------------------------------- */
|
||||||
/* Exported functions ------------------------------------------------------- */
|
/* Exported functions ------------------------------------------------------- */
|
||||||
void Task_lvgl(void *argument) {
|
void Task_display(void *argument) {
|
||||||
(void)argument; /* 未使用argument,消除警告 */
|
(void)argument; /* 未使用argument,消除警告 */
|
||||||
|
|
||||||
|
|
||||||
|
/* 计算任务运行到指定频率需要等待的tick数 */
|
||||||
|
const uint32_t delay_tick = osKernelGetTickFreq() / DISPLAY_FREQ;
|
||||||
|
|
||||||
|
osDelay(DISPLAY_INIT_DELAY); /* 延时一段时间再开启任务 */
|
||||||
|
|
||||||
|
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
|
||||||
|
/* USER CODE INIT BEGIN */
|
||||||
|
|
||||||
lcd_init();
|
lcd_init();
|
||||||
lv_init();
|
lv_init();
|
||||||
|
|
||||||
lv_port_disp_init();
|
lv_port_disp_init();
|
||||||
|
lv_ex_label();
|
||||||
lv_demo_stress();
|
// lv_demo_stress();
|
||||||
// osDelay(LVGL_INIT_DELAY); /* 延时一段时间再开启任务 */
|
|
||||||
|
|
||||||
/* USER CODE INIT BEGIN */
|
|
||||||
|
|
||||||
/* USER CODE INIT END */
|
/* USER CODE INIT END */
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
||||||
|
/* USER CODE BEGIN */
|
||||||
// lcd_fill(100, 100,200,200,RED);
|
// lcd_fill(100, 100,200,200,RED);
|
||||||
lv_task_handler();
|
lv_task_handler();
|
||||||
// lv_timer_handler();
|
lv_tick_inc(1);
|
||||||
/* USER CODE BEGIN */
|
|
||||||
|
|
||||||
/* USER CODE END */
|
/* USER CODE END */
|
||||||
|
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,7 +30,7 @@ void Task_Init(void *argument) {
|
|||||||
osKernelLock(); /* 锁定内核,防止任务切换 */
|
osKernelLock(); /* 锁定内核,防止任务切换 */
|
||||||
|
|
||||||
/* 创建任务线程 */
|
/* 创建任务线程 */
|
||||||
task_runtime.thread.lvgl = osThreadNew(Task_lvgl, NULL, &attr_lvgl);
|
task_runtime.thread.display = osThreadNew(Task_display, NULL, &attr_display);
|
||||||
|
|
||||||
// 创建消息队列
|
// 创建消息队列
|
||||||
/* USER MESSAGE BEGIN */
|
/* USER MESSAGE BEGIN */
|
||||||
|
|||||||
@ -9,8 +9,8 @@ const osThreadAttr_t attr_init = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* User_task */
|
/* User_task */
|
||||||
const osThreadAttr_t attr_lvgl = {
|
const osThreadAttr_t attr_display = {
|
||||||
.name = "lvgl",
|
.name = "display",
|
||||||
.priority = osPriorityNormal,
|
.priority = osPriorityNormal,
|
||||||
.stack_size = 1024 * 8,
|
.stack_size = 1024 * 4,
|
||||||
};
|
};
|
||||||
@ -13,11 +13,11 @@ extern "C" {
|
|||||||
/* USER INCLUDE END */
|
/* USER INCLUDE END */
|
||||||
/* Exported constants ------------------------------------------------------- */
|
/* Exported constants ------------------------------------------------------- */
|
||||||
/* 任务运行频率 */
|
/* 任务运行频率 */
|
||||||
|
#define DISPLAY_FREQ (1000.0)
|
||||||
|
|
||||||
/* 任务初始化延时ms */
|
/* 任务初始化延时ms */
|
||||||
#define TASK_INIT_DELAY (100u)
|
#define TASK_INIT_DELAY (100u)
|
||||||
#define LVGL_INIT_DELAY (0)
|
#define DISPLAY_INIT_DELAY (0)
|
||||||
|
|
||||||
/* Exported defines --------------------------------------------------------- */
|
/* Exported defines --------------------------------------------------------- */
|
||||||
/* Exported macro ----------------------------------------------------------- */
|
/* Exported macro ----------------------------------------------------------- */
|
||||||
@ -27,7 +27,7 @@ extern "C" {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
/* 各任务,也可以叫做线程 */
|
/* 各任务,也可以叫做线程 */
|
||||||
struct {
|
struct {
|
||||||
osThreadId_t lvgl;
|
osThreadId_t display;
|
||||||
} thread;
|
} thread;
|
||||||
|
|
||||||
/* USER MESSAGE BEGIN */
|
/* USER MESSAGE BEGIN */
|
||||||
@ -49,17 +49,17 @@ typedef struct {
|
|||||||
|
|
||||||
/* 各任务的stack使用 */
|
/* 各任务的stack使用 */
|
||||||
struct {
|
struct {
|
||||||
UBaseType_t lvgl;
|
UBaseType_t display;
|
||||||
} stack_water_mark;
|
} stack_water_mark;
|
||||||
|
|
||||||
/* 各任务运行频率 */
|
/* 各任务运行频率 */
|
||||||
struct {
|
struct {
|
||||||
|
float display;
|
||||||
} freq;
|
} freq;
|
||||||
|
|
||||||
/* 任务最近运行时间 */
|
/* 任务最近运行时间 */
|
||||||
struct {
|
struct {
|
||||||
|
float display;
|
||||||
} last_up_time;
|
} last_up_time;
|
||||||
|
|
||||||
} Task_Runtime_t;
|
} Task_Runtime_t;
|
||||||
@ -69,11 +69,11 @@ extern Task_Runtime_t task_runtime;
|
|||||||
|
|
||||||
/* 初始化任务句柄 */
|
/* 初始化任务句柄 */
|
||||||
extern const osThreadAttr_t attr_init;
|
extern const osThreadAttr_t attr_init;
|
||||||
extern const osThreadAttr_t attr_lvgl;
|
extern const osThreadAttr_t attr_display;
|
||||||
|
|
||||||
/* 任务函数声明 */
|
/* 任务函数声明 */
|
||||||
void Task_Init(void *argument);
|
void Task_Init(void *argument);
|
||||||
void Task_lvgl(void *argument);
|
void Task_display(void *argument);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user