Hello all
In some case, I usinf a fonction to display a text for debuging.
I call in that way:
sprint(F("Buz"),2);
The second parameter is use to eigher Display in Serial Monitor (0), write into a SD card (1), or both(2)
here is the fonction
void sprint(const __FlashStringHelper * message, int logToSd)
{
if(logToSd == 0 || logToSd == 2)
{
SerialUSB.print(message);
}
if(logToSd == 1 || logToSd == 2)
{
#ifdef LOGGER
sd_write(sd_logFile, message);
#endif
}
}
And here are the function to write SD.
The below function. The problem is, the below function does not accept __FlashStringHelper (for the text)
void sd_write(char * fileName, char * text)
{
//SerialUSB.println("*c*");
sd_write(fileName, text, false);
}
void sd_write(char * fileName, char * text, bool ln)
{
#ifdef LOGGER
if(isSdReady == true)
{
digitalWrite(PIN_SDLED, HIGH);
logfile = SD.open(fileName, FILE_WRITE);
// if the file opened okay, write to it:
if (logfile)
{
sprint(F("Writing ["),0);
sprint(text,0);
sprint(F("] to "),0);
sprint(F(fileName),0);
if(ln == true)
{
logfile.println(text);
}
else
{
logfile.print(text);
}
logfile.flush();
// close the file:
logfile.close();
sprintln(F(" => Done."),0);
}
else
{
// if the file didn't open, print an error:
sprint(F("\nError opening "),0); sprintln(fileName,0);
}
digitalWrite(PIN_SDLED, LOW);
// delay(100);
}
#endif
}
Is there a way to craete a function as described here (see comment)
const __FlashStringHelper *
void sd_write(char * fileName, const __FlashStringHelper * text)
{
// CONVERT HERE the const __FlashStringHelper TO BE USE BY text
sd_write(fileName, text, false);
}
Thank a lot