forked from airgradienthq/arduino
Copy correction object to jconfig
This commit is contained in:
@ -146,6 +146,7 @@ bool Configuration::updatePmCorrection(JSONVar &json) {
|
|||||||
// But first check if pmCorrection different from algo
|
// But first check if pmCorrection different from algo
|
||||||
if (algo == None || algo == EPA_2021) {
|
if (algo == None || algo == EPA_2021) {
|
||||||
if (pmCorrection.algorithm != algo) {
|
if (pmCorrection.algorithm != algo) {
|
||||||
|
jconfig[jprop_corrections]["pm02"]["correctionAlgorithm"] = algorithm;
|
||||||
pmCorrection.algorithm = algo;
|
pmCorrection.algorithm = algo;
|
||||||
pmCorrection.changed = true;
|
pmCorrection.changed = true;
|
||||||
Serial.println("PM2.5 correction updated");
|
Serial.println("PM2.5 correction updated");
|
||||||
@ -177,6 +178,10 @@ bool Configuration::updatePmCorrection(JSONVar &json) {
|
|||||||
return false; // No changes needed
|
return false; // No changes needed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deep copy corrections from root to jconfig, so it will be saved later
|
||||||
|
jconfig[jprop_corrections] = corrections;
|
||||||
|
Serial.println("Correction copied");
|
||||||
|
|
||||||
// Update pmCorrection with new values
|
// Update pmCorrection with new values
|
||||||
pmCorrection.algorithm = algo;
|
pmCorrection.algorithm = algo;
|
||||||
pmCorrection.intercept = (double)slr["intercept"];
|
pmCorrection.intercept = (double)slr["intercept"];
|
||||||
@ -778,8 +783,6 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
|
|
||||||
// Corrections
|
// Corrections
|
||||||
if (updatePmCorrection(root)) {
|
if (updatePmCorrection(root)) {
|
||||||
// Deep copy corrections from root to jconfig, so it will be saved later
|
|
||||||
jconfig[jprop_corrections] = JSON.parse(JSON.stringify(root["corrections"]));
|
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user