From 51dd451677f07899f217aacef16181a76fb29967 Mon Sep 17 00:00:00 2001 From: mkende Date: Fri, 28 Apr 2023 23:24:27 +0200 Subject: [PATCH] Add a way to control the type of the SdFat file being used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change introduce a new USE_SDFAT_FAT32 preprocessor variable that can be set to control the compilation of the library. When set, the library will use the File32 and SdFat32 types from the SdFat library rather than the default File and SdFat whose meaning is context dependant. This serves two purposes: - when an Arduino core has an FS.h header then currently the code will not compile because the SdFat and File classes are not defined. - the default SdFat File type on modern core is a typedef for SdFat FsFile type, which has a subset of the interface of the File32 one, which also prevent some existing code from compiling. This change is a no-op for people who don’t define the new variable, so it should not break any existing code. --- Adafruit_VS1053.cpp | 5 +++++ Adafruit_VS1053.h | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Adafruit_VS1053.cpp b/Adafruit_VS1053.cpp index f486789..82c9a38 100644 --- a/Adafruit_VS1053.cpp +++ b/Adafruit_VS1053.cpp @@ -310,7 +310,12 @@ void Adafruit_VS1053_FilePlayer::feedBuffer_noLock(void) { // must be at the end of the file if (_loopPlayback) { // play in loop +#if defined(USE_SDFAT_FAT32) + char fileName[32]; + if (currentTrack.getName(fileName, 32) && isMP3File(fileName)) { +#else if (isMP3File(currentTrack.name())) { +#endif currentTrack.seek(mp3_ID3Jumper(currentTrack)); } else { currentTrack.seek(0); diff --git a/Adafruit_VS1053.h b/Adafruit_VS1053.h index 6a45d16..e4ceefc 100644 --- a/Adafruit_VS1053.h +++ b/Adafruit_VS1053.h @@ -19,9 +19,14 @@ #include -#if defined(PREFER_SDFAT_LIBRARY) +#if defined(PREFER_SDFAT_LIBRARY) || defined(USE_SDFAT_FAT32) #include +#if defined(USE_SDFAT_FAT32) +extern SdFat32 SD; +typedef File32 File; +#else extern SdFat SD; +#endif #else #include #endif