72 lines
2.4 KiB
C
72 lines
2.4 KiB
C
/*
|
||
display Task
|
||
|
||
*/
|
||
|
||
/* Includes ----------------------------------------------------------------- */
|
||
#include "task/user_task.h"
|
||
/* USER INCLUDE BEGIN */
|
||
#include "lvgl/lvgl.h"
|
||
#include "lvgl/stress/lv_demo_stress.h"
|
||
#include "lvgl/examples/porting/lv_port_disp_template.h"
|
||
#include "LCD/lcd.h"
|
||
/* USER INCLUDE END */
|
||
|
||
/* Private typedef ---------------------------------------------------------- */
|
||
/* Private define ----------------------------------------------------------- */
|
||
/* Private macro ------------------------------------------------------------ */
|
||
/* Private variables -------------------------------------------------------- */
|
||
/* 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 */
|
||
|
||
/* Private function --------------------------------------------------------- */
|
||
/* Exported functions ------------------------------------------------------- */
|
||
void Task_display(void *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();
|
||
lv_init();
|
||
|
||
lv_port_disp_init();
|
||
lv_ex_label();
|
||
// lv_demo_stress();
|
||
/* USER CODE INIT END */
|
||
|
||
while (1) {
|
||
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
||
/* USER CODE BEGIN */
|
||
// lcd_fill(100, 100,200,200,RED);
|
||
lv_task_handler();
|
||
lv_tick_inc(1);
|
||
/* USER CODE END */
|
||
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
||
}
|
||
|
||
}
|