本文整理汇总了C++中SdVolume::clusterCount方法的典型用法代码示例。如果您正苦于以下问题:C++ SdVolume::clusterCount方法的具体用法?C++ SdVolume::clusterCount怎么用?C++ SdVolume::clusterCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SdVolume
的用法示例。
在下文中一共展示了SdVolume::clusterCount方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
int App::run()
{
if (!card.init(SPI_HALF_SPEED, 4))
{
Serial.puts("initialization failed. Things to check:\r\n");
Serial.puts("* is a card is inserted?\r\n");
Serial.puts("* Is your wiring correct?\r\n");
Serial.puts("* did you change the chipSelect pin to match your shield or module?\r\n");
return 0;
}
else
{
Serial.puts("Wiring is correct and a card is present.\r\n");
}
Serial.puts("\r\nCard type: ");
switch(card.type())
{
case SD_CARD_TYPE_SD1:
Serial.puts("SD1\r\n");
break;
case SD_CARD_TYPE_SD2:
Serial.puts("SD2\r\n");
break;
case SD_CARD_TYPE_SDHC:
Serial.puts("SDHC\r\n");
break;
default:
Serial.puts("Unknown\r\n");
}
if (!volume.init(card))
{
Serial.puts("Could not find FAT16/FAT32 partition.\r\n");
Serial.puts("Make sure you've formatted the card\r\n");
return 0;
}
uint32_t volumesize;
Serial.printf("\r\nVolume type is FAT%u\r\n", volume.fatType());
volumesize = volume.blocksPerCluster();
volumesize *= volume.clusterCount();
volumesize *= 512;
Serial.printf("Volume size (bytes): %u\r\n", volumesize);
volumesize /= 1024;
Serial.printf("Volume size (Kbytes): %u\r\n");
volumesize /= 1024;
Serial.printf("Volume size (Mbytes): %u\r\n");
Serial.puts("\r\nFiles found on the card (name, date and size in bytes): \r\n");
root.openRoot(volume);
root.ls(LS_R | LS_DATE | LS_SIZE, 0, Serial);
while (true) { }
return 0;
}
示例2: initSDCard
bool FileSystem::initSDCard() {
boolean status;
if (root.isOpen())
root.close(); // allows repeated calls
// First, detect the card
status = card.init(pinCS); // Audio shield has SD card SD on pin 10
if (status) {
Serial.println("SD card is connected :-)");
} else {
Serial.println("SD card is not connected or unusable :-(");
sdCardInitialized = false;
return sdCardInitialized;
}
// Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
if (!volume.init(card)) {
Serial.println(
"Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
sdCardInitialized = false;
return sdCardInitialized;
}
root.openRoot(volume);
// print the type and size of the first FAT-type volume
Serial.print("\nVolume type is FAT");
Serial.println(volume.fatType(), DEC);
Serial.println();
float size = volume.blocksPerCluster() * volume.clusterCount();
size = size * (512.0 / 1e6); // convert blocks to millions of bytes
Serial.print("File system space is ");
Serial.print(size);
Serial.println(" Mbytes.");
status = SD.begin(pinCS); // Audio shield has SD card CS on pin 10
if (status) {
Serial.println("SD library is able to access the filesystem");
} else {
Serial.println("SD library can not access the filesystem!");
Serial.println(
"Please report this problem, with the make & model of your SD card.");
Serial.println(
" http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports");
}
sdCardInitialized = true;
return sdCardInitialized;
}
示例3: initialize
/**
* initialize
* Initialize Writter and SD Card behavior
* @return {void}
*/
bool SDWriter::initialize()
{
Sd2Card card;
card.init(SPI_HALF_SPEED, pin);
SdVolume volume;
volume.init(card);
volumesize = volume.blocksPerCluster() * volume.clusterCount() * 512;
if (!SD.begin(pin))
state = false;
else
state = true;
return state;
}
示例4: scanSD
// ----------------------------------------------------------------------------
// Scan the SD card and open the volume
// Set reg[STATUS] to FDC_ST_NOTREADY if no card present
// ----------------------------------------------------------------------------
void scanSD()
{
if (!card.init(SPI_FULL_SPEED, SD_CHIP_SELECT_PIN))
{
Serial.print("Init failed, error:");
Serial.println(card.errorCode());
mb8877.reg[STATUS] = FDC_ST_NOTREADY;
return;
}
#ifdef SD_DEBUG
Serial.print("\nCard type: ");
switch(card.type()) {
case SD_CARD_TYPE_SD1: Serial.println("SD1"); break;
case SD_CARD_TYPE_SD2: Serial.println("SD2"); break;
case SD_CARD_TYPE_SDHC: Serial.println("SDHC"); break;
default: Serial.println("Unknown");
}
#endif
if (!volume.init(card)) {
#ifdef SD_DEBUG
Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
#endif
mb8877.reg[STATUS] = FDC_ST_NOTREADY;
return;
}
#ifdef SD_DEBUG
// ----- Print the type and size of the first FAT-type volume
Serial.print("\nVolume type is FAT");
Serial.println(volume.fatType(), DEC);
Serial.println();
long volumesize;
volumesize = volume.blocksPerCluster(); // clusters are collections of blocks
volumesize *= volume.clusterCount(); // we'll have a lot of clusters
volumesize *= 512; // SD card blocks are always 512 bytes
Serial.print("Volume size (bytes): ");
Serial.println(volumesize);
#endif
root.openRoot(volume);
mb8877.reg[STATUS]=0x00;
}
示例5: printCardInfo
void printCardInfo() {
Serial.print(F("Data logging is "));
if (disableLogging) {
Serial.println(F("DISABLED"));
} else {
Serial.println(F("ENABLED"));
}
Serial.println();
Serial.print("\nCard type: ");
switch (card.type()) {
case SD_CARD_TYPE_SD1:
Serial.println("SD1");
break;
case SD_CARD_TYPE_SD2:
Serial.println("SD2");
break;
case SD_CARD_TYPE_SDHC:
Serial.println("SDHC");
break;
default:
Serial.println("Unknown");
}
Serial.print("\nVolume type is FAT");
Serial.println(volume.fatType(), DEC);
unsigned long volumesize;
volumesize = volume.blocksPerCluster();
volumesize *= volume.clusterCount();
volumesize /= 2;
volumesize /= 1024;
Serial.print("Volume size: ");
Serial.print(volumesize, DEC);
Serial.println("MB");
Serial.println("name\tdate\tsize");
root.ls(LS_R | LS_DATE | LS_SIZE);
Serial.println();
}
示例6: setup
void setup()
{
Serial.begin(BPS_115200);
PgmPrintln("Type any character to start");
while (!Serial.available());
Serial.print("\nInitializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin
// (10 on most Arduino boards, 53 on the Mega) must be left as an output
// or the SD library functions will not work.
//pinMode(10, OUTPUT); // change this to 53 on a mega
// we'll use the initialization code from the utility libraries
// since we're just testing if the card is working!
if (!card.init(SPI_HALF_SPEED, chipSelect)) {
Serial.println("initialization failed. Things to check:");
Serial.println("* is a card is inserted?");
Serial.println("* Is your wiring correct?");
Serial.println("* did you change the chipSelect pin to match your shield or module?");
return;
} else {
Serial.println("Wiring is correct and a card is present.");
}
// print the type of card
Serial.print("\nCard type: ");
switch(card.type()) {
case SD_CARD_TYPE_SD1:
Serial.println("SD1");
break;
case SD_CARD_TYPE_SD2:
Serial.println("SD2");
break;
case SD_CARD_TYPE_SDHC:
Serial.println("SDHC");
break;
default:
Serial.println("Unknown");
}
// Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
if (!volume.init(card)) {
Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
return;
}
// print the type and size of the first FAT-type volume
uint32_t volumesize;
Serial.print("\nVolume type is FAT");
Serial.println(volume.fatType(), DEC);
Serial.println();
volumesize = volume.blocksPerCluster(); // clusters are collections of blocks
volumesize *= volume.clusterCount(); // we'll have a lot of clusters
volumesize *= 512; // SD card blocks are always 512 bytes
Serial.print("Volume size (bytes): ");
Serial.println(volumesize);
Serial.print("Volume size (Kbytes): ");
volumesize /= 1024;
Serial.println(volumesize);
Serial.print("Volume size (Mbytes): ");
volumesize /= 1024;
Serial.println(volumesize);
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);
}
示例7: infoSDCard
int infoSDCard(void){
Serial.print("SD-Card type is ");
switch(card.type()){
case SD_CARD_TYPE_SD1:
Serial.print("SD1");
break;
case SD_CARD_TYPE_SD2:
Serial.print("SD2");
break;
case SD_CARD_TYPE_SDHC:
Serial.print("SDHC");
break;
default:
Serial.println("Unknown");
}
cid_t cid;
if (!card.readCID(&cid))
{
Serial.print("\nError Open read CID of SD-Card");
return SDCARD_ERROR;
}
Serial.print("\nManufacturer ID: ");
Serial.print(cid.mid, HEX);
Serial.print("\nOEM/Application ID: ");
Serial.print(cid.oid[0]);
Serial.print(cid.oid[1]);
Serial.print("\nProduct name: ");
for (uint8_t i = 0; i < 5; i++) {
Serial.print(cid.pnm[i]);
}
Serial.print("\nProduct revision: ");
Serial.print(cid.prv_m, DEC);
Serial.print(".");
Serial.print(cid.prv_n, DEC);
Serial.print("\nProduct serial number: ");
Serial.print(cid.psn);
Serial.print("\nManufacturing date: ");
Serial.print(cid.mdt_month);
Serial.print('/');
Serial.print(2000 + (10*cid.mdt_year_high) + cid.mdt_year_low);
// print the type and size of the first FAT-type volume
Serial.print("\nVolume type is FAT");
Serial.print(volume.fatType(), DEC);
uint32_t volumesize, volume_free;
volumesize = volume.blocksPerCluster(); // clusters are collections of blocks
volume_free = volume.blocksPerCluster();
Serial.print("\nNb blocks per cluster: ");
Serial.print(volumesize);
volumesize *= volume.clusterCount(); // we'll have a lot of clusters
volume_free *= volume.freeClusterCount();
Serial.print("\nClusters count: ");
Serial.print(volume.clusterCount());
volumesize *= 512;
volume_free *= 512;
Serial.print("\nBlock size: 512"); // SD card blocks are always 512 bytes
Serial.print("\nVolume size (bytes): ");
Serial.print(volumesize);
Serial.print(" / Volume free (bytes): ");
Serial.print(volume_free);
Serial.print(" / % free: ");
Serial.print(100.0*(double)(volume_free)/(double)(volumesize));
Serial.print("\nVolume size (Kbytes): ");
volumesize /= 1024;
Serial.print(volumesize);
Serial.print(" / Volume free (Kbytes): ");
volume_free /= 1024;
Serial.print(volume_free);
Serial.print("\nVolume size (Mbytes): ");
volumesize /= 1024;
Serial.print(volumesize);
Serial.print(" / Volume free (Mbytes): ");
volume_free /= 1024;
Serial.print(volume_free);
// list all files in the card with date and size
Serial.println("\nFiles found on the card (name, date and size in bytes): ");
uint16_t n = root.ls(LS_R | LS_DATE | LS_SIZE);
Serial.println("");
Serial.print(n); Serial.println(" files found");
Serial.println("");
return n;
}
示例8: setup
void setup()
{
Serial.begin(115200);
while (!Serial.available());
Serial.print("\nInitializing SD card...");
// we'll use the initialization code from the utility libraries
// since we're just testing if the card is working!
// Initialize HARDWARE SPI with user defined chipSelect
if (!card.init(SPI_HALF_SPEED, chipSelect)) {
// Initialize SOFTWARE SPI (uncomment and comment out above line to use)
// if (!card.init(mosiPin, misoPin, clockPin, chipSelect)) {
Serial.println("initialization failed. Things to check:");
Serial.println("* is a card is inserted?");
Serial.println("* Is your wiring correct?");
Serial.println("* did you change the chipSelect pin to match your shield or module?");
return;
} else {
Serial.println("Wiring is correct and a card is present.");
}
// print the type of card
Serial.print("\nCard type: ");
switch(card.type()) {
case SD_CARD_TYPE_SD1:
Serial.println("SD1");
break;
case SD_CARD_TYPE_SD2:
Serial.println("SD2");
break;
case SD_CARD_TYPE_SDHC:
Serial.println("SDHC");
break;
default:
Serial.println("Unknown");
}
// Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
if (!volume.init(card)) {
Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
return;
}
// print the type and size of the first FAT-type volume
uint32_t volumesize;
Serial.print("\nVolume type is FAT");
Serial.println(volume.fatType(), DEC);
Serial.println();
volumesize = volume.blocksPerCluster(); // clusters are collections of blocks
volumesize *= volume.clusterCount(); // we'll have a lot of clusters
volumesize *= 512; // SD card blocks are always 512 bytes
Serial.print("Volume size (bytes): ");
Serial.println(volumesize);
Serial.print("Volume size (Kbytes): ");
volumesize /= 1024;
Serial.println(volumesize);
Serial.print("Volume size (Mbytes): ");
volumesize /= 1024;
Serial.println(volumesize);
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);
}