新手入门
- 积分
- 13
- 金钱
- 13
- 注册时间
- 2024-1-29
- 在线时间
- 3 小时
|
3金钱
优化了一下LVGL 结果发现用DMA和不用中断,显示动画有拖影很严重
只用中断不用DMA没拖影但是不咋流畅片子用的STM32F207,SPI速度30M,屏幕分辨率240x280
关键代码:
#define scr_act_width() lv_obj_get_width(lv_scr_act())
#define scr_act_height() lv_obj_get_height(lv_scr_act())
static const lv_font_t *font; /* 定义字体 */
static lv_obj_t *obj; /* 基础对象 */
static lv_obj_t * obj1;
static lv_obj_t * obj2;
static lv_obj_t * obj3;
static lv_obj_t * obj4;
static lv_obj_t * obj5;
static lv_obj_t * obj6;
static lv_obj_t * obj7;
static lv_obj_t * label1;
static lv_obj_t * label2;
static lv_obj_t * label3;
static lv_obj_t * label4;
static lv_obj_t * label5;
static lv_obj_t * label6;
static lv_timer_t * t1;
static int move=0;
static void event_cb(lv_event_t * e)
{
move=lv_obj_get_scroll_x(obj);
if(move%150!=0)
{
if(move%150<75){lv_obj_scroll_to_x(obj, move-(move%150), LV_ANIM_ON);}
if(move%150>74){lv_obj_scroll_to_x(obj, move+150-(move%150), LV_ANIM_ON);}
}
}
//void tile0_pressing_cb(lv_event_t * e)
void timer_cb1(lv_timer_t * t)
{
lv_obj_scroll_to_x(obj, move, LV_ANIM_ON);
move = move + 150;
move %= 600;
}
void lv_mainstart(void)
{
font = &lv_font_montserrat_16;
obj = lv_obj_create(lv_scr_act());
lv_obj_set_size(obj, scr_act_width(), scr_act_height());
lv_obj_align(obj, LV_ALIGN_CENTER, 0 , 0);
lv_obj_set_style_bg_color(obj, lv_color_hex(0x00001f), LV_STATE_DEFAULT);
obj1=lv_obj_create(obj);
lv_obj_set_style_radius(obj1,20,LV_PART_MAIN);
lv_obj_align(obj1,LV_ALIGN_CENTER, 0, 0);
lv_obj_set_style_bg_color(obj1,lv_color_hex(0xff0020), LV_PART_MAIN);
lv_obj_set_size(obj1,80,80);
label1 = lv_label_create(obj1);
lv_obj_align(label1, LV_ALIGN_CENTER, 0 , 0);
lv_obj_set_style_bg_opa(label1, LV_OPA_COVER, 0); //设置控件的透明度为不透明
lv_obj_set_style_bg_color(label1, lv_color_hex(0xff0020), 0); //设置空间的本地样式演示为绿色
lv_obj_set_style_text_color(label1, lv_color_hex(0x000000), 0);
lv_label_set_text(label1, "Happy");
lv_obj_set_style_text_font(label1, font, LV_PART_MAIN);
obj2=lv_obj_create(obj);
lv_obj_set_style_radius(obj2,20,LV_PART_MAIN);
lv_obj_align(obj2,LV_ALIGN_CENTER, 150, 0);
lv_obj_set_style_bg_color(obj2,lv_color_hex(0x20ff20), LV_PART_MAIN);
lv_obj_set_size(obj2,80,80);
label2 = lv_label_create(obj2);
lv_obj_align(label2, LV_ALIGN_CENTER, 0 , 0);
lv_obj_set_style_bg_opa(label2, LV_OPA_COVER, 0); //设置控件的透明度为不透明
lv_obj_set_style_bg_color(label2, lv_color_hex(0x20ff20), 0); //设置空间的本地样式演示为绿色
lv_obj_set_style_text_color(label2, lv_color_hex(0x000000), 0);
lv_label_set_text(label2, "New");
lv_obj_set_style_text_font(label2, font, LV_PART_MAIN);
obj3=lv_obj_create(obj);
lv_obj_set_style_radius(obj3,20,LV_PART_MAIN);
lv_obj_align(obj3,LV_ALIGN_CENTER, 300, 0);
lv_obj_set_style_bg_color(obj3,lv_color_hex(0x20ffff), LV_PART_MAIN);
lv_obj_set_size(obj3,80,80);
label3 = lv_label_create(obj3);
lv_obj_align(label3, LV_ALIGN_CENTER, 0 , 0);
lv_obj_set_style_bg_opa(label3, LV_OPA_COVER, 0); //设置控件的透明度为不透明
lv_obj_set_style_bg_color(label3, lv_color_hex(0x20ffff), 0); //设置空间的本地样式演示为绿色
lv_obj_set_style_text_color(label3, lv_color_hex(0x000000), 0);
lv_label_set_text(label3, "Year");
lv_obj_set_style_text_font(label3, font, LV_PART_MAIN);
obj4=lv_obj_create(obj);
lv_obj_set_style_radius(obj4,20,LV_PART_MAIN);
lv_obj_align(obj4,LV_ALIGN_CENTER, 450, 0);
lv_obj_set_style_bg_color(obj4,lv_color_hex(0x3f90f0), LV_PART_MAIN);
lv_obj_set_size(obj4,80,80);
label4 = lv_label_create(obj4);
lv_obj_align(label4, LV_ALIGN_CENTER, 0 , 0);
lv_obj_set_style_bg_opa(label4, LV_OPA_COVER, 0); //设置控件的透明度为不透明
lv_obj_set_style_bg_color(label4, lv_color_hex(0x3f90f0), 0); //设置空间的本地样式演示为绿色
lv_obj_set_style_text_color(label4, lv_color_hex(0x000000), 0);
lv_label_set_text(label4, "2025");
lv_obj_set_style_text_font(label4, font, LV_PART_MAIN);
// obj5=lv_obj_create(obj);
// lv_obj_set_style_radius(obj5,20,LV_PART_MAIN);
// lv_obj_align(obj5,LV_ALIGN_CENTER, 600, 0);
// lv_obj_set_style_bg_color(obj5,lv_color_hex(0x2000ff), LV_PART_MAIN);
// lv_obj_set_size(obj5,80,80);
// obj6=lv_obj_create(obj);
// lv_obj_set_style_radius(obj6,20,LV_PART_MAIN);
// lv_obj_align(obj6,LV_ALIGN_CENTER, 750, 0);
// lv_obj_set_style_bg_color(obj6,lv_color_hex(0x3a7803), LV_PART_MAIN);
// lv_obj_set_size(obj6,80,80);
obj7=lv_obj_create(obj);
lv_obj_set_style_radius(obj7,20,LV_PART_MAIN);
lv_obj_align(obj7,LV_ALIGN_CENTER, 600, 0);
lv_obj_set_style_bg_color(obj7,lv_color_hex(0x00001f), LV_PART_MAIN);
lv_obj_set_style_border_color(obj7,lv_color_hex(0x00001f), LV_PART_MAIN);
lv_obj_set_size(obj7,80,80);
//lv_obj_add_flag(obj7, LV_OBJ_FLAG_HIDDEN);
//lv_obj_add_event_cb(obj,event_cb,LV_EVENT_SCROLL_END,0);
lv_obj_set_scrollbar_mode(obj,LV_SCROLLBAR_MODE_OFF);
lv_obj_set_scrollbar_mode(obj1,LV_SCROLLBAR_MODE_OFF);
lv_obj_set_scrollbar_mode(obj2,LV_SCROLLBAR_MODE_OFF);
lv_obj_set_scrollbar_mode(obj3,LV_SCROLLBAR_MODE_OFF);
lv_obj_set_scrollbar_mode(obj4,LV_SCROLLBAR_MODE_OFF);
t1=lv_timer_create(timer_cb1, 1000, 0);
}
void test1_demo(void)
{
lv_mainstart();
}
|
|