测试H7系列滑动LVGL V8.3.8页面没有TouchGFX,GUIX,emWin搞得流畅,邪门
TouchGFX,GUIX,emWin滑动效果很丝滑。LVGL就不行,没有那三个丝滑。测试平台:
H743+LVGL8.3.8+32bit SDRAM。分辨率800*480,开LVGL双缓冲,底层做DMA2D优化。开读Cache
RTE添加:
优势简单易用,一键添加,部分2D优化需要自己加。添加RTOS也比较方便。
400MHz主频,MDK AC5优化等级开到最高,效果凑合了。
https://img.anfulai.cn/bbs/120090/VID_20230716_025741.mp4
后面有时间再研究研究LVGL那一堆参数配置,性能再提提。
以超简洁方式实现硬件双缓冲,提升到45FPS
eric2013 发表于 2023-7-16 14:37
以超简洁方式实现硬件双缓冲,提升到45FPS
大神有大神深入 lvgl 的前兆 ? 大佬,是不是准备出教程了?:lol 个人感觉LVGL还是不完善,以 nxp 的gui builder1.60 为例,以前的1.40版本多建立几个screen,screen内含控件不管多少,screen之间切换,多次后就会死机,后来版本解决,现在1.60这个问题重新出现。还有就是选项卡空间不支持中文的名目。其他控件可调节范围不多,LVGL我个人的感觉能用,不好用。 willsonxie 发表于 2023-9-18 08:39
个人感觉LVGL还是不完善,以 nxp 的gui builder1.60 为例,以前的1.40版本多建立几个screen,screen内含控 ...
有么有一种可能是你自己没管理好问题,而且builder也不是官方的 eric2013 发表于 2023-7-16 14:37
以超简洁方式实现硬件双缓冲,提升到45FPS
您好,请问下,LVGL我看了几天,发现例程都是触摸屏的,有没有实体按键的例程啊,我们项目的屏是非触摸屏的,谢谢 Yue@123 发表于 2023-11-14 17:55
您好,请问下,LVGL我看了几天,发现例程都是触摸屏的,有没有实体按键的例程啊,我们项目的屏是非触摸屏 ...
这有专门的接口函数,触摸,按键,编码器,鼠标多合一的。
/**
* @file lv_port_indev_templ.c
*
*/
/*Copy this file as "lv_port_indev.c" and set this value to "1" to enable content*/
#if 0
/*********************
* INCLUDES
*********************/
#include "lv_port_indev_template.h"
#include "../../lvgl.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
*STATIC PROTOTYPES
**********************/
static void touchpad_init(void);
static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
static bool touchpad_is_pressed(void);
static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y);
static void mouse_init(void);
static void mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
static bool mouse_is_pressed(void);
static void mouse_get_xy(lv_coord_t * x, lv_coord_t * y);
static void keypad_init(void);
static void keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
static uint32_t keypad_get_key(void);
static void encoder_init(void);
static void encoder_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
static void encoder_handler(void);
static void button_init(void);
static void button_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
static int8_t button_get_pressed_id(void);
static bool button_is_pressed(uint8_t id);
/**********************
*STATIC VARIABLES
**********************/
lv_indev_t * indev_touchpad;
lv_indev_t * indev_mouse;
lv_indev_t * indev_keypad;
lv_indev_t * indev_encoder;
lv_indev_t * indev_button;
static int32_t encoder_diff;
static lv_indev_state_t encoder_state;
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
void lv_port_indev_init(void)
{
/**
* Here you will find example implementation of input devices supported by LittelvGL:
*- Touchpad
*- Mouse (with cursor support)
*- Keypad (supports GUI usage only with key)
*- Encoder (supports GUI usage only with: left, right, push)
*- Button (external buttons to press points on the screen)
*
*The `..._read()` function are only examples.
*You should shape them according to your hardware
*/
static lv_indev_drv_t indev_drv;
/*------------------
* Touchpad
* -----------------*/
/*Initialize your touchpad if you have*/
touchpad_init();
/*Register a touchpad input device*/
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = touchpad_read;
indev_touchpad = lv_indev_drv_register(&indev_drv);
/*------------------
* Mouse
* -----------------*/
/*Initialize your mouse if you have*/
mouse_init();
/*Register a mouse input device*/
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = mouse_read;
indev_mouse = lv_indev_drv_register(&indev_drv);
/*Set cursor. For simplicity set a HOME symbol now.*/
lv_obj_t * mouse_cursor = lv_img_create(lv_scr_act());
lv_img_set_src(mouse_cursor, LV_SYMBOL_HOME);
lv_indev_set_cursor(indev_mouse, mouse_cursor);
/*------------------
* Keypad
* -----------------*/
/*Initialize your keypad or keyboard if you have*/
keypad_init();
/*Register a keypad input device*/
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_KEYPAD;
indev_drv.read_cb = keypad_read;
indev_keypad = lv_indev_drv_register(&indev_drv);
/*Later you should create group(s) with `lv_group_t * group = lv_group_create()`,
*add objects to the group with `lv_group_add_obj(group, obj)`
*and assign this input device to group to navigate in it:
*`lv_indev_set_group(indev_keypad, group);`*/
/*------------------
* Encoder
* -----------------*/
/*Initialize your encoder if you have*/
encoder_init();
/*Register a encoder input device*/
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_ENCODER;
indev_drv.read_cb = encoder_read;
indev_encoder = lv_indev_drv_register(&indev_drv);
/*Later you should create group(s) with `lv_group_t * group = lv_group_create()`,
*add objects to the group with `lv_group_add_obj(group, obj)`
*and assign this input device to group to navigate in it:
*`lv_indev_set_group(indev_encoder, group);`*/
/*------------------
* Button
* -----------------*/
/*Initialize your button if you have*/
button_init();
/*Register a button input device*/
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_BUTTON;
indev_drv.read_cb = button_read;
indev_button = lv_indev_drv_register(&indev_drv);
/*Assign buttons to points on the screen*/
static const lv_point_t btn_points = {
{10, 10}, /*Button 0 -> x:10; y:10*/
{40, 100},/*Button 1 -> x:40; y:100*/
};
lv_indev_set_button_points(indev_button, btn_points);
}
/**********************
* STATIC FUNCTIONS
**********************/
/*------------------
* Touchpad
* -----------------*/
/*Initialize your touchpad*/
static void touchpad_init(void)
{
/*Your code comes here*/
}
/*Will be called by the library to read the touchpad*/
static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
{
static lv_coord_t last_x = 0;
static lv_coord_t last_y = 0;
/*Save the pressed coordinates and the state*/
if(touchpad_is_pressed()) {
touchpad_get_xy(&last_x, &last_y);
data->state = LV_INDEV_STATE_PR;
}
else {
data->state = LV_INDEV_STATE_REL;
}
/*Set the last pressed coordinates*/
data->point.x = last_x;
data->point.y = last_y;
}
/*Return true is the touchpad is pressed*/
static bool touchpad_is_pressed(void)
{
/*Your code comes here*/
return false;
}
/*Get the x and y coordinates if the touchpad is pressed*/
static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y)
{
/*Your code comes here*/
(*x) = 0;
(*y) = 0;
}
/*------------------
* Mouse
* -----------------*/
/*Initialize your mouse*/
static void mouse_init(void)
{
/*Your code comes here*/
}
/*Will be called by the library to read the mouse*/
static void mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
{
/*Get the current x and y coordinates*/
mouse_get_xy(&data->point.x, &data->point.y);
/*Get whether the mouse button is pressed or released*/
if(mouse_is_pressed()) {
data->state = LV_INDEV_STATE_PR;
}
else {
data->state = LV_INDEV_STATE_REL;
}
}
/*Return true is the mouse button is pressed*/
static bool mouse_is_pressed(void)
{
/*Your code comes here*/
return false;
}
/*Get the x and y coordinates if the mouse is pressed*/
static void mouse_get_xy(lv_coord_t * x, lv_coord_t * y)
{
/*Your code comes here*/
(*x) = 0;
(*y) = 0;
}
/*------------------
* Keypad
* -----------------*/
/*Initialize your keypad*/
static void keypad_init(void)
{
/*Your code comes here*/
}
/*Will be called by the library to read the mouse*/
static void keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
{
static uint32_t last_key = 0;
/*Get the current x and y coordinates*/
mouse_get_xy(&data->point.x, &data->point.y);
/*Get whether the a key is pressed and save the pressed key*/
uint32_t act_key = keypad_get_key();
if(act_key != 0) {
data->state = LV_INDEV_STATE_PR;
/*Translate the keys to LVGL control characters according to your key definitions*/
switch(act_key) {
case 1:
act_key = LV_KEY_NEXT;
break;
case 2:
act_key = LV_KEY_PREV;
break;
case 3:
act_key = LV_KEY_LEFT;
break;
case 4:
act_key = LV_KEY_RIGHT;
break;
case 5:
act_key = LV_KEY_ENTER;
break;
}
last_key = act_key;
}
else {
data->state = LV_INDEV_STATE_REL;
}
data->key = last_key;
}
/*Get the currently being pressed key.0 if no key is pressed*/
static uint32_t keypad_get_key(void)
{
/*Your code comes here*/
return 0;
}
/*------------------
* Encoder
* -----------------*/
/*Initialize your keypad*/
static void encoder_init(void)
{
/*Your code comes here*/
}
/*Will be called by the library to read the encoder*/
static void encoder_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
{
data->enc_diff = encoder_diff;
data->state = encoder_state;
}
/*Call this function in an interrupt to process encoder events (turn, press)*/
static void encoder_handler(void)
{
/*Your code comes here*/
encoder_diff += 0;
encoder_state = LV_INDEV_STATE_REL;
}
/*------------------
* Button
* -----------------*/
/*Initialize your buttons*/
static void button_init(void)
{
/*Your code comes here*/
}
/*Will be called by the library to read the button*/
static void button_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
{
static uint8_t last_btn = 0;
/*Get the pressed button's ID*/
int8_t btn_act = button_get_pressed_id();
if(btn_act >= 0) {
data->state = LV_INDEV_STATE_PR;
last_btn = btn_act;
}
else {
data->state = LV_INDEV_STATE_REL;
}
/*Save the last pressed button's ID*/
data->btn_id = last_btn;
}
/*Get ID(0, 1, 2 ..) of the pressed button*/
static int8_t button_get_pressed_id(void)
{
uint8_t i;
/*Check to buttons see which is being pressed (assume there are 2 buttons)*/
for(i = 0; i < 2; i++) {
/*Return the pressed button's ID*/
if(button_is_pressed(i)) {
return i;
}
}
/*No button pressed*/
return -1;
}
/*Test if `id` button is pressed or not*/
static bool button_is_pressed(uint8_t id)
{
/*Your code comes here*/
return false;
}
#else /*Enable this file at the top*/
/*This dummy typedef exists purely to silence -Wpedantic.*/
typedef int keep_pedantic_happy;
#endif
请交各位,我创建了一个屏幕,屏幕上有一个list列表菜单,我怎么能实现进入这个界面,光标选中条默认在第一个菜单上呢,见附件的图:
if (setting_screen == NULL){
setting_screen = lv_obj_create(NULL);
}
lv_scr_load(setting_screen);
lv_obj_t * list = lv_list_create(setting_screen);
lv_list_add_btn(list, LV_SYMBOL_LIST, "Display Setting");
lv_list_add_btn(list, LV_SYMBOL_LIST, "Information");
lv_list_add_btn(list, LV_SYMBOL_LIST, "Language");
lv_list_add_btn(list, LV_SYMBOL_LIST, "Theme");
lv_list_add_btn(list, LV_SYMBOL_LIST, "Password");
lv_list_add_btn(list, LV_SYMBOL_LIST, "Bluetooth");
lv_list_add_btn(list, LV_SYMBOL_LIST, "Factory Reset");
lv_list_add_btn(list, LV_SYMBOL_LIST, "Exit");
lv_obj_set_pos(list, 0, 51);
lv_obj_set_size(list, 800, 320+110);
//lv_obj_set_scrollbar_mode(list, LV_SCROLLBAR_MODE_OFF);
lv_obj_add_flag(list, LV_OBJ_FLAG_CLICK_FOCUSABLE);
lv_obj_t * btn = lv_obj_get_child(list, 1);
lv_obj_scroll_to_view(btn, LV_ANIM_ON); eric2013 发表于 2023-11-14 18:06
这有专门的接口函数,触摸,按键,编码器,鼠标多合一的。
/**
请问下,如果LVGL界面有内存泄漏,大概0.5K左右每次泄漏,需要怎么排查呢? Yue@123 发表于 2023-11-20 10:03
请问下,如果LVGL界面有内存泄漏,大概0.5K左右每次泄漏,需要怎么排查呢?
1、找到复现步骤。
2、看源码。 eric2013 发表于 2023-7-16 14:37
以超简洁方式实现硬件双缓冲,提升到45FPS
lvgl 45帧和其他GUI差距大吗? 无关风月 发表于 2023-11-20 16:00
lvgl 45帧和其他GUI差距大吗?
LVG你的帧率统计可以忽略,实际发现参考价值太低。
LVGL要流畅,最主要就是加大动态内存。 eric2013 发表于 2023-11-20 18:08
LVG你的帧率统计可以忽略,实际发现参考价值太低。
LVGL要流畅,最主要就是加大动态内存。
加大动态内存是什么意思?
页:
[1]