I'm working on the datalogging aspect of my project.
In the text file on the SD card, I want the text to look like:
Date , Time ,Value1,Cmd,Status
05/03/2018,13:45:34, 12.3 , On, Run
The commas should align vertically and the values and heading centered.
My thought was to create a header write function that would accept the header text, write the text and the comma to the file, and return the column width. The column width would then be passed to the the data write function that would add the correct number of spaces before and after the data record to get the next comma in the correct location.
I can't recal; having ever written a function to receive a constant char [] value. The one I wrote is throwing an warning during the compile.
Relevant Code:
uint8_t writeHeaderText(char text[])
{
file.print(text);
file.print(",");
return(strlen(text));
}
void logHeader()
{
logColWidth[0]=writeHeaderText(" Date ");
logColWidth[1]=writeHeaderText(" Time ");
}
Error:
C:\Users\Ralph-Win7\Documents\Arduino\Pool_Heater_Main_V6\Pool_Heater_Main_V6.ino: In function 'void logHeader()':
C:\Users\Ralph-Win7\Documents\Arduino\Pool_Heater_Main_V6\Pool_Heater_Main_V6.ino:503:46: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
logColWidth[0]=writeHeaderText(" Date ");
^
C:\Users\Ralph-Win7\Documents\Arduino\Pool_Heater_Main_V6\Pool_Heater_Main_V6.ino:504:44: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
logColWidth[1]=writeHeaderText(" Time ");
^
I prefer my code to be warning free. Any help on how the 'correct' way to pass the text without a compiler warning. It must be doable, Serial.print("x") works just fine.