一般来讲下载了 https://github.com/lvgl/lvgl.git 就能够使用文件系统了,不需要额外下载lv_fs_if那个代码。
参考lvgl/examples/porting目录下的lv_port_fs_template.c文件实现各种方法即可。
static lv_fs_res_t open_cb(struct _lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode)
{
(void) drv;
//ESP_LOGI(TAG, "lvgl open file: path=%s mode=%d", path, mode);
FILE *fp = NULL;
if (mode == LV_FS_MODE_RD) {
fp = fopen(path, "rb"); // only reading is supported
} else if (mode == LV_FS_MODE_WR) {
fp = fopen(path, "wb");
} else {
ESP_LOGE(TAG, "lvfs open mode error!");
return LV_FS_RES_UNKNOWN;
}
*((FILE **)file_p) = fp;
return NULL == fp ? LV_FS_RES_UNKNOWN : LV_FS_RES_OK;
}
static lv_fs_res_t close_cb(struct _lv_fs