- Sun Aug 29, 2010 9:09 pm
#108515
Hi all...
I'm writing up a tutorial based on a project I've been working on and in the process I've extracted a high-level wrapper library for SD card access. I thought some people might be interested in using it for their own purposes.
An alpha release is available from: http://sparkfun.com/Code/MemoryCard/Mem ... lpha-1.zip
The library wraps the standard sdfatlib library and provides some higher-level functions and provides four key benefits:
Example use:
Feel free to provide feedback.
--Philip;
I'm writing up a tutorial based on a project I've been working on and in the process I've extracted a high-level wrapper library for SD card access. I thought some people might be interested in using it for their own purposes.
An alpha release is available from: http://sparkfun.com/Code/MemoryCard/Mem ... lpha-1.zip
The library wraps the standard sdfatlib library and provides some higher-level functions and provides four key benefits:
- Including `MemoryCard.h` automatically creates a global `MemoryCard` object which can be interacted with in a similar manner to other standard global objects like `Serial` and `Ethernet`.
- Boilerplate initialisation code is contained in one method named `begin` and no further objects need to be created in order to access the memory card.
- Calls to `open` can supply a full path name including parent directories which simplifies interacting with files in subdirectories.
- Utility methods are provided to determine whether a file exists and to create a directory heirarchy.
Example use:
Code: Select all
I'm not entirely happy with the API (in terms of file interaction and read/write control) but it's a start and worked for the purpose for which I needed it. MemoryCard.begin();
MemoryCard.makeDir("/apple/banana/cabbage/");
if (MemoryCard.exists("/apple/banana/cabbage/")) {
...
}
MemoryCard.open("/apple/banana/cabbage/dolphin.txt", true);
MemoryCard.file.println("This line was appended to the file.");
MemoryCard.close();
Feel free to provide feedback.
--Philip;