tone() with sanguino

I am trying to use the tone() function with a sanguino board. When I complie the example code toneMelody.pde I get this error:

toneMelody.cpp: In function 'void setup()':
toneMelody:35: error: 'tone' was not declared in this scope
toneMelody:42: error: 'noTone' was not declared in this scope

I can compile as long as a Duemilanove is selected as the board (or any other board for that matter.) I can also upload the sketch, play the tune etc. This is only a problem with the Sanguino board.

I have searched for this problem, and seen several posts, but none have a definate answer. I have tried deleting the Arduino folders, re-downloading, recopying/downloading the Sanguino Hardware folder. and I have tried both Version 22 and 23 of Arduino.

Does anyone know how to fix this issue?

Thanks

I think I may have figured this out for myself. I do not know too much about changing around the arduino hardware - but after reviewing a lot of forums about this issue and some trial and eerror. This is what I did to make it work.

Open the file named WProgram.h in the arduino-0022\hardware\Sanguino\cores\arduino folder.

add the following two lines:

void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0);
void noTone(uint8_t _pin);

save the file, Close Arduino, reopen Arduino, Upload and it did compile for me.

I do not know why this works but it does. If anyone else knows why, I would like to know so that I could solve a similar issue in the future, and understand what I am doing.

Since you are not actually implementing the tone and noTone functions with the change you made, the tone and noTone functions must actually be defined somewhere (they are). So, you should find the header file in which they are defined, and include that, not modify WProgram.h.

PaulS:
Since you are not actually implementing the tone and noTone functions with the change you made, the tone and noTone functions must actually be defined somewhere (they are). So, you should find the header file in which they are defined, and include that, not modify WProgram.h.

Actually, no. Sanguino doesn't declare tone or noTone. His solution is actually the right one.

Sanguino doesn't declare tone or noTone. His solution is actually the right one.

Declaring something in a header file is only part of making something happen. There must also be an implementation. If adding the statements to one header file results in no undefined external references then the functions are implemented somewhere. If that is the case, then there must also be a declaration for them, somewhere.

I still contend that finding where they are declared, and including that header file is a better solution. But, whatever works...

PaulS:
there must also be a declaration for them, somewhere.

You would think so. There certainly should be. But in fact there is not. Sanguino includes implementations for tone/noTone but does not bother to declare them. Check the files.

all
I agree with manicbug that the files do not contain the function prototype in a header.
I agree with Paul that you should not declare these functions in WProgram.
Therefore I think it is best to create a file called tone.h and add the prototypes there or simply add them at the top of your code.
Best regards
Jantje

There is considerable difference between the WProgram.h file delivered with the Arduino IDE and the WProgram.h file delivered with the Sanguino package. Almost like the Sanguino package is not being maintained.