Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fs): add Arduino ESP LittleFS driver #5905

Merged
merged 4 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat(drv): rename to arduino_esp_littlefs
  • Loading branch information
PierreRambaud committed Mar 19, 2024
commit e41ee42c701ec6aa4cc10ec32503752b567156f8
8 changes: 4 additions & 4 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1066,12 +1066,12 @@ menu "LVGL configuration"
default 0
depends on LV_USE_FS_LITTLEFS

config LV_USE_FS_ARDUINO_LITTLEFS
bool "File system on top of littlefs API"
config LV_FS_ARDUINO_LITTLEFS_LETTER
config LV_USE_FS_ARDUINO_ESP_LITTLEFS
bool "File system on top of Arduino ESP littlefs API"
config LV_FS_ARDUINO_ESP_LITTLEFS_LETTER
int "Set an upper cased letter on which the drive will accessible (e.g. 'A' i.e. 65)"
default 0
depends on LV_USE_FS_ARDUINO_LITTLEFS
depends on LV_USE_FS_ARDUINO_ESP_LITTLEFS

config LV_USE_LODEPNG
bool "PNG decoder library"
Expand Down
10 changes: 5 additions & 5 deletions docs/libs/arduino-littlefs.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.. _arduino_littlefs:
.. _arduino_esp_littlefs:

================
Arduino littlefs
================
====================
Arduino ESP littlefs
====================

LittleFS is a little fail-safe filesystem designed for microcontrollers and integrated in the Arduino framework
when used with ESP32 and ESP8266.
Expand All @@ -15,7 +15,7 @@ Detailed introduction:
Usage
-----

Enable :c:macro:`LV_USE_FS_ARDUINO_LITTLEFS` and define a :c:macro`LV_FS_ARDUINO_LITTLEFS_LETTER` in ``lv_conf.h``.
Enable :c:macro:`LV_USE_FS_ARDUINO_ESP_LITTLEFS` and define a :c:macro`LV_FS_ARDUINO_ESP_LITTLEFS_LETTER` in ``lv_conf.h``.


API
Expand Down
2 changes: 1 addition & 1 deletion docs/libs/fs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ LVG has built in support for:
- WIN32 (Windows using Win32 API function .e.g ``CreateFileA``, ``ReadFile``)
- MEMFS (read a file from a memory buffer)
- LITTLEFS (a little fail-safe filesystem designed for microcontrollers)
- Arduino LITTLEFS (a little fail-safe filesystem designed for Arduino ESP)
- Arduino ESP LITTLEFS (a little fail-safe filesystem designed for Arduino ESP)

You still need to provide the drivers and libraries, this extension
provides only the bridge between FATFS, STDIO, POSIX, WIN32 and LVGL.
Expand Down
2 changes: 1 addition & 1 deletion docs/libs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
rlottie
ffmpeg
rle
arduino_littlefs
arduino_esp_littlefs
lfs
6 changes: 3 additions & 3 deletions lv_conf_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -658,9 +658,9 @@
#endif

/*API for Arduino LittleFs. */
#define LV_USE_FS_ARDUINO_LITTLEFS 0
#if LV_USE_FS_ARDUINO_LITTLEFS
#define LV_FS_ARDUINO_LITTLEFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
#define LV_USE_FS_ARDUINO_ESP_LITTLEFS 0
#if LV_USE_FS_ARDUINO_ESP_LITTLEFS
#define LV_FS_ARDUINO_ESP_LITTLEFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
#endif

/*LODEPNG decoder library*/
Expand Down
4 changes: 2 additions & 2 deletions src/core/lv_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ typedef struct _lv_global_t {
lv_fs_drv_t littlefs_fs_drv;
#endif

#if LV_USE_FS_ARDUINO_LITTLEFS
lv_fs_drv_t arduino_littlefs_fs_drv;
#if LV_USE_FS_ARDUINO_ESP_LITTLEFS
lv_fs_drv_t arduino_esp_littlefs_fs_drv;
#endif

#if LV_USE_FREETYPE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "../../../lvgl.h"
#if LV_USE_FS_ARDUINO_LITTLEFS
#if LV_USE_FS_ARDUINO_ESP_LITTLEFS

#include "../../core/lv_global.h"
#include "LittleFS.h"

typedef struct ArduinoLittleFile {
typedef struct ArduinoEspLittleFile {
File file;
} ArduinoLittleFile;
} ArduinoEspLittleFile;

/**********************
* STATIC PROTOTYPES
Expand All @@ -22,14 +22,14 @@ static lv_fs_res_t fs_tell(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p);
/**
* Register a driver for the LittleFS File System interface
*/
extern "C" void lv_fs_arduino_littlefs_init(void)
extern "C" void lv_fs_arduino_esp_littlefs_init(void)
{
fs_init();

lv_fs_drv_t * fs_drv = &(LV_GLOBAL_DEFAULT()->arduino_littlefs_fs_drv);
lv_fs_drv_t * fs_drv = &(LV_GLOBAL_DEFAULT()->arduino_esp_littlefs_fs_drv);
lv_fs_drv_init(fs_drv);

fs_drv->letter = LV_FS_ARDUINO_LITTLEFS_LETTER;
fs_drv->letter = LV_FS_ARDUINO_ESP_LITTLEFS_LETTER;
fs_drv->open_cb = fs_open;
fs_drv->close_cb = fs_close;
fs_drv->read_cb = fs_read;
Expand Down Expand Up @@ -78,7 +78,7 @@ static void * fs_open(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode)
return NULL;
}

ArduinoLittleFile * lf = new ArduinoLittleFile{file};
ArduinoEspLittleFile * lf = new ArduinoEspLittleFile{file};

return (void *)lf;
}
Expand All @@ -92,7 +92,7 @@ static void * fs_open(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode)
static lv_fs_res_t fs_close(lv_fs_drv_t * drv, void * file_p)
{
LV_UNUSED(drv);
ArduinoLittleFile * lf = (ArduinoLittleFile *)file_p;
ArduinoEspLittleFile * lf = (ArduinoEspLittleFile *)file_p;
lf->file.close();
lv_free(lf);

Expand All @@ -111,7 +111,7 @@ static lv_fs_res_t fs_close(lv_fs_drv_t * drv, void * file_p)
static lv_fs_res_t fs_read(lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br)
{
LV_UNUSED(drv);
ArduinoLittleFile * lf = (ArduinoLittleFile *)file_p;
ArduinoEspLittleFile * lf = (ArduinoEspLittleFile *)file_p;
*br = lf->file.read((uint8_t *)buf, btr);

return (int32_t)(*br) < 0 ? LV_FS_RES_UNKNOWN : LV_FS_RES_OK;
Expand All @@ -129,7 +129,7 @@ static lv_fs_res_t fs_read(lv_fs_drv_t * drv, void * file_p, void * buf, uint32_
static lv_fs_res_t fs_write(lv_fs_drv_t * drv, void * file_p, const void * buf, uint32_t btw, uint32_t * bw)
{
LV_UNUSED(drv);
ArduinoLittleFile * lf = (ArduinoLittleFile *)file_p;
ArduinoEspLittleFile * lf = (ArduinoEspLittleFile *)file_p;
*bw = lf->file.write((uint8_t *)buf, btw);

return (int32_t)(*bw) < 0 ? LV_FS_RES_UNKNOWN : LV_FS_RES_OK;
Expand All @@ -154,7 +154,7 @@ static lv_fs_res_t fs_seek(lv_fs_drv_t * drv, void * file_p, uint32_t pos, lv_fs
else if(whence == LV_FS_SEEK_END)
mode = SeekEnd;

ArduinoLittleFile * lf = (ArduinoLittleFile *)file_p;
ArduinoEspLittleFile * lf = (ArduinoEspLittleFile *)file_p;

int rc = lf->file.seek(pos, mode);

Expand All @@ -171,7 +171,7 @@ static lv_fs_res_t fs_seek(lv_fs_drv_t * drv, void * file_p, uint32_t pos, lv_fs
static lv_fs_res_t fs_tell(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p)
{
LV_UNUSED(drv);
ArduinoLittleFile * lf = (ArduinoLittleFile *)file_p;
ArduinoEspLittleFile * lf = (ArduinoEspLittleFile *)file_p;

*pos_p = lf->file.position();

Expand Down
4 changes: 2 additions & 2 deletions src/libs/fsdrv/lv_fsdrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ void lv_fs_memfs_init(void);
void lv_fs_littlefs_init(void);
#endif

#if LV_USE_FS_ARDUINO_LITTLEFS
void lv_fs_arduino_littlefs_init(void);
#if LV_USE_FS_ARDUINO_ESP_LITTLEFS
void lv_fs_arduino_esp_littlefs_init(void);
#endif

/**********************
Expand Down
18 changes: 9 additions & 9 deletions src/lv_conf_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -2174,19 +2174,19 @@
#endif

/*API for Arduino LittleFs. */
PGNetHun marked this conversation as resolved.
Show resolved Hide resolved
#ifndef LV_USE_FS_ARDUINO_LITTLEFS
#ifdef CONFIG_LV_USE_FS_ARDUINO_LITTLEFS
#define LV_USE_FS_ARDUINO_LITTLEFS CONFIG_LV_USE_FS_ARDUINO_LITTLEFS
#ifndef LV_USE_FS_ARDUINO_ESP_LITTLEFS
#ifdef CONFIG_LV_USE_FS_ARDUINO_ESP_LITTLEFS
#define LV_USE_FS_ARDUINO_ESP_LITTLEFS CONFIG_LV_USE_FS_ARDUINO_ESP_LITTLEFS
#else
#define LV_USE_FS_ARDUINO_LITTLEFS 0
#define LV_USE_FS_ARDUINO_ESP_LITTLEFS 0
#endif
#endif
#if LV_USE_FS_ARDUINO_LITTLEFS
#ifndef LV_FS_ARDUINO_LITTLEFS_LETTER
#ifdef CONFIG_LV_FS_ARDUINO_LITTLEFS_LETTER
#define LV_FS_ARDUINO_LITTLEFS_LETTER CONFIG_LV_FS_ARDUINO_LITTLEFS_LETTER
#if LV_USE_FS_ARDUINO_ESP_LITTLEFS
#ifndef LV_FS_ARDUINO_ESP_LITTLEFS_LETTER
#ifdef CONFIG_LV_FS_ARDUINO_ESP_LITTLEFS_LETTER
#define LV_FS_ARDUINO_ESP_LITTLEFS_LETTER CONFIG_LV_FS_ARDUINO_ESP_LITTLEFS_LETTER
#else
#define LV_FS_ARDUINO_LITTLEFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
#define LV_FS_ARDUINO_ESP_LITTLEFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
#endif
#endif
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/lv_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ void lv_init(void)
lv_fs_littlefs_init();
#endif

#if LV_USE_FS_ARDUINO_LITTLEFS
lv_fs_arduino_littlefs_init();
#if LV_USE_FS_ARDUINO_ESP_LITTLEFS
lv_fs_arduino_esp_littlefs_init();
#endif

#if LV_USE_LODEPNG
Expand Down
Loading