Modifications

Sauter à la navigation Sauter à la recherche
2 061 octets ajoutés ,  13 mars 2012 à 12:33
aucun résumé de modification
Ligne 40 : Ligne 40 :     
Here are the steps:
 
Here are the steps:
    Wake up and print out the to Serial Monitor that we're running (OPTIONAL)
+
# '''Wake up and print''' out the to Serial Monitor that we're running '''(OPTIONAL)'''
    Check how much free RAM we have after we have used the buffer for storing Wave audio data, make sure its more than 100 bytes and keep an eye on it as you modify your code. This test can be removed, its for your use (OPTIONAL)
+
# '''Check how much free RAM we have''' after we have used the buffer for storing Wave audio data, make sure its more than 100 bytes and keep an eye on it as you modify your code. This test can be removed, its for your use '''(OPTIONAL)'''
    Set the pin modes for the DAC control lines. These should not be changed unless you've modified them in the library as well. Its probably best to keep them as-is
+
# '''Set the pin modes for the DAC''' control lines. These should not be changed unless you've modified them in the library as well. Its probably best to keep them as-is
    Initialize the SD card and see if it responds. We try to talk to it at 8MHz. If you have a waveshield 1.0 you may need to use 4MHz mode so comment out one line and uncommment the other to swap which method is used. If the card fails to initialize, print out an error and halt.
+
# '''Initialize the SD card''' and see if it responds. We try to talk to it at 8MHz. If you have a waveshield 1.0 you may need to use 4MHz mode so comment out one line and uncommment the other to swap which method is used. If the card fails to initialize, print out an error and halt.
    Allow partial block reads. Some SD cards don't like this so if you're having problems, comment this out first! (OPTIONAL)
+
# '''Allow partial block reads'''. Some SD cards don't like this so if you're having problems, comment this out first! (OPTIONAL)
    Try to find a FAT partition in the first 5 slots. You did format the card to FAT format, right? If it cant find a FAT partition it will print out that it failed, so make sure you format it again if its giving you trouble
+
# '''Try to find a FAT partition''' in the first 5 slots. You did format the card to FAT format, right? If it cant find a FAT partition it will print out that it failed, so make sure you format it again if its giving you trouble
    Print out what kind of FAT partition was found (OPTIONAL)
+
# '''Print out what kind of FAT''' partition was found '''(OPTIONAL)'''
    Try to open up the root directory. If this doesnt work, something is messed up with the formatting. Try to format it again!
+
# '''Try to open up the root directory'''. If this doesnt work, something is messed up with the formatting. Try to format it again!
    Finally, print out the files found, one after the other in the directories on the card. This is great for debugging and will show you what you've got on there. Since we dont have long filename access and use the 'base' 8.3 format to define files, you'll need to see what the files are named on the partition and this helps a lot (OPTIONAL)
+
# Finally, print out the files found, one after the other in the directories on the card. This is great for debugging and will show you what you've got on there. Since we dont have long filename access and use the 'base' 8.3 format to define files, you'll need to see what the files are named on the partition and this helps a lot '''(OPTIONAL)'''
 +
 
 +
  <nowiki>void setup() {
 +
  Serial.begin(9600);          // set up Serial library at 9600 bps for debugging
 +
 
 +
  putstring_nl("\nWave test!");  // say we woke up!
 +
 
 +
  putstring("Free RAM: ");      // This can help with debugging, running out of RAM is bad
 +
  Serial.println(freeRam()); 
 +
 +
  // Set the output pins for the DAC control. This pins are defined in the library
 +
  pinMode(2, OUTPUT);
 +
  pinMode(3, OUTPUT);
 +
  pinMode(4, OUTPUT);
 +
  pinMode(5, OUTPUT);
 +
 
 +
  //  if (!card.init(true)) { //play with 4 MHz spi if 8MHz isn't working for you
 +
  if (!card.init()) {        //play with 8 MHz spi (default faster!) 
 +
    putstring_nl("Card init. failed!");  // Something went wrong, lets print out why
 +
    sdErrorCheck();
 +
    while(1);                            // then 'halt' - do nothing!
 +
  }
 +
 
 +
  // enable optimize read - some cards may timeout. Disable if you're having problems
 +
  card.partialBlockRead(true);
 +
 
 +
  // Now we will look for a FAT partition!
 +
  uint8_t part;
 +
  for (part = 0; part < 5; part++) {    // we have up to 5 slots to look in
 +
    if (vol.init(card, part))
 +
      break;                            // we found one, lets bail
 +
  }
 +
  if (part == 5) {                      // if we ended up not finding one  :(
 +
    putstring_nl("No valid FAT partition!");
 +
    sdErrorCheck();      // Something went wrong, lets print out why
 +
    while(1);                            // then 'halt' - do nothing!
 +
  }
 +
 
 +
  // Lets tell the user about what we found
 +
  putstring("Using partition ");
 +
  Serial.print(part, DEC);
 +
  putstring(", type is FAT");
 +
  Serial.println(vol.fatType(),DEC);    // FAT16 or FAT32?
 +
 
 +
  // Try to open the root directory
 +
  if (!root.openRoot(vol)) {
 +
    putstring_nl("Can't open root dir!"); // Something went wrong,
 +
    while(1);                            // then 'halt' - do nothing!
 +
  }
 +
 
 +
  // Whew! We got past the tough parts.
 +
  putstring_nl("Files found:");
 +
  dirLevel = 0;
 +
  // Print out all of the files in all the directories.
 +
  lsR(root);
 +
}
 +
</nowiki>
29 917

modifications

Menu de navigation