硬件平台:F1C100S 系统主频 408M
软件平台:用的WhyCan 网友staunchheart提供的代码,码云地址https://gitee.com/zhangheyang/f1c100s_rt-thread
改动地方:
只改了800*480的屏幕参数和gt911芯片的中断和复位脚,为了适配自己的板子
问题:
系统跑起来后启动了个littlevGL的titleView的demo,切换界面的时候卡的不行,已经把动画时间设置为0了
还是卡
littlevGL关键代码:
刷新函数
lvgl_rtt_lcd_flush_cb
{
……
uint32_t w = lv_area_get_width(area);
uint32_t *fbp32 = (uint32_t*) info.framebuffer; // 是我的info.framebuffer
for (y = area->y1; y <= area->y2 && y < disp_drv->ver_res; y++)
{
memcpy(&fbp32[y * info.width + area->x1], color_p, w * sizeof(lv_color_t));
color_p += w;
}
……
}
lv缓存初始化函数
rt_err_t lvgl_rtt_init(const char *name)
{
……
static lv_color_t buffer[LV_HOR_RES_MAX * LV_VER_RES_MAX];
static lv_disp_buf_t disp_buf;
lv_disp_buf_init(&disp_buf, buffer, NULL, LV_HOR_RES_MAX * LV_VER_RES_MAX);
/* littlevGL Display device interface */
lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv);
……
}
lv tick函数 lvgl_rtt_tick_run是一个rtt的线程任务函数,在里面进行lv_tick_inc(1);
static void lvgl_rtt_tick_run(void *p)
{
while (1)
{
lv_tick_inc(1);
rt_thread_delay(1);
}
}
lv_task_handler函数 :lvgl_demo_run也是自己开启的一个rtt的任务函数,在里面进行lv_task_handler()调用
void lvgl_demo_run(void *p)
{
/* 新建个样式 */
static lv_style_t style_desktop;
static lv_style_t style_tabview;
static lv_style_t style_label;
lv_style_copy(&style_desktop, &lv_style_scr);
style_desktop.body.main_color = LV_COLOR_WHITE; /* 设置底色 */
style_desktop.body.grad_color = LV_COLOR_WHITE; /* 设置渐变色 */
lv_obj_t *scr = lv_disp_get_scr_act(NULL); /* 获取当前屏幕 */
lv_obj_set_style(scr, &style_desktop); /* 设置样式 */
static lv_point_t valid_pos1[] = { { 0, 0 }, { 1, 0 } ,{ 2, 0 } };
lv_obj_t *tileview;
tileview = lv_tileview_create(scr, NULL); // 父亲是main_title
lv_tileview_set_valid_positions(tileview, valid_pos1, 3);
lv_tileview_set_edge_flash(tileview, true);
lv_tileview_set_anim_time(tileview,10);
lv_tileview_set_tile_act(tileview, 1, 0, LV_ANIM_ON);
/*
* left title
*/
lv_obj_t * left_title = lv_obj_create(tileview, NULL);
lv_obj_set_size(left_title, LV_HOR_RES, LV_VER_RES);
//lv_obj_set_pos(left_title, -LV_HOR_RES, 0);
lv_obj_set_style(left_title, &lv_style_pretty);
lv_tileview_add_element(tileview, left_title);
lv_obj_t * left_label = lv_label_create(left_title, NULL);
lv_label_set_text(left_label, "left title");
lv_obj_align(left_label, NULL, LV_ALIGN_CENTER, 0, 0);
/*
* mid title
*/
lv_obj_t * mid_title = lv_obj_create(tileview, NULL);
lv_obj_set_size(mid_title, LV_HOR_RES, LV_VER_RES);
lv_obj_set_pos(mid_title, LV_HOR_RES, 0);
lv_obj_set_style(mid_title, &lv_style_pretty);
lv_tileview_add_element(tileview, mid_title);
lv_obj_t * mid_label = lv_label_create(mid_title, NULL);
lv_label_set_text(mid_label, "mid title");
lv_obj_align(mid_label, NULL, LV_ALIGN_CENTER, 0, 0);
/*
* right title
*/
lv_obj_t * right_title = lv_obj_create(tileview, NULL);
lv_obj_set_size(right_title, LV_HOR_RES, LV_VER_RES);
lv_obj_set_pos(right_title, LV_HOR_RES*2, 0);
lv_obj_set_style(right_title, &lv_style_pretty);
lv_tileview_add_element(tileview, right_title);
lv_obj_t * right_label = lv_label_create(right_title, NULL);
lv_label_set_text(right_label, "right title");
lv_obj_align(right_label, NULL, LV_ALIGN_CENTER, 0, 0);
while (1)
{
rt_thread_delay(RT_TICK_PER_SECOND / 100);
lv_task_handler(); // 这里进行lv task任务函数
}
}
运行效果如下:
手滑动的时候,界面都是慢慢的切过去的。好慢。
https://whycan.cn/files/members/4433/QQ%E7%9F%AD%E8%A7%86%E9%A2%9120200718232506.mp4
离线