ardunio TFT_eSPI库与Audio库冲突解决

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) {

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值