Adafruit_VS1053_Library
Adafruit_VS1053_Library copied to clipboard
Add a way to control the type of the SdFat file being used
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 the current code will not compile because the SdFat and File 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.
@ladyada can you have someone look at these pull requests? Many of them are years old.
What's an example sketch that can be used for testing?
Unfortunately, the current file player examples in the library have hard coded #include <SD.h>, so will generally not work as is.
I don’t have a small working example ready that can be used, but just an empty sketch that import the VS1053 library will fail to compile using the rp2040 core:
#include <Adafruit_VS1053.h>
The compilation will succeeds with the new USE_SDFAT_FAT32 constant set (and it will work correctly in more complex sketch using SdFat.h instead of SD.h).
Any chance this can be merged?
Any chance this can be merged some day? This has been open for more than a year (and, to confirm, a no would be a valid answer too, if there is a reason why this change cannot be merged).
If the new USE_SDFAT_FAT32 macro is not set, this change is a no-op to all existing users, so it’s fairly low risk (and I can give a longer name to the macro if needed).