TFT_eSPI库与Audio库发生冲突,原因是TFT_eSPI库引用了FS.h,其中命名空间为fs,定义了FS类,Audio.h开启sdFat库后,也有一个fs命名空间,然后在sdFat类基础上又定义了一个FS类。
audio.h文件
#define SDFATFS_USED // activate for SdFat
#ifdef SDFATFS_USED
//typedef File32 File;
typedef FsFile File;
namespace fs {
class FS : public SdFat {
public:
bool begin(SdCsPin_t csPin = SS, uint32_t maxSck = SD_SCK_MHZ(25)) { return SdFat::begin(csPin, maxSck); }
bool begin(SdSpiConfig config){return SdFat::begin(config);}
};
class SDFATFS : public fs::FS {
public:
// sdcard_type_t cardType();
uint64_t cardSize() {
return totalBytes();
}
uint64_t usedBytes() {
// set SdFatConfig MAINTAIN_FREE_CLUSTER_COUNT non-zero. Then only the first call will take time.
return (uint64_t)(clusterCount() - freeClusterCount()) * (uint64_t)bytesPerCluster();
}
uint64_t totalBytes() {
return (uint64_t)clusterCount() * (uint64_t)bytesPerCluster();
}
};
}
extern fs::SDFATFS SD_SDFAT;
using namespace fs;
#define SD SD_SDFAT
#endif //SDFATFS_USED
fs.h文件
namespace fs
{
...
class FS
{
public:
FS(FSImplPtr impl) : _impl(impl) { }
File open(const char* path, const char* mode = FILE_READ);
File open(const String& path, const char* mode = FILE_READ);
bool exists(const char* path);
bool exists(const String& path);
bool remove(const char* path);
bool remove(const String& path);
bool rename(const char* pathFrom, const char* pathTo);
bool rename(const String& pathFrom, const String& pathTo);
bool mkdir(const char *path);
bool mkdir(const String &path);
bool rmdir(const char *path);
bool rmdir(const String &path);
protected:
FSImplPtr _impl;
};
解决办法,修改audio.h命名空间,并修改audio.cpp文件即可
修改后audio.h如下
#define SDFATFS_USED // activate for SdFat
#ifdef SDFATFS_USED
//typedef File32 File;
typedef FsFile File;
namespace fss {
class FS : public SdFat {
public:
bool begin(SdCsPin_t csPin = SS, uint32_t maxSck = SD_SCK_MHZ(25)) { return SdFat::begin(csPin, maxSck); }
bool begin(SdSpiConfig config){return SdFat::begin(config);}
};
class SDFATFS : public fss::FS {
public:
// sdcard_type_t cardType();
uint64_t cardSize() {
return totalBytes();
}
uint64_t usedBytes() {
// set SdFatConfig MAINTAIN_FREE_CLUSTER_COUNT non-zero. Then only the first call will take time.
return (uint64_t)(clusterCount() - freeClusterCount()) * (uint64_t)bytesPerCluster();
}
uint64_t totalBytes() {
return (uint64_t)clusterCount() * (uint64_t)bytesPerCluster();
}
};
}
extern fss::SDFATFS SD_SDFAT;
using namespace fss;
#define SD SD_SDFAT
#endif //SDFATFS_USED
修改audio.h文件部分
//699行附近
bool Audio::connecttoFS(fss::FS &fs, const char* path, uint32_t resumeFilePos) {