I want to develop an application based on the library SimpleSDAudio.
Everything works ok if I run the examples included with the library.
After changing some C-code in the library sources these changes are not compiled when compiling the sketch. Always the original code is used.
For example I added a variable, anzsect, in the public area of the class definition in SimpleSDAudio.h and wanted to print it with Serial.print.
The compiler outputs the error: 'class SdPlayClass' has no member named 'anzsect'.
What shall I do to get the changed code of the library compiled?
I am confused !
Go into the preferences, check "Use external editor". Close the prefs. Compile. Reopen prefs, uncheck that option. Or switch to an external editor for real :). I like Geany.
class SdPlayClass {
// don't change this struct from here ...
private:
volatile uint8_t _flags;
uint8_t _flags2; // flags not touched in interrupt
volatile uint16_t _Buflen; // how much bytes are availible in buffer
uint8_t *_pBuf; // pointer to working buffer, used for audio and all kind of file access
volatile uint8_t *_pBufout; // pointer where next byte can read from the buffer
uint8_t *_pBufoutend; // points to _pBuf + _Bufsize
uint16_t _Bufsize; // size of working buffer, must be a multiple of 512, at least 1024
volatile uint16_t _Bufin; // index where next byte can put into the buffer
uint16_t _BufsizeMinus512; // used to avoid one calculation every time
volatile uint8_t _WorkTrig; // counter to autotrigger worker
// ...to here as it is adressed directly by assembler functions!
...
public:
SdPlayClass(void); // constructor
~SdPlayClass(void); // destructor
uint32_t anzsect; // this is the inserted code for test purposes <------------
void interrupt(void);
...
In SimpleSDAudio.cpp there is a function definition where I added 1 line too.
The else path is really performed. Otherwise the program woud not work at all:
void setup()
{
Serial.begin(9600);
// If your SD card CS-Pin is not at Pin 4, enable and adapt the following line:
// SdPlay.setSDCSPin(10);
// Init SdPlay and set audio mode
if (!SdPlay.init(SSDA_MODE_FULLRATE | SSDA_MODE_MONO)) {
while(1); // Error while initialization of SD card -> stop.
}
// Select file to play
if(!SdPlay.setFile("EXAMPLE.AFM")) {
while(1); // Error file not found -> stop.
}
Serial.print(F("max. Zahl Sektoren=")); // this line is inserted and is compiled and executed
Serial.print(SdPlay.anzsect); // on this line the compiler reports the error
// Start playback
SdPlay.play();
// Let the worker work until playback is finished
while(!SdPlay.isStopped()) {
SdPlay.worker();
}
}
When I delete the line where the error is reported everything is ok.
Where is the library installed?
The library is installed in H:\Arduino\examples\SimpleSDAudio
All my editing is performed also in this location. For editing I am using Notepad++.
a frustrated SupArdu
In the function
boolean SdPlayClass::setFile(char *fileName)
I also added a dummy call of get_anzsect() in order to see if this function can be executed:
...
uint32_t hhv=get_anzsect();
...
But now, considering your question, I deleted the declaration of get_anzsect() in the header file.
The status now is:
no declaration of get_anzsect() within header file
existing definition of get_anzsect() in the cpp file
call of get_anzsect() in the changed code of the library
In spite of calling the function within the code there is no error message during build.
Is'nt this a proof that the changed code is not used for build?
the problem is solved!
The questions where the library is located brought me on the right track.
I had the directory SimpleSDAudio twice, once in ...\examples\ and another one in ...\examples\libraries.
I guess that the IDE needs libraries in a directory named "libraries". During installation of the library I defined the path as ...\examples. But the IDE generated a folder "libraries" in the defined location and the library then in ...\examples\libraries\SimpleSDAudio.
Anyway, somebody (me? >:( ) copied the content of the library one level higher,
i.e. to ...\examples\SimpleSDAudio. Here I changed the code but the IDE used the code in
...\examples\libraries\SimpleSDAudio.
Click on the Quick Edit button on yourfirst post. Then you will see at the top of the first post there is a white box with the title that is editable. Edit it and then click the Save button.