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

Enhance the filesystem #742

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Martinson50
Copy link

@Martinson50 Martinson50 commented May 23, 2024

Hi everybody again.
I finaly learn how to use github in a proper way (I hope so) so I decided to start again and add some code to make an SDCard when avalaible, as in Sunton plates, and put an imaginary Z: unit as a source in images an json files.

I only tested on my Sunton-4827s043c_16MB and it works with a 16Gb Cat.4 card
example in pages.jsonl

{"page":1,"id":4,"obj":"img","x":0,"y":65,"src":"Z:/cycle.png","auto_size":false,"w":128,"h":128}

you can of course send from HA custom component in configuration yaml as:
plate:
objects:
- obj: "p1b4"
properties:
"src": "Z:/airplane.png"

@FreeBear-nc
Copy link
Contributor

Looked at the changes, and tried compiling it here (failing with a whole stack of errors). Compile time failures aside, some comments in no particular order:

sdcardsetup() will kinda work, but attempts to access the card later on will fail (on my board, and probably others). There is a conflict between TFT and SD using the same SPI pins during setup. The answer is to defer sdcardsetup() until after TFT setup is complete.
It is a bad idea to hard bake SPI clock speed in to the code, and doubly bad to limit it to just 1MHz. The ESP32 can go to 40MHz when using the GPIO matrix pins. But due to PCB design/layout, this may not always be possible. A side note: defines for SPI pins should be encased in an ifndef/endif pair. You then avoid compile time warnings about SPI_MOSI & friends being redefined.
listdir_SD is just a rehash of filesystemList() but using the function prototype of filesystem_list() without returning the data of the latter. filesystemList() is only called once during set up, and just lists files found to LOG_VERBOSE. Beyond that, it doesn't really serve much purpose that I can see.
special_attribute_src() duplicates a sizable chunk of code from further on in the same function that is used to process HTTP requests. You should be treating file access the same as drive L (or littleFS).

@fvanroie
Copy link
Collaborator

fvanroie commented May 24, 2024

Since @Martinson50 is new to PRs on GitHub, I am not set to merge this code as is. But it can be used to see how he solved the problem for his device.

We'll need to focus on adding devices one-by-one in an easy configurable way, without breaking existing stuff.

@Martinson50
Copy link
Author

Martinson50 commented May 24, 2024 via email

@Martinson50
Copy link
Author

special_attribute_src() duplicates a sizable chunk of code from further on in the same function that is used to process HTTP requests. You should be treating file access the same as drive L (or littleFS).

You mean to use a simple 'lv_img_set_src' instead of a duplicate code for http?
But I wanted to have at the same time SDCard and spiff filesystem and with lv_img_set_src you should register several systems.
lv_fs_drv_register(&spifffs);
lv_fs_drv_register(&sdfs);

@fvanroie
Copy link
Collaborator

fvanroie commented May 24, 2024

I'm updating the LVFS driver so that both /littlefs and /sdcard drive letters can be used simultaneously. LVGL integration is actually the easy part. You don't need to check for L: or Z: prefix, LVGL will handle it automatically.

@Martinson50
Copy link
Author

Martinson50 commented May 24, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants