Skip to content

Commit b8e6f66

Browse files
Earle F. Philhower, IIIEarle F. Philhower, III
authored andcommitted
Wrap all objects/definitions in namespace sdfat
Fork upstream to add a "namespace sdfat { ... };" wrapper around all objects, constants, definitions, and other routines in the SdFat library. This is necessary the ESP8266 because we already have classes of the types used in this library.
1 parent f0c65da commit b8e6f66

File tree

107 files changed

+512
-39
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+512
-39
lines changed

README.esp8266.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
This is a downstream version of Bill Greiman's <[email protected]>
2+
"SdFat" library for Arduino.
3+
4+
No code changes were intended to be made. Only a custom namespace called
5+
"sdfat" was wrapped around all objects and structures in the library.
6+
This namespace is required because the ESP8266 already has global class
7+
types whose names conflict with SdFat's built-in ones (File, others).
8+
9+
"using namespace sdfat;" at the top of a sketch should make it work as-is,
10+
and all examples have been so updated.
11+
12+
By performing this wrapping I hope to be able to integrate the latest
13+
updates from upstream and pull them into an ESP8266 compatible FS (like
14+
SPIFFS or LittleFS) to make it much more useful and work much better with
15+
the ESP8266 Arduino ecosystem.
16+
17+
-Earle F. Philhower, III <[email protected]>

examples/#attic/AnalogLogger/AnalogLogger.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include "sdios.h"
66
#include "FreeStack.h"
77

8+
using namespace sdfat;
9+
810
#define SD_CHIP_SELECT SS // SD chip select pin
911
#define USE_DS1307 0 // set nonzero to use DS1307 RTC
1012
#define LOG_INTERVAL 1000 // mills between entries
@@ -194,4 +196,4 @@ void loop() {
194196
logfile.close();
195197
cout << F("Done!");
196198
SysCall::halt();
197-
}
199+
}

examples/#attic/BaseExtCaseTest/BaseExtCaseTest.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include <SPI.h>
55
#include "SdFat.h"
66

7+
using namespace sdfat;
8+
79
const uint8_t chipSelect = SS;
810

911
SdFat sd;

examples/#attic/HelloWorld/HelloWorld.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#include "SdFat.h"
33
#include "sdios.h"
44

5+
using namespace sdfat;
6+
57
// create a serial output stream
68
ArduinoOutStream cout(Serial);
79

examples/#attic/MiniSerial/MiniSerial.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#ifdef UDR0 // Must be AVR with serial port zero.
1111
#include "MinimumSerial.h"
1212

13+
using namespace sdfat;
14+
1315
MinimumSerial MiniSerial;
1416

1517
void setup() {
@@ -26,4 +28,4 @@ void loop() {
2628
}
2729
#else // UDR0
2830
#error no AVR serial port 0
29-
#endif // UDR0
31+
#endif // UDR0

examples/#attic/PrintBenchmarkSD/PrintBenchmarkSD.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include <SPI.h>
55
#include <SD.h>
66

7+
using namespace sdfat;
8+
79
// SD chip select pin
810
const uint8_t chipSelect = SS;
911

@@ -122,4 +124,4 @@ void loop() {
122124
}
123125
file.close();
124126
Serial.println(F("Done!\n"));
125-
}
127+
}

examples/#attic/SD_Size/SD_Size.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <SPI.h>
66
#include <SD.h>
77

8+
using namespace sdfat;
9+
810
File file;
911
//------------------------------------------------------------------------------
1012
void setup() {

examples/#attic/SdFatSize/SdFatSize.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <SPI.h>
77
#include "SdFat.h"
88

9+
using namespace sdfat;
10+
911
SdFat sd;
1012

1113
SdFile file;

examples/#attic/StreamParseInt/StreamParseInt.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
#include <SPI.h>
33
// The next two lines replace #include <SD.h>.
44
#include "SdFat.h"
5+
6+
using namespace sdfat;
7+
58
SdFat SD;
69

710
// SD card chip select pin - Modify the value of csPin for your SD module.
@@ -41,4 +44,4 @@ void setup() {
4144
file.close();
4245
}
4346

44-
void loop() {}
47+
void loop() {}

examples/#attic/append/append.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include "SdFat.h"
1010
#include "sdios.h"
1111

12+
using namespace sdfat;
13+
1214
// SD chip select pin
1315
const uint8_t chipSelect = SS;
1416

examples/#attic/average/average.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include "SdFat.h"
66
#include "sdios.h"
77

8+
using namespace sdfat;
9+
810
// SD chip select pin
911
const uint8_t chipSelect = SS;
1012

examples/#attic/benchSD/benchSD.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <SPI.h>
66
#include <SD.h>
77

8+
using namespace sdfat;
9+
810
// SD chip select pin
911
const uint8_t chipSelect = SS;
1012

@@ -146,4 +148,4 @@ void loop() {
146148
Serial.print(F(" usec\n\n"));
147149
Serial.print(F("Done\n\n"));
148150
file.close();
149-
}
151+
}

examples/#attic/bufstream/bufstream.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include "SdFat.h"
66
#include "sdios.h"
77

8+
using namespace sdfat;
9+
810
// create a serial output stream
911
ArduinoOutStream cout(Serial);
1012
//------------------------------------------------------------------------------

examples/#attic/cin_cout/cin_cout.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include "SdFat.h"
66
#include "sdios.h"
77

8+
using namespace sdfat;
9+
810
// create serial output stream
911
ArduinoOutStream cout(Serial);
1012

examples/#attic/eventlog/eventlog.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
#include <SPI.h>
55
#include "SdFat.h"
66
#include "sdios.h"
7+
8+
using namespace sdfat;
9+
710
// SD chip select pin
811
const uint8_t chipSelect = SS;
912

examples/#attic/fgetsRewrite/fgetsRewrite.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include "SdFat.h"
44
#include "sdios.h"
55

6+
using namespace sdfat;
7+
68
// SD card chip select pin
79
const uint8_t chipSelect = SS;
810

examples/#attic/readlog/readlog.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include "SdFat.h"
77
#include "sdios.h"
88

9+
using namespace sdfat;
10+
911
// SD chip select pin
1012
const uint8_t chipSelect = SS;
1113

@@ -48,4 +50,4 @@ void setup() {
4850
cout << "Done" << endl;
4951
}
5052
//------------------------------------------------------------------------------
51-
void loop() {}
53+
void loop() {}

examples/AnalogBinLogger/AnalogBinLogger.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
#include "SdFat.h"
2525
#include "FreeStack.h"
2626
#include "AnalogBinLogger.h"
27+
28+
using namespace sdfat;
29+
2730
//------------------------------------------------------------------------------
2831
// Analog pin number list for a sample. Pins may be in any order and pin
2932
// numbers may be repeated.
@@ -823,4 +826,4 @@ void loop(void) {
823826
}
824827
#else // __AVR__
825828
#error This program is only for AVR.
826-
#endif // __AVR__
829+
#endif // __AVR__

examples/DirectoryFunctions/DirectoryFunctions.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
#include <SPI.h>
55
#include "SdFat.h"
66
#include "sdios.h"
7+
8+
using namespace sdfat;
9+
710
// SD card chip select pin.
811
const uint8_t chipSelect = SS;
912
//------------------------------------------------------------------------------
@@ -121,4 +124,4 @@ void setup() {
121124
}
122125
//------------------------------------------------------------------------------
123126
// Nothing happens in loop.
124-
void loop() {}
127+
void loop() {}

examples/LongFileName/LongFileName.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include "SdFat.h"
66
#include "FreeStack.h"
77

8+
using namespace sdfat;
9+
810
// SD card chip select pin.
911
const uint8_t SD_CS_PIN = SS;
1012

@@ -99,4 +101,4 @@ void loop() {
99101
file.close();
100102
Serial.flush();
101103
delay(100);
102-
}
104+
}

examples/LowLatencyLogger/LowLatencyLogger.ino

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@
2020

2121
#ifdef __AVR_ATmega328P__
2222
#include "MinimumSerial.h"
23-
MinimumSerial MinSerial;
23+
sdfat::MinimumSerial MinSerial;
2424
#define Serial MinSerial
2525
#endif // __AVR_ATmega328P__
26+
27+
using namespace sdfat;
28+
2629
//==============================================================================
2730
// Start of configuration constants.
2831
//==============================================================================
@@ -652,4 +655,4 @@ void loop(void) {
652655
} else {
653656
Serial.println(F("Invalid entry"));
654657
}
655-
}
658+
}

examples/LowLatencyLogger/UserFunctions.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "UserTypes.h"
22
// User data functions. Modify these functions for your data items.
33

4+
using namespace sdfat;
5+
46
// Start time for data
57
static uint32_t startMicros;
68

examples/LowLatencyLoggerADXL345/LowLatencyLogger.ino

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@
2020

2121
#ifdef __AVR_ATmega328P__
2222
#include "MinimumSerial.h"
23-
MinimumSerial MinSerial;
23+
sdfat::MinimumSerial MinSerial;
2424
#define Serial MinSerial
2525
#endif // __AVR_ATmega328P__
26+
27+
using namespace sdfat;
28+
2629
//==============================================================================
2730
// Start of configuration constants.
2831
//==============================================================================
@@ -652,4 +655,4 @@ void loop(void) {
652655
} else {
653656
Serial.println(F("Invalid entry"));
654657
}
655-
}
658+
}

examples/LowLatencyLoggerADXL345/UserFunctions.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "UserTypes.h"
22
// User data functions. Modify these functions for your data items.
33

4+
using namespace sdfat;
5+
46
// Start time for data
57
static uint32_t startMicros;
68

examples/LowLatencyLoggerMPU6050/LowLatencyLogger.ino

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@
2020

2121
#ifdef __AVR_ATmega328P__
2222
#include "MinimumSerial.h"
23-
MinimumSerial MinSerial;
23+
sdfat::MinimumSerial MinSerial;
2424
#define Serial MinSerial
2525
#endif // __AVR_ATmega328P__
26+
27+
using namespace sdfat;
28+
2629
//==============================================================================
2730
// Start of configuration constants.
2831
//==============================================================================
@@ -652,4 +655,4 @@ void loop(void) {
652655
} else {
653656
Serial.println(F("Invalid entry"));
654657
}
655-
}
658+
}

examples/LowLatencyLoggerMPU6050/UserFunctions.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#include "Wire.h"
44
#include "I2Cdev.h"
55
#include "MPU6050.h"
6+
7+
using namespace sdfat;
8+
69
//------------------------------------------------------------------------------
710
MPU6050 mpu;
811
static uint32_t startMicros;

examples/OpenNext/OpenNext.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include <SPI.h>
55
#include "SdFat.h"
66

7+
using namespace sdfat;
8+
79
// SD default chip select pin.
810
const uint8_t chipSelect = SS;
911

examples/PrintBenchmark/PrintBenchmark.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include "sdios.h"
77
#include "FreeStack.h"
88

9+
using namespace sdfat;
10+
911
// SD chip select pin
1012
const uint8_t chipSelect = SS;
1113

examples/QuickStart/QuickStart.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#include <SPI.h>
44
#include "SdFat.h"
55
#include "sdios.h"
6+
7+
using namespace sdfat;
8+
69
//
710
// Set DISABLE_CHIP_SELECT to disable a second SPI device.
811
// For example, with the Ethernet shield, set DISABLE_CHIP_SELECT
@@ -164,4 +167,4 @@ void loop() {
164167
while (!Serial.available()) {
165168
SysCall::yield();
166169
}
167-
}
170+
}

examples/RawWrite/RawWrite.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include "sdios.h"
1616
#include "FreeStack.h"
1717

18+
using namespace sdfat;
19+
1820
// SD chip select pin
1921
const uint8_t chipSelect = SS;
2022

@@ -177,4 +179,4 @@ void loop(void) {
177179
// close file for next pass of loop
178180
file.close();
179181
Serial.println();
180-
}
182+
}

0 commit comments

Comments
 (0)