0

Wave Shield Programming
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Wave Shield Programming

by Marsi on Fri Jun 29, 2018 11:06 am

Hello, i am trying to program my wave shield but the arduino program gives me this error " freeRam was not declared in this scope" is it because i installed the library wrong? I am very lost with this complex program so i would apreciate a helping hand. It's from the dapHC.pde example.

Code: Select all | TOGGLE FULL SIZE
#include "WaveUtil.h"
#include "WaveHC.h"


SdReader card;    // This object holds the information for the card
FatVolume vol;    // This holds the information for the partition on the card
FatReader root;   // This holds the information for the filesystem on the card

uint8_t dirLevel; // indent level for file/dir names    (for prettyprinting)
dir_t dirBuf;     // buffer for directory reads

WaveHC wave;      // This is the only wave (audio) object, since we will only play one at a time



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()); 

Marsi
 
Posts: 4
Joined: Fri Jun 29, 2018 9:41 am

Re: Wave Shield Programming

by adafruit_support_bill on Fri Jun 29, 2018 11:18 am

You can just comment out those lines of code. They can be useful for debugging, but are not essential for normal operation.

adafruit_support_bill
 
Posts: 69785
Joined: Sat Feb 07, 2009 10:11 am

Re: Wave Shield Programming

by Marsi on Fri Jun 29, 2018 11:49 am

I've deleted all of the freeRam stuff and also the errorCheck and now it gives me this error

Code: Select all | TOGGLE FULL SIZE
libraries\WaveHC\FatReader.cpp.o (symbol from plugin): In function `FatVolume::nextCluster(unsigned long)':

(.text+0x0): multiple definition of `printEntryName(directoryEntry&)'

sketch\sketch_jun28b.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here

C:\Users\MARALC~1\AppData\Local\Temp\ccpYY19M.ltrans0.ltrans.o: In function `main':

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/main.cpp:46: undefined reference to `loop'

collect2.exe: error: ld returned 1 exit status

exit status 1

Marsi
 
Posts: 4
Joined: Fri Jun 29, 2018 9:41 am

Re: Wave Shield Programming

by adafruit_support_bill on Fri Jun 29, 2018 11:59 am

Please post the code you are using.

adafruit_support_bill
 
Posts: 69785
Joined: Sat Feb 07, 2009 10:11 am

Re: Wave Shield Programming

by Marsi on Fri Jun 29, 2018 12:14 pm

Here you have it, it's the one in the " A tour of dap_hc.pde"

https://learn.adafruit.com/adafruit-wav ... hc-library

Code: Select all | TOGGLE FULL SIZE
#include "WaveUtil.h"
#include "WaveHC.h"


SdReader card;    // This object holds the information for the card
FatVolume vol;    // This holds the information for the partition on the card
FatReader root;   // This holds the information for the filesystem on the card

uint8_t dirLevel; // indent level for file/dir names    (for prettyprinting)
dir_t dirBuf;     // buffer for directory reads

WaveHC wave;      // This is the only wave (audio) object, since we will only play one at a time

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps for debugging
 
  putstring_nl("\nWave test!");  // say we woke up!
 
   
 
  // 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
 
 
  // 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
  }
 
 
  // 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);
}


/*
 * list recursively - possible stack overflow if subdirectories too nested
 */
void lsR(FatReader &d)
{
  int8_t r;                     // indicates the level of recursion
 
  while ((r = d.readDir(dirBuf)) > 0) {     // read the next file in the directory
    // skip subdirs . and ..
    if (dirBuf.name[0] == '.')
      continue;
   
    for (uint8_t i = 0; i < dirLevel; i++)
      Serial.print(' ');        // this is for prettyprinting, put spaces in front
    printEntryName(dirBuf);           // print the name of the file we just found
    Serial.println();           // and a new line
   
    if (DIR_IS_SUBDIR(dirBuf)) {   // we will recurse on any direcory
      FatReader s;                 // make a new directory object to hold information
      dirLevel += 2;               // indent 2 spaces for future prints
      if (s.open(vol, dirBuf))
        lsR(s);                    // list all the files in this directory now!
      dirLevel -=2;                // remove the extra indentation
    }
  }
               // are we doign OK?
}


/*
 * print dir_t name field. The output is 8.3 format, so like SOUND.WAV or FILENAME.DAT
 */
void printEntryName(dir_t &dir)
{
  for (uint8_t i = 0; i < 11; i++) {     // 8.3 format has 8+3 = 11 letters in it
    if (dir.name[i] == ' ')
        continue;         // dont print any spaces in the name
    if (i == 8)
        Serial.print('.');           // after the 8th letter, place a dot
    Serial.print(dir.name[i]);      // print the n'th digit
  }
  if (DIR_IS_SUBDIR(dir))
    Serial.print('/');       // directories get a / at the end
}

Marsi
 
Posts: 4
Joined: Fri Jun 29, 2018 9:41 am

Re: Wave Shield Programming

by adafruit_support_bill on Fri Jun 29, 2018 12:56 pm

Hmmm. That is missing the loop() function. It is not the complete program.

You can find the complete program in the WaveHC library here:
https://github.com/adafruit/WaveHC/blob ... /daphc.pde

adafruit_support_bill
 
Posts: 69785
Joined: Sat Feb 07, 2009 10:11 am

Re: Wave Shield Programming

by Marsi on Fri Jun 29, 2018 1:58 pm

Thank you very much!! I was worried because it was for a school project and i barely know the basics of arduino so this was too much for me, but you fixed it. Thanks!

Marsi
 
Posts: 4
Joined: Fri Jun 29, 2018 9:41 am

Re: Wave Shield Programming

by adafruit_support_bill on Fri Jun 29, 2018 2:08 pm

Good to hear. Thanks for the follow-up. :)

adafruit_support_bill
 
Posts: 69785
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.