AdmiralCrunch
Well-known member
Hi
I read a line from startCfg.txt on my SD-card, .. I split it by ":" , and then put the slices into String-Variables.
Now I push the cfgValue as a argument to loadCfgFile(), where I want this file to be loaded:
this does not work. As I can see in the https://github.com/PaulStoffregen/SD/blob/master/SD.cpp the open()-method expects a const char *
.. how would I convert it? or is there a other solution?
I read a line from startCfg.txt on my SD-card, .. I split it by ":" , and then put the slices into String-Variables.
Code:
// READ INIT-CONFIG
startCfg = SD.open("startCfg.txt");
if (startCfg) {
// read each line
while (startCfg.available()) {
helpVarString = startCfg.readStringUntil('\n');
// split line by :
cfgName = getValue(helpVarString, ':', 0);
cfgValue = getValue(helpVarString, ':', 1);
if(cfgName == "MappingPreset") {
// load cfg file
loadCfgFile(cfgValue);
}
}
startCfg.close();
} else {
Serial.println("error opening startCfg.txt");
}
Now I push the cfgValue as a argument to loadCfgFile(), where I want this file to be loaded:
Code:
void loadCfgFile(String cfgFile) {
Serial.println(cfgFile); // contains Sring "Default"
loadedCfg = SD.open(cfgFile + ".txt"); // should read Default.txt
if (loadedCfg) {
Serial.println("Loading OK");
}
startCfg.close();
} else {
Serial.print("error opening "); Serial.print(cfgFile); Serial.println(".txt");
}
}
this does not work. As I can see in the https://github.com/PaulStoffregen/SD/blob/master/SD.cpp the open()-method expects a const char *
Code:
File SDClass::open(const char *filepath, uint8_t mode)