Selaa lähdekoodia

Emulate Sd2Card & SdVolume for old CardInfo example

main
PaulStoffregen 4 vuotta sitten
vanhempi
commit
7c6b4fa59f
2 muutettua tiedostoa jossa 35 lisäystä ja 3 poistoa
  1. +3
    -3
      examples/CardInfo/CardInfo.ino
  2. +32
    -0
      src/SD.h

+ 3
- 3
examples/CardInfo/CardInfo.ino Näytä tiedosto

@@ -110,11 +110,11 @@ void setup()
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
root.ls(LS_R | LS_DATE | LS_SIZE);
//root.ls(LS_R | LS_DATE | LS_SIZE);
}



+ 32
- 0
src/SD.h Näytä tiedosto

@@ -133,4 +133,36 @@ public: // allow access, so users can mix SD & SdFat APIs

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

Loading…
Peruuta
Tallenna