浏览代码

Emulate Sd2Card & SdVolume for old CardInfo example

main
PaulStoffregen 5 年前
父节点
当前提交
7c6b4fa59f
共有 2 个文件被更改,包括 35 次插入3 次删除
  1. +3
    -3
      examples/CardInfo/CardInfo.ino
  2. +32
    -0
      src/SD.h

+ 3
- 3
examples/CardInfo/CardInfo.ino 查看文件

Serial.println(volumesize); Serial.println(volumesize);


Serial.println("\nFiles found on the card (name, date and size in bytes): ");
root.openRoot(volume);
//Serial.println("\nFiles found on the card (name, date and size in bytes): ");
//root.openRoot(volume);
// list all files in the card with date and size // list all files in the card with date and size
root.ls(LS_R | LS_DATE | LS_SIZE);
//root.ls(LS_R | LS_DATE | LS_SIZE);
} }





+ 32
- 0
src/SD.h 查看文件



extern SDClass SD; extern SDClass SD;




#define SD_CARD_TYPE_SD1 0
#define SD_CARD_TYPE_SD2 1
#define SD_CARD_TYPE_SDHC 3
class Sd2Card
{
public:
bool init(uint8_t speed, uint8_t csPin) {
return SD.sdfs.begin(csPin);
}
uint8_t type() {
return SD.sdfs.card()->type();
}
};
class SdVolume
{
public:
bool init(Sd2Card &card) {
return SD.sdfs.vol() != nullptr;
}
uint8_t fatType() {
return SD.sdfs.vol()->fatType();
}
uint32_t blocksPerCluster() {
return SD.sdfs.vol()->sectorsPerCluster();
}
uint32_t clusterCount() {
return SD.sdfs.vol()->clusterCount();
}
};

#endif #endif

正在加载...
取消
保存