diff --git a/libraries/MemoryCard/MemoryCard.h b/libraries/MemoryCard/MemoryCard.h deleted file mode 100644 index 180671f96..000000000 --- a/libraries/MemoryCard/MemoryCard.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - - MemoryCard - a slightly more friendly wrapper for sdfatlib - - This library aims to expose a subset of SD card functionality - in the form of a higher level "wrapper" object. - - License: GNU General Public License V3 - (Because sdfatlib is licensed with this.) - - (C) Copyright 2010 SparkFun Electronics - - */ - -#ifndef __MEMORY_CARD_H__ -#define __MEMORY_CARD_H__ - -#include "MemoryCardDevice.h" - -extern MemoryCardDevice MemoryCard; - -// Preinstantiate required object -MemoryCardDevice MemoryCard; - -#endif diff --git a/libraries/MemoryCard/README.txt b/libraries/SD/README.txt similarity index 100% rename from libraries/MemoryCard/README.txt rename to libraries/SD/README.txt diff --git a/libraries/MemoryCard/MemoryCardDevice.cpp b/libraries/SD/SD.cpp similarity index 91% rename from libraries/MemoryCard/MemoryCardDevice.cpp rename to libraries/SD/SD.cpp index a12779105..e76ad7d79 100644 --- a/libraries/MemoryCard/MemoryCardDevice.cpp +++ b/libraries/SD/SD.cpp @@ -1,6 +1,6 @@ /* - MemoryCard - a slightly more friendly wrapper for sdfatlib + SD - a slightly more friendly wrapper for sdfatlib This library aims to expose a subset of SD card functionality in the form of a higher level "wrapper" object. @@ -13,13 +13,13 @@ This library provides four key benefits: - * Including `MemoryCard.h` automatically creates a global - `MemoryCard` object which can be interacted with in a similar + * Including `SD.h` automatically creates a global + `SD` 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. + the SD card. * Calls to `open` can supply a full path name including parent directories which simplifies interacting with files in subdirectories. @@ -50,10 +50,10 @@ */ -#include "MemoryCardDevice.h" +#include "SD.h" // Use this to configure the chip select pin of the SD card. -#define SD_CARD_CHIP_SELECT_PIN 8 // For use with SparkFun MicroSD shield +#define SD_CARD_CHIP_SELECT_PIN 4 // For use with Arduino Ethernet Shield // Used by `getNextPathComponent` @@ -286,7 +286,7 @@ boolean callback_openPath(SdFile& parentDir, char *filePathComponent, Callback used to open a file specified by a filepath that may specify one or more directories above it. - Expects the context object to be an instance of `MemoryCard` and + Expects the context object to be an instance of `SDClass` and will use the `file` property of the instance to open the requested file/directory with the associated file open mode property. @@ -298,7 +298,7 @@ boolean callback_openPath(SdFile& parentDir, char *filePathComponent, */ if (isLastComponent) { - MemoryCardDevice *p_MemoryCard = static_cast(object); + SDClass *p_MemoryCard = static_cast(object); p_MemoryCard->file.open(parentDir, filePathComponent, p_MemoryCard->fileOpenMode); // TODO: Return file open result? @@ -309,9 +309,9 @@ boolean callback_openPath(SdFile& parentDir, char *filePathComponent, -/* Implementation of class used to create `MemoryCard` object. */ +/* Implementation of class used to create `SDCard` object. */ -void MemoryCardDevice::begin() { +void SDClass::begin() { /* Performs the initialisation required by the sdfatlib library. @@ -329,14 +329,14 @@ void MemoryCardDevice::begin() { } -boolean MemoryCardDevice::open(char *filepath, +boolean SDClass::open(char *filepath, boolean write, boolean append) { /* Open the supplied file path for reading or writing. The file content can be accessed via the `file` property of - the `MemoryCardDevice` object--this property is currently + the `SDClass` object--this property is currently a standard `SdFile` object from `sdfatlib`. Defaults to read only. @@ -375,7 +375,7 @@ boolean MemoryCardDevice::open(char *filepath, } -boolean MemoryCardDevice::close() { +boolean SDClass::close() { /* Closes the file opened by the `open` method. @@ -385,7 +385,7 @@ boolean MemoryCardDevice::close() { } -boolean MemoryCardDevice::exists(char *filepath) { +boolean SDClass::exists(char *filepath) { /* Returns true if the supplied file path exists. @@ -395,7 +395,7 @@ boolean MemoryCardDevice::exists(char *filepath) { } -boolean MemoryCardDevice::exists(char *filepath, SdFile& parentDir) { +boolean SDClass::exists(char *filepath, SdFile& parentDir) { /* Returns true if the supplied file path rooted at `parentDir` @@ -406,7 +406,7 @@ boolean MemoryCardDevice::exists(char *filepath, SdFile& parentDir) { } -boolean MemoryCardDevice::makeDir(char *filepath) { +boolean SDClass::makeDir(char *filepath) { /* Makes a single directory or a heirarchy of directories. @@ -416,3 +416,5 @@ boolean MemoryCardDevice::makeDir(char *filepath) { */ return walkPath(filepath, root, callback_makeDirPath); } + +SDClass SD; \ No newline at end of file diff --git a/libraries/MemoryCard/MemoryCardDevice.h b/libraries/SD/SD.h similarity index 96% rename from libraries/MemoryCard/MemoryCardDevice.h rename to libraries/SD/SD.h index d560a251b..512d47631 100644 --- a/libraries/MemoryCard/MemoryCardDevice.h +++ b/libraries/SD/SD.h @@ -17,9 +17,9 @@ #include -#include +#include -class MemoryCardDevice { +class SDClass { private: // These are required for initialisation and use of sdfatlib @@ -62,4 +62,6 @@ class MemoryCardDevice { int fileOpenMode; // TODO: Don't make this public? }; +extern SDClass SD; + #endif diff --git a/libraries/MemoryCard/examples/FeatureDemo/FeatureDemo.pde b/libraries/SD/examples/FeatureDemo/FeatureDemo.pde similarity index 62% rename from libraries/MemoryCard/examples/FeatureDemo/FeatureDemo.pde rename to libraries/SD/examples/FeatureDemo/FeatureDemo.pde index 766ea7cd8..b2c7eb705 100644 --- a/libraries/MemoryCard/examples/FeatureDemo/FeatureDemo.pde +++ b/libraries/SD/examples/FeatureDemo/FeatureDemo.pde @@ -1,27 +1,25 @@ /* - A sketch to demonstrate the features of the MemoryCard library. + A sketch to demonstrate the features of the SD library. */ -// At the moment you need to include both the SdFat and MemoryCard libraries. -#include -#include +#include void setup() { Serial.begin(9600); - // You always need to initialise the MemoryCard library - Serial.println("Init MemoryCard..."); - MemoryCard.begin(); + // You always need to initialise the SD library + Serial.println("Init SD..."); + SD.begin(); // This demonstrates making a directory hierarchy Serial.println(); Serial.println("Make directory..."); - MemoryCard.makeDir("/apple/banana/cabbage/"); + SD.makeDir("/apple/banana/cabbage/"); // You can check for the existence of specific files/directories @@ -32,7 +30,7 @@ void setup() { Serial.print(filePathOne); Serial.print(" does "); - if (MemoryCard.exists(filePathOne)) { + if (SD.exists(filePathOne)) { Serial.println("exist."); } else { Serial.println("not exist."); @@ -40,7 +38,7 @@ void setup() { Serial.print(filePathTwo); Serial.print(" does "); - if (MemoryCard.exists(filePathTwo)) { + if (SD.exists(filePathTwo)) { Serial.println("exist."); } else { Serial.println("not exist."); @@ -52,11 +50,11 @@ void setup() { Serial.println(); Serial.println("Writing to 'dolphin.txt'."); - MemoryCard.open("/apple/banana/cabbage/dolphin.txt", true); + SD.open("/apple/banana/cabbage/dolphin.txt", true); - MemoryCard.file.println("This line was appended to the file."); + SD.file.println("This line was appended to the file."); - MemoryCard.close(); + SD.close(); // Demonstrate writing to a file in the root directory and overwriting any @@ -64,45 +62,45 @@ void setup() { Serial.println(); Serial.println("Writing to 'top.txt'."); - MemoryCard.open("/top.txt", true, false); + SD.open("/top.txt", true, false); - MemoryCard.file.println("This line overwrote the previous content of the file."); + SD.file.println("This line overwrote the previous content of the file."); - MemoryCard.close(); + SD.close(); // Demonstrate reading from a file in a subdirectory Serial.println(); Serial.println("Reading 'dolphin.txt':"); - MemoryCard.open("/apple/banana/cabbage/dolphin.txt"); + SD.open("/apple/banana/cabbage/dolphin.txt"); int c; // This approach may be easier to follow while(true) { - c = MemoryCard.file.read(); + c = SD.file.read(); if (c < 0) { break; } Serial.print((char) c); } - MemoryCard.close(); + SD.close(); // Demonstrate reading from a file in the root directory in a slightly different way Serial.println(); Serial.println("Reading 'top.txt':"); - MemoryCard.open("/top.txt"); + SD.open("/top.txt"); // This approach is more compact - while((c = MemoryCard.file.read()) >= 0) { + while((c = SD.file.read()) >= 0) { Serial.print((char) c); } - MemoryCard.close(); + SD.close(); // Demonstration complete! diff --git a/libraries/SdFat/FatStructs.h b/libraries/SD/utility/FatStructs.h similarity index 100% rename from libraries/SdFat/FatStructs.h rename to libraries/SD/utility/FatStructs.h diff --git a/libraries/SdFat/Sd2Card.cpp b/libraries/SD/utility/Sd2Card.cpp similarity index 96% rename from libraries/SdFat/Sd2Card.cpp rename to libraries/SD/utility/Sd2Card.cpp index 8222cfd93..26c4236ac 100755 --- a/libraries/SdFat/Sd2Card.cpp +++ b/libraries/SD/utility/Sd2Card.cpp @@ -227,6 +227,7 @@ uint8_t Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) { #ifndef SOFTWARE_SPI // SS must be in output mode even it is not chip select pinMode(SS_PIN, OUTPUT); + digitalWrite(SS_PIN, HIGH); // disable any SPI device using hardware SS pin // Enable SPI, Master, clock rate f_osc/128 SPCR = (1 << SPE) | (1 << MSTR) | (1 << SPR1) | (1 << SPR0); // clear double speed diff --git a/libraries/SdFat/Sd2Card.h b/libraries/SD/utility/Sd2Card.h similarity index 100% rename from libraries/SdFat/Sd2Card.h rename to libraries/SD/utility/Sd2Card.h diff --git a/libraries/SdFat/Sd2PinMap.h b/libraries/SD/utility/Sd2PinMap.h similarity index 100% rename from libraries/SdFat/Sd2PinMap.h rename to libraries/SD/utility/Sd2PinMap.h diff --git a/libraries/SdFat/SdFat.h b/libraries/SD/utility/SdFat.h similarity index 100% rename from libraries/SdFat/SdFat.h rename to libraries/SD/utility/SdFat.h diff --git a/libraries/SdFat/SdFatUtil.h b/libraries/SD/utility/SdFatUtil.h similarity index 100% rename from libraries/SdFat/SdFatUtil.h rename to libraries/SD/utility/SdFatUtil.h diff --git a/libraries/SdFat/SdFatmainpage.h b/libraries/SD/utility/SdFatmainpage.h similarity index 100% rename from libraries/SdFat/SdFatmainpage.h rename to libraries/SD/utility/SdFatmainpage.h diff --git a/libraries/SdFat/SdFile.cpp b/libraries/SD/utility/SdFile.cpp similarity index 100% rename from libraries/SdFat/SdFile.cpp rename to libraries/SD/utility/SdFile.cpp diff --git a/libraries/SdFat/SdInfo.h b/libraries/SD/utility/SdInfo.h similarity index 100% rename from libraries/SdFat/SdInfo.h rename to libraries/SD/utility/SdInfo.h diff --git a/libraries/SdFat/SdVolume.cpp b/libraries/SD/utility/SdVolume.cpp similarity index 100% rename from libraries/SdFat/SdVolume.cpp rename to libraries/SD/utility/SdVolume.cpp diff --git a/libraries/SdFat/examples/SdFatAnalogLogger/SdFatAnalogLogger.pde b/libraries/SD/utility/examples/SdFatAnalogLogger/SdFatAnalogLogger.pde similarity index 100% rename from libraries/SdFat/examples/SdFatAnalogLogger/SdFatAnalogLogger.pde rename to libraries/SD/utility/examples/SdFatAnalogLogger/SdFatAnalogLogger.pde diff --git a/libraries/SdFat/examples/SdFatAppend/SdFatAppend.pde b/libraries/SD/utility/examples/SdFatAppend/SdFatAppend.pde similarity index 100% rename from libraries/SdFat/examples/SdFatAppend/SdFatAppend.pde rename to libraries/SD/utility/examples/SdFatAppend/SdFatAppend.pde diff --git a/libraries/SdFat/examples/SdFatBench/SdFatBench.pde b/libraries/SD/utility/examples/SdFatBench/SdFatBench.pde similarity index 100% rename from libraries/SdFat/examples/SdFatBench/SdFatBench.pde rename to libraries/SD/utility/examples/SdFatBench/SdFatBench.pde diff --git a/libraries/SdFat/examples/SdFatCopy/SdFatCopy.pde b/libraries/SD/utility/examples/SdFatCopy/SdFatCopy.pde similarity index 100% rename from libraries/SdFat/examples/SdFatCopy/SdFatCopy.pde rename to libraries/SD/utility/examples/SdFatCopy/SdFatCopy.pde diff --git a/libraries/SdFat/examples/SdFatGPSLogger_v3/SdFatGPSLogger_v3.pde b/libraries/SD/utility/examples/SdFatGPSLogger_v3/SdFatGPSLogger_v3.pde similarity index 100% rename from libraries/SdFat/examples/SdFatGPSLogger_v3/SdFatGPSLogger_v3.pde rename to libraries/SD/utility/examples/SdFatGPSLogger_v3/SdFatGPSLogger_v3.pde diff --git a/libraries/SdFat/examples/SdFatGPS_CSVSensorLogger/SdFatGPS_CSVSensorLogger.pde b/libraries/SD/utility/examples/SdFatGPS_CSVSensorLogger/SdFatGPS_CSVSensorLogger.pde similarity index 100% rename from libraries/SdFat/examples/SdFatGPS_CSVSensorLogger/SdFatGPS_CSVSensorLogger.pde rename to libraries/SD/utility/examples/SdFatGPS_CSVSensorLogger/SdFatGPS_CSVSensorLogger.pde diff --git a/libraries/SdFat/examples/SdFatInfo/SdFatInfo.pde b/libraries/SD/utility/examples/SdFatInfo/SdFatInfo.pde similarity index 100% rename from libraries/SdFat/examples/SdFatInfo/SdFatInfo.pde rename to libraries/SD/utility/examples/SdFatInfo/SdFatInfo.pde diff --git a/libraries/SdFat/examples/SdFatLs/SdFatLs.pde b/libraries/SD/utility/examples/SdFatLs/SdFatLs.pde similarity index 100% rename from libraries/SdFat/examples/SdFatLs/SdFatLs.pde rename to libraries/SD/utility/examples/SdFatLs/SdFatLs.pde diff --git a/libraries/SdFat/examples/SdFatMakeDir/SdFatMakeDir.pde b/libraries/SD/utility/examples/SdFatMakeDir/SdFatMakeDir.pde similarity index 100% rename from libraries/SdFat/examples/SdFatMakeDir/SdFatMakeDir.pde rename to libraries/SD/utility/examples/SdFatMakeDir/SdFatMakeDir.pde diff --git a/libraries/SdFat/examples/SdFatPrint/SdFatPrint.pde b/libraries/SD/utility/examples/SdFatPrint/SdFatPrint.pde similarity index 100% rename from libraries/SdFat/examples/SdFatPrint/SdFatPrint.pde rename to libraries/SD/utility/examples/SdFatPrint/SdFatPrint.pde diff --git a/libraries/SdFat/examples/SdFatRawWrite/SdFatRawWrite.pde b/libraries/SD/utility/examples/SdFatRawWrite/SdFatRawWrite.pde similarity index 100% rename from libraries/SdFat/examples/SdFatRawWrite/SdFatRawWrite.pde rename to libraries/SD/utility/examples/SdFatRawWrite/SdFatRawWrite.pde diff --git a/libraries/SdFat/examples/SdFatRead/SdFatRead.pde b/libraries/SD/utility/examples/SdFatRead/SdFatRead.pde similarity index 100% rename from libraries/SdFat/examples/SdFatRead/SdFatRead.pde rename to libraries/SD/utility/examples/SdFatRead/SdFatRead.pde diff --git a/libraries/SdFat/examples/SdFatRemove/SdFatRemove.pde b/libraries/SD/utility/examples/SdFatRemove/SdFatRemove.pde similarity index 100% rename from libraries/SdFat/examples/SdFatRemove/SdFatRemove.pde rename to libraries/SD/utility/examples/SdFatRemove/SdFatRemove.pde diff --git a/libraries/SdFat/examples/SdFatRewrite/SdFatRewrite.pde b/libraries/SD/utility/examples/SdFatRewrite/SdFatRewrite.pde similarity index 100% rename from libraries/SdFat/examples/SdFatRewrite/SdFatRewrite.pde rename to libraries/SD/utility/examples/SdFatRewrite/SdFatRewrite.pde diff --git a/libraries/SdFat/examples/SdFatRmDir/SdFatRmDir.pde b/libraries/SD/utility/examples/SdFatRmDir/SdFatRmDir.pde similarity index 100% rename from libraries/SdFat/examples/SdFatRmDir/SdFatRmDir.pde rename to libraries/SD/utility/examples/SdFatRmDir/SdFatRmDir.pde diff --git a/libraries/SdFat/examples/SdFatTail/SdFatTail.pde b/libraries/SD/utility/examples/SdFatTail/SdFatTail.pde similarity index 100% rename from libraries/SdFat/examples/SdFatTail/SdFatTail.pde rename to libraries/SD/utility/examples/SdFatTail/SdFatTail.pde diff --git a/libraries/SdFat/examples/SdFatTimestamp/SdFatTimestamp.pde b/libraries/SD/utility/examples/SdFatTimestamp/SdFatTimestamp.pde similarity index 100% rename from libraries/SdFat/examples/SdFatTimestamp/SdFatTimestamp.pde rename to libraries/SD/utility/examples/SdFatTimestamp/SdFatTimestamp.pde diff --git a/libraries/SdFat/examples/SdFatTruncate/SdFatTruncate.pde b/libraries/SD/utility/examples/SdFatTruncate/SdFatTruncate.pde similarity index 100% rename from libraries/SdFat/examples/SdFatTruncate/SdFatTruncate.pde rename to libraries/SD/utility/examples/SdFatTruncate/SdFatTruncate.pde diff --git a/libraries/SdFat/examples/SdFatWrite/SdFatWrite.pde b/libraries/SD/utility/examples/SdFatWrite/SdFatWrite.pde similarity index 100% rename from libraries/SdFat/examples/SdFatWrite/SdFatWrite.pde rename to libraries/SD/utility/examples/SdFatWrite/SdFatWrite.pde diff --git a/libraries/SdFat/examples/clean.bat b/libraries/SD/utility/examples/clean.bat similarity index 100% rename from libraries/SdFat/examples/clean.bat rename to libraries/SD/utility/examples/clean.bat