Arduino understanding passing data to functions

dr pepper

Well-Known Member
Most Helpful Member
I recently got a mp3 player shield, it has the vs1053 codec, similar to sparkfun's & adafruits.
I can play mp3's from an sd card, at first I put a file on the sd as per the tutorial called track001.mp3, that worked, then I put a sd card in with a load of music on and changed the track001 to wave/800hz and it worked, the mp3 file was in a folder on the sd called wave, and within the folder the track is called 800hz.
This is the library function to play a track copied from the .h file:

boolean startPlayingFile(const char *trackname);

So I tried this in my code

musicPlayer.startPlayingFile(inData)

Indata is a character string read in from serial, I presume this doesnt work as the original function has const char defined.

Sparkfun also does a library for this chip, but its really complex.
 
Thats the funny thing.
The Lib didnt like me passing it a string as in String, however when I redid the code and used a character array instead of a string it worked, I thought a string was a character array - with a null at the end.
All this without changing the header or ++ file.
I've just been reading sdfat docs, not something I really enjoy.

Anway whats with the new booze bottle I thought you like single malt not that treacle.
 
With embedded processors the Constant pointer can be cast to a ram pointer but not the reverse... So you have to change the function... With C++ you can overload the function and just copy it with a character function as the parameter... Define the new overload in the private section and you can then use both..

The Brandy was a Christmas gift from the wife... I like most liquids.... I love rum as well..
 
Yes I get that, never had it exactly like that before.

5 years now since I had any booze, I was never a big boozer, just packed it in.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…