Is your feature request related to a problem? Please describe.
Right now, the following lines of code need to be added for every unique NVS implementation:
// Iterate through the parameter array in memory and put loaded values there
for (uint8_t i = 0; i < NUM_PARAMETERS; i++) {
if (typeid(*params[i]) == typeid(parameter_bool_t)) {
Serial1.println("Got boolean parameter!"); // Debug
dynamic_cast<parameter_bool_t*>(params[i])->value = parameterSettings.getBool(params[i]->key);
params[i]->type = RCLC_PARAMETER_BOOL;
}
else if (typeid(*params[i]) == typeid(parameter_int_t)) {
Serial1.println("Got integer parameter!"); // Debug
dynamic_cast<parameter_int_t*>(params[i])->value = parameterSettings.getInt(params[i]->key);
params[i]->type = RCLC_PARAMETER_INT;
}
else if (typeid(*params[i]) == typeid(parameter_double_t)) {
Serial1.println("Got double parameter!"); // Debug
dynamic_cast<parameter_double_t*>(params[i])->value = parameterSettings.getDouble(params[i]->key);
params[i]->type = RCLC_PARAMETER_DOUBLE;
}
else {
params[i]->type = RCLC_PARAMETER_NOT_SET;
}
}
This can get very clunky once more NVS solutions are implemented for EEPROM versus Preferences versus JSON, etc.
Describe the solution you'd like
The parameter value import line (dynamic_cast<parameter_bool_t*>(params[i])->value = parameterSettings.getBool(params[i]->key);) should be modified to use a callback (e.g. getBoolCB()) that can be changed depending on the NVS implementation. This will make it a single loop for importing all the data, regardless of the NVS solution.
Is your feature request related to a problem? Please describe. Right now, the following lines of code need to be added for every unique NVS implementation:
This can get very clunky once more NVS solutions are implemented for EEPROM versus Preferences versus JSON, etc.
Describe the solution you'd like The parameter value import line (
dynamic_cast<parameter_bool_t*>(params[i])->value = parameterSettings.getBool(params[i]->key);
) should be modified to use a callback (e.g.getBoolCB()
) that can be changed depending on the NVS implementation. This will make it a single loop for importing all the data, regardless of the NVS solution.