From 0275aee370b69624398dc7005c334eee21b8035f Mon Sep 17 00:00:00 2001 From: samuelbles07 Date: Sat, 2 Nov 2024 10:34:35 +0700 Subject: [PATCH] Copy correction object to jconfig --- src/AgConfigure.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/AgConfigure.cpp b/src/AgConfigure.cpp index 16f91b0..7d311e1 100644 --- a/src/AgConfigure.cpp +++ b/src/AgConfigure.cpp @@ -146,6 +146,7 @@ bool Configuration::updatePmCorrection(JSONVar &json) { // But first check if pmCorrection different from algo if (algo == None || algo == EPA_2021) { if (pmCorrection.algorithm != algo) { + jconfig[jprop_corrections]["pm02"]["correctionAlgorithm"] = algorithm; pmCorrection.algorithm = algo; pmCorrection.changed = true; Serial.println("PM2.5 correction updated"); @@ -177,6 +178,10 @@ bool Configuration::updatePmCorrection(JSONVar &json) { 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 pmCorrection.algorithm = algo; pmCorrection.intercept = (double)slr["intercept"]; @@ -778,8 +783,6 @@ bool Configuration::parse(String data, bool isLocal) { // Corrections 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; }