diff --git a/include/lv_conf_v7.h b/include/lv_conf_v7.h index 764be7bd..606203cc 100644 --- a/include/lv_conf_v7.h +++ b/include/lv_conf_v7.h @@ -211,7 +211,7 @@ typedef void* lv_group_user_data_t; #define LV_USE_FILESYSTEM 1 #if LV_USE_FILESYSTEM /*Declare the type of the user data of file system drivers (can be e.g. `void *`, `int`, `struct`)*/ -typedef void* lv_fs_drv_user_data_t; +typedef const char* lv_fs_drv_user_data_t; /*File system interface*/ #ifndef LV_USE_FS_IF @@ -229,7 +229,7 @@ typedef void* lv_fs_drv_user_data_t; //# define LV_FS_IF_SPIFFS '\0' // no internal esp Flash #endif #endif /*LV_USE_FS_IF*/ -#if HASP_TARGET_ARDUINO +#if HASP_TARGET_ARDUINO && !defined(LV_FS_PC_PATH) #define LV_FS_PC_PATH "/littlefs" #endif diff --git a/lib/lv_fs_if/lv_fs_if.c b/lib/lv_fs_if/lv_fs_if.c index 472edcf2..45c94def 100644 --- a/lib/lv_fs_if/lv_fs_if.c +++ b/lib/lv_fs_if/lv_fs_if.c @@ -14,6 +14,13 @@ /********************* * DEFINES *********************/ +#ifndef LV_FS_PC_PATH +#ifndef WIN32 +#define LV_FS_PC_PATH "./" /*Project root*/ +#else +#define LV_FS_PC_PATH ".\\" /*Project root*/ +#endif +#endif /*LV_FS_PATH*/ /********************** * TYPEDEFS @@ -26,8 +33,8 @@ void lv_fs_if_fatfs_init(void); #endif -#if LV_FS_IF_PC != '\0' -void lv_fs_if_pc_init(void); +#if LV_FS_IF_PC != '\0' || LV_FS_IF_SD != '\0' +void lv_fs_if_pc_init(char letter, const char* path); #endif /********************** @@ -48,13 +55,16 @@ void lv_fs_if_pc_init(void); void lv_fs_if_init(void) { #if LV_FS_IF_FATFS != '\0' - lv_fs_if_fatfs_init(); + lv_fs_if_fatfs_init(); #endif #if LV_FS_IF_PC != '\0' - lv_fs_if_pc_init(); + lv_fs_if_pc_init(LV_FS_IF_PC, LV_FS_PC_PATH); #endif +#if LV_FS_IF_SD != '\0' + lv_fs_if_pc_init(LV_FS_IF_SD, LV_FS_SD_PATH); +#endif } /********************** diff --git a/lib/lv_fs_if/lv_fs_pc.c b/lib/lv_fs_if/lv_fs_pc.c index 02aa1a41..b83e1ac3 100644 --- a/lib/lv_fs_if/lv_fs_pc.c +++ b/lib/lv_fs_if/lv_fs_pc.c @@ -19,17 +19,6 @@ #include #endif -/********************* - * DEFINES - *********************/ -#ifndef LV_FS_PC_PATH -#ifndef WIN32 -#define LV_FS_PC_PATH "./" /*Projet root*/ -#else -#define LV_FS_PC_PATH ".\\" /*Projet root*/ -#endif -#endif /*LV_FS_PATH*/ - /********************** * TYPEDEFS **********************/ @@ -77,7 +66,7 @@ static lv_fs_res_t fs_dir_close(lv_fs_drv_t* drv, void* dir_p); /** * Register a driver for the File system interface */ -void lv_fs_if_pc_init(void) +void lv_fs_if_pc_init(char letter, const char* path) { /*--------------------------------------------------- * Register the file system interface in LittlevGL @@ -107,6 +96,8 @@ void lv_fs_if_pc_init(void) fs_drv.dir_open_cb = fs_dir_open; fs_drv.dir_read_cb = fs_dir_read; + fs_drv.user_data = LV_FS_PC_PATH; + lv_fs_drv_register(&fs_drv); // char cur_path[512] = ""; @@ -145,10 +136,10 @@ static lv_fs_res_t fs_open(lv_fs_drv_t* drv, void* file_p, const char* path, lv_ #ifndef WIN32 char buf[256]; - sprintf(buf, LV_FS_PC_PATH "/%s", path); + sprintf(buf, "%s/%s", drv->user_data, path); #else char buf[256]; - sprintf(buf, LV_FS_PC_PATH "\\%s", path); + sprintf(buf, "%s\\%s", drv->user_data, path); #endif LV_LOG_USER(buf); @@ -255,6 +246,7 @@ static lv_fs_res_t fs_size(lv_fs_drv_t* drv, void* file_p, uint32_t* size_p) return LV_FS_RES_OK; } + /** * Give the position of the read write pointer * @param drv pointer to a driver where this function belongs @@ -318,8 +310,8 @@ static lv_fs_res_t fs_rename(lv_fs_drv_t* drv, const char* oldname, const char* static char new[512]; static char old[512]; - sprintf(old, LV_FS_PC_PATH "/%s", oldname); - sprintf(new, LV_FS_PC_PATH "/%s", newname); + sprintf(old, "%s/%s", drv->user_data, oldname); + sprintf(new, "%s/%s", drv->user_data, newname); int r = rename(old, new); @@ -365,7 +357,7 @@ static lv_fs_res_t fs_dir_open(lv_fs_drv_t* drv, void* dir_p, const char* path) #ifndef WIN32 /*Make the path relative to the current directory (the projects root folder)*/ char buf[256]; - sprintf(buf, LV_FS_PC_PATH "/%s", path); + sprintf(buf, "%s/%s", drv->user_data, path); if((d = opendir(buf)) == NULL) { return LV_FS_RES_FS_ERR; } else { @@ -380,7 +372,7 @@ static lv_fs_res_t fs_dir_open(lv_fs_drv_t* drv, void* dir_p, const char* path) /*Make the path relative to the current directory (the projects root folder)*/ char buf[256]; - sprintf(buf, LV_FS_PC_PATH "\\%s\\*", path); + sprintf(buf, "%s\\%s\\*", drv->user_data, path); strcpy(next_fn, ""); d = FindFirstFile(buf, &fdata); diff --git a/user_setups/esp32/_esp32.ini b/user_setups/esp32/_esp32.ini index 780997e5..93079589 100644 --- a/user_setups/esp32/_esp32.ini +++ b/user_setups/esp32/_esp32.ini @@ -45,7 +45,7 @@ build_flags = -D LV_ATTRIBUTE_FAST_MEM=IRAM_ATTR -D LV_ATTRIBUTE_TASK_HANDLER=IRAM_ATTR -D LV_USE_FS_IF=1 - ;-D LV_FS_PC_PATH="//littlefs" ; this needs to match the vfs mount pount + -D LV_FS_PC_PATH='"/littlefs"' ; this needs to match the vfs mount pount ; -- ArduinoJson build options ---------------------------- -D ARDUINOJSON_ENABLE_PROGMEM=1 ; for PROGMEM arguments ; -- tft_espi build options ------------------------ diff --git a/user_setups/esp32s2/_esp32s2.ini b/user_setups/esp32s2/_esp32s2.ini index 0cfc0156..7b042521 100644 --- a/user_setups/esp32s2/_esp32s2.ini +++ b/user_setups/esp32s2/_esp32s2.ini @@ -15,7 +15,7 @@ build_flags = -D LV_ATTRIBUTE_FAST_MEM= -D LV_ATTRIBUTE_TASK_HANDLER=IRAM_ATTR -D LV_USE_FS_IF=1 - ;-D LV_FS_PC_PATH="//littlefs" ; this needs to match the vfs mount pount + -D LV_FS_PC_PATH='"/littlefs"' ; this needs to match the vfs mount pount ; -- ArduinoJson build options ---------------------------- -D ARDUINOJSON_ENABLE_PROGMEM=1 ; for PROGMEM arguments ; -- tft_espi build options ------------------------