移植LVGL的文件系统接口,使用IMX6ull,基于Linux平台
在使用LVGL时,我们难免要使用要其他的图片,如果使用LVGL平台提供的在线转换成数组的话,文件太大了,所以我们需要移植LVGL的文件接口
1、移植跟文件系统接口移植
1.1、使能使用LVGL的文件系统接口(lv_conf.h)
1.2、编译(make -j8)
出现错误:错误: ‘DT_DIR’未声明(在此函数内第一次使用) if(entry->d_type == DT_DIR) sprintf(fn, “/%s”, entry->d_name);
原因:LVGL中引入了如下依赖
#include <sys/types.h>
#include <dirent.h>
#include <stdlib.h>
#include <errno.h>
解决::然后在编译的时候加上 -D_BSD_SOURCE
修改Makefile
@$(CC) $(CFLAGS) -c $< -std=c99 -D_BSD_SOURCE -o $@
1.3、测试
打开目录,并打印目录文件
void FileTest(void)
{
lv_fs_dir_t dir;
lv_fs_res_t res;
res = lv_fs_dir_open(&dir, "L:/");
char fn[256];
while(1) {
res = lv_fs_dir_read(&dir, fn);
if(strlen(fn) == 0) {
break;
}
printf("%s\n", fn);
}
lv_fs_dir_close(&dir);
}
移植成功