-->
Page 1 of 2

Store Arrays in Flash - spiffs?

PostPosted: Tue Oct 25, 2016 5:05 pm
by gavspav
I have some large arrays in my sketch (24 bit image data) and I've run out of ram. I'm using a Wemos D1 R2.
It looks like using spiffs is the best way to store them - is that a good way to go?

I can save a text file into a data folder and read it in my sketch, output it to the serial monitor.
I'm wondering the best way to read the data into an array.
A text file means parsing each byte and converting it into numerical values. This seems inefficient.
I guess I could write the file from a sketch byte by byte - this would make it easier.

Any hints or pointers,

Thanks

Re: Store Arrays in Flash - spiffs?

PostPosted: Tue Oct 25, 2016 5:46 pm
by martinayotte
It is not clear what you wish to do with this array which is actually an image.
Are you sending it to a LCD display or a Web page ?

SPIFFS.read() and SPIFFS.write() can handle binaries bytes directly, so you can have a buffer with specific size, such as 1024 or 2048, and simply loop until end-of-file.

Take a look at this post which describes how to send files to browser :
viewtopic.php?p=57118#p57118

Re: Store Arrays in Flash - spiffs?

PostPosted: Tue Oct 25, 2016 6:08 pm
by gavspav
I want to load the image data into an array so I can loop through it and send it to a strip of LEDS for a persistence of vision display. Each array has 7744 24 bit colour values. I read them from the array 44 at a time and send them out to the pixels.

Thanks for the example but I don't really understand it, sorry. :oops:
Is there an example of the write function somewhere?

Re: Store Arrays in Flash - spiffs?

PostPosted: Tue Oct 25, 2016 7:02 pm
by martinayotte
Sorry if the code didn't help you.

For POV, @mkeyno is trying to do similar things, search about his posts ...

From what I've remember, he got stuck about SPIFFS speed performance, but I suggest him to use Plain Flash Raw Read instead.
Maybe he achieve some steps forwards since then...