Skip to content

Commit

Permalink
Add UTF-8 support
Browse files Browse the repository at this point in the history
  • Loading branch information
greiman committed Aug 23, 2021
1 parent caece65 commit a5e4bde
Show file tree
Hide file tree
Showing 105 changed files with 2,326 additions and 1,267 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ Earlier releases of Version 1 are here:

https://github.com/greiman/SdFat/releases

###### UTF-8 encoded filenames are supported in v2.1.0.

Try the UnicodeFilenames example. Here is output from ls:
<pre>
Type any character to begin
ls:
0 😀/
20 россиянин
17 très élégant
9 狗.txt
</pre>

SdFat Version 2 supports FAT16/FAT32 and exFAT SD cards. It is mostly
backward compatible with SdFat Version 1 for FAT16/FAT32 cards.

Expand Down
Binary file modified doc/html.zip
Binary file not shown.
8 changes: 5 additions & 3 deletions examples/AvrAdcLogger/AvrAdcLogger.ino
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,13 @@ const uint16_t ISR_TIMER0 = 160;
//==============================================================================
const uint32_t MAX_FILE_SIZE = MAX_FILE_SIZE_MiB << 20;

// Select fastest interface.
// Select fastest interface. Max SPI rate for AVR is 10 MHx.
#define SPI_CLOCK SD_SCK_MHZ(10)

#if ENABLE_DEDICATED_SPI
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI)
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
#else // ENABLE_DEDICATED_SPI
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI)
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SPI_CLOCK)
#endif // ENABLE_DEDICATED_SPI

#if SD_FAT_TYPE == 0
Expand Down
5 changes: 5 additions & 0 deletions examples/BackwardCompatibility/BackwardCompatibility.ino
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
//
// Your SD must be formatted FAT16/FAT32.
//
// SD.h does not support some default SdFat features.
// To compare flash size, set USE_FAT_FILE_FLAG_CONTIGUOUS,
// ENABLE_DEDICATED_SPI, and USE_LONG_FILE_NAMES to zero also
// set SDFAT_FILE_TYPE to one in SdFat/src/SdFatCongfig.h
//
// Set USE_SD_H nonzero to use SD.h.
// Set USE_SD_H zero to use SdFat.h.
//
Expand Down
9 changes: 6 additions & 3 deletions examples/BufferedPrint/BufferedPrint.ino
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ const uint8_t SD_CS_PIN = SS;
const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
#endif // SDCARD_SS_PIN

// Try max SPI clock for an SD. Reduce SPI_CLOCK if errors occur.
#define SPI_CLOCK SD_SCK_MHZ(50)

// Try to select the best SD card configuration.
#if HAS_SDIO_CLASS
#define SD_CONFIG SdioConfig(FIFO_SDIO)
#elif ENABLE_DEDICATED_SPI
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI)
#elif ENABLE_DEDICATED_SPI
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
#else // HAS_SDIO_CLASS
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI)
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SPI_CLOCK)
#endif // HAS_SDIO_CLASS

#if SD_FAT_TYPE == 0
Expand Down
12 changes: 7 additions & 5 deletions examples/DirectoryFunctions/DirectoryFunctions.ino
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ const uint8_t SD_CS_PIN = SS;
const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
#endif // SDCARD_SS_PIN

// Try max SPI clock for an SD. Reduce SPI_CLOCK if errors occur.
#define SPI_CLOCK SD_SCK_MHZ(50)

// Try to select the best SD card configuration.
#if HAS_SDIO_CLASS
#define SD_CONFIG SdioConfig(FIFO_SDIO)
#elif ENABLE_DEDICATED_SPI
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI)
#elif ENABLE_DEDICATED_SPI
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
#else // HAS_SDIO_CLASS
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI)
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SPI_CLOCK)
#endif // HAS_SDIO_CLASS
//------------------------------------------------------------------------------

Expand Down Expand Up @@ -66,7 +69,6 @@ void setup() {
SysCall::yield();
}
delay(1000);

cout << F("Type any character to start\n");
while (!Serial.available()) {
SysCall::yield();
Expand Down Expand Up @@ -153,4 +155,4 @@ void setup() {
}
//------------------------------------------------------------------------------
// Nothing happens in loop.
void loop() {}
void loop() {}
22 changes: 12 additions & 10 deletions examples/ExFatLogger/ExFatLogger.ino
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Example to demonstrate write latency for preallocated exFAT files.
// I suggest you write a PC program to convert very large bin files.
//
// If an exFAT SD is required, the ExFatFormatter example will format
// smaller cards with an exFAT file system.
//
// The maximum data rate will depend on the quality of your SD,
// the size of the FIFO, and using dedicated SPI.
#include "SdFat.h"
Expand Down Expand Up @@ -68,12 +65,17 @@ const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
// Preallocate 1GiB file.
const uint32_t PREALLOCATE_SIZE_MiB = 1024UL;

// Select the fastest interface. Assumes no other SPI devices.
#if ENABLE_DEDICATED_SPI
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI)
#else // ENABLE_DEDICATED_SPI
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI)
#endif // ENABLE_DEDICATED_SPI
// Try max SPI clock for an SD. Reduce SPI_CLOCK if errors occur.
#define SPI_CLOCK SD_SCK_MHZ(50)

// Try to select the best SD card configuration.
#if HAS_SDIO_CLASS
#define SD_CONFIG SdioConfig(FIFO_SDIO)
#elif ENABLE_DEDICATED_SPI
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
#else // HAS_SDIO_CLASS
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SPI_CLOCK)
#endif // HAS_SDIO_CLASS

// Save SRAM if 328.
#ifdef __AVR_ATmega328P__
Expand Down Expand Up @@ -189,7 +191,7 @@ void binaryToCsv() {
data_t binData[FIFO_DIM];

if (!binFile.seekSet(512)) {
error("binFile.seek faile");
error("binFile.seek failed");
}
uint32_t tPct = millis();
printRecord(&csvFile, nullptr);
Expand Down
47 changes: 0 additions & 47 deletions examples/ExFatUnicodeTest/ExFatUnicodeTest.ino

This file was deleted.

9 changes: 6 additions & 3 deletions examples/OpenNext/OpenNext.ino
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ const uint8_t SD_CS_PIN = SS;
const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
#endif // SDCARD_SS_PIN

// Try max SPI clock for an SD. Reduce SPI_CLOCK if errors occur.
#define SPI_CLOCK SD_SCK_MHZ(50)

// Try to select the best SD card configuration.
#if HAS_SDIO_CLASS
#define SD_CONFIG SdioConfig(FIFO_SDIO)
#elif ENABLE_DEDICATED_SPI
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI)
#elif ENABLE_DEDICATED_SPI
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
#else // HAS_SDIO_CLASS
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI)
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SPI_CLOCK)
#endif // HAS_SDIO_CLASS

#if SD_FAT_TYPE == 0
Expand Down
9 changes: 6 additions & 3 deletions examples/ReadCsvFile/ReadCsvFile.ino
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ const uint8_t SD_CS_PIN = SS;
const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
#endif // SDCARD_SS_PIN

// Try max SPI clock for an SD. Reduce SPI_CLOCK if errors occur.
#define SPI_CLOCK SD_SCK_MHZ(50)

// Try to select the best SD card configuration.
#if HAS_SDIO_CLASS
#define SD_CONFIG SdioConfig(FIFO_SDIO)
#elif ENABLE_DEDICATED_SPI
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI)
#elif ENABLE_DEDICATED_SPI
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
#else // HAS_SDIO_CLASS
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI)
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SPI_CLOCK)
#endif // HAS_SDIO_CLASS

#if SD_FAT_TYPE == 0
Expand Down
9 changes: 6 additions & 3 deletions examples/RtcTimestampTest/RtcTimestampTest.ino
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ const uint8_t SD_CS_PIN = SS;
const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
#endif // SDCARD_SS_PIN

// Try max SPI clock for an SD. Reduce SPI_CLOCK if errors occur.
#define SPI_CLOCK SD_SCK_MHZ(50)

// Try to select the best SD card configuration.
#if HAS_SDIO_CLASS
#define SD_CONFIG SdioConfig(FIFO_SDIO)
#elif ENABLE_DEDICATED_SPI
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI)
#elif ENABLE_DEDICATED_SPI
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
#else // HAS_SDIO_CLASS
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI)
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SPI_CLOCK)
#endif // HAS_SDIO_CLASS

#if SD_FAT_TYPE == 0
Expand Down
5 changes: 3 additions & 2 deletions examples/STM32Test/STM32Test.ino
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
/* This example is for https://github.com/rogerclarkmelbourne/Arduino_STM32
*
* Example use of two SPI ports on an STM32 board.
* Note SPI speed is limited to 18 MHz.
*/
Expand All @@ -13,7 +14,7 @@ FsFile file1;

// Use mySPI2 since SPI2 is used in SPI.h as a different type.
static SPIClass mySPI2(2);
// Chip select PB21, dedicated SPI, 18 MHz, port 2.
// Chip select PB12, dedicated SPI, 18 MHz, port 2.
#if ENABLE_DEDICATED_SPI
#define SD2_CONFIG SdSpiConfig(PB12, DEDICATED_SPI, SD_SCK_MHZ(18), &mySPI2)
#else // ENABLE_DEDICATED_SPI
Expand Down
9 changes: 6 additions & 3 deletions examples/SdFormatter/SdFormatter.ino
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ const uint8_t SD_CS_PIN = SS;
const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
#endif // SDCARD_SS_PIN

// Try max SPI clock for an SD. Reduce SPI_CLOCK if errors occur.
#define SPI_CLOCK SD_SCK_MHZ(50)

// Try to select the best SD card configuration.
#if HAS_SDIO_CLASS
#define SD_CONFIG SdioConfig(FIFO_SDIO)
#elif ENABLE_DEDICATED_SPI
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI)
#elif ENABLE_DEDICATED_SPI
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
#else // HAS_SDIO_CLASS
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI)
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SPI_CLOCK)
#endif // HAS_SDIO_CLASS
//==============================================================================
// Serial output stream
Expand Down
9 changes: 6 additions & 3 deletions examples/TeensyRtcTimestamp/TeensyRtcTimestamp.ino
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ const uint8_t SD_CS_PIN = SS;
const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
#endif // SDCARD_SS_PIN

// Try max SPI clock for an SD. Reduce SPI_CLOCK if errors occur.
#define SPI_CLOCK SD_SCK_MHZ(50)

// Try to select the best SD card configuration.
#if HAS_SDIO_CLASS
#define SD_CONFIG SdioConfig(FIFO_SDIO)
#elif ENABLE_DEDICATED_SPI
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI)
#elif ENABLE_DEDICATED_SPI
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
#else // HAS_SDIO_CLASS
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI)
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SPI_CLOCK)
#endif // HAS_SDIO_CLASS

#if SD_FAT_TYPE == 0
Expand Down
Loading

0 comments on commit a5e4bde

Please sign in to comment.