Storing & Reading Large Arrays on Micro SD Card?

Status
Not open for further replies.

NewLinuxFan

Well-known member
Is there a way to do this besides saving a text file and reading back every digit, comma, brace, and bracket? I'm thinking of something like how PROGMEM arrays are stored and then read back during a sketch. I would like to convert a text file into something more efficient and store that on a micro SD card for a Teensy to read.

If nobody does it that way, and everyone is just storing their large arrays as text files on SD cards, I would be interested in seeing an example instead of re-inventing the wheel by coding it myself.

Please excuse me if this has been discussed in another thread. I searched and was not able to find it. Also searched the Arduino forum, and the closest thing I found is someone suggested using a similar method as this code but modifying it for SD cards instead of EEPROM:
http://playground.arduino.cc/Code/EEPROMWriteAnything
I'm a bit rusty on pointers and need to brush up on that subject to understand what it's doing, then figure out what the equivalent is on an SD card. Is this the best route to follow? I would imagine I'd have to code something in C language to run on a computer (something I have little knowledge of) to convert the text file. Any advice would be greatly appreciated.
 
How large are your arrays? PROGMEM is not needed on teensy as long as you declare the array const it will be stored in flash without all the headaches of PROGMEM calls
 
Is there a way to do this besides saving a text file and reading back every digit, comma, brace, and bracket?

you can write anything to SD cards and read it back.
writing junks of large amount of binary data is standard procedure.
so what is the problem?
 
I'm guessing there's also a discussion or guide somewhere on converting C language arrays into binary format using a computer.

No conversion required, nowadays all data are internally stored as binary in a computer. Search for difference of 'printf' and 'write' for writing formatted or binary data respectively to disk.
 
Thanks again. I'll read up on that. This is new stuff for me. Sounds like the learning curve is not as bad as I thought it might be.
 
Status
Not open for further replies.
Back
Top