From 15869be234482a5f3a965ab1b3b62d7f71b795e2 Mon Sep 17 00:00:00 2001 From: samuelbles07 Date: Wed, 5 Feb 2025 11:05:36 +0700 Subject: [PATCH] Rename prefix temp hum correction enum member --- src/AgConfigure.cpp | 20 ++++++++++---------- src/AgValue.cpp | 12 ++++++------ src/App/AppDef.h | 8 ++++---- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/AgConfigure.cpp b/src/AgConfigure.cpp index 63e5e8f..5fa8d3c 100644 --- a/src/AgConfigure.cpp +++ b/src/AgConfigure.cpp @@ -34,10 +34,10 @@ const char *PM_CORRECTION_ALGORITHM_NAMES[] = { }; const char *TEMP_HUM_CORRECTION_ALGORITHM_NAMES[] = { - [CA_TH_UNKNOWN] = "-", // This is only to pass "non-trivial designated initializers" error - [CA_TH_NONE] = "none", - [CA_TH_AG_PMS5003T_2024] = "ag_pms5003t_2024", - [CA_TH_SLR_CUSTOM] = "custom", + [COR_ALGO_TEMP_HUM_UNKNOWN] = "-", // This is only to pass "non-trivial designated initializers" error + [COR_ALGO_TEMP_HUM_NONE] = "none", + [COR_ALGO_TEMP_HUM_AG_PMS5003T_2024] = "ag_pms5003t_2024", + [COR_ALGO_TEMP_HUM_SLR_CUSTOM] = "custom", }; #define JSON_PROP_NAME(name) jprop_##name @@ -128,8 +128,8 @@ PMCorrectionAlgorithm Configuration::matchPmAlgorithm(String algorithm) { TempHumCorrectionAlgorithm Configuration::matchTempHumAlgorithm(String algorithm) { // Get the actual size of the enum - const int enumSize = static_cast(CA_TH_SLR_CUSTOM); - TempHumCorrectionAlgorithm result = CA_TH_UNKNOWN; + const int enumSize = static_cast(COR_ALGO_TEMP_HUM_SLR_CUSTOM); + TempHumCorrectionAlgorithm result = COR_ALGO_TEMP_HUM_UNKNOWN; // Loop through enum values for (size_t enumVal = 0; enumVal <= enumSize; enumVal++) { @@ -251,7 +251,7 @@ bool Configuration::updateTempHumCorrection(JSONVar &json, TempHumCorrection &ta String algorithm = correctionTarget["correctionAlgorithm"]; TempHumCorrectionAlgorithm algo = matchTempHumAlgorithm(algorithm); - if (algo == CA_TH_UNKNOWN) { + if (algo == COR_ALGO_TEMP_HUM_UNKNOWN) { logInfo("Uknown temp/hum algorithm"); return false; } @@ -259,7 +259,7 @@ bool Configuration::updateTempHumCorrection(JSONVar &json, TempHumCorrection &ta // If algo is None or Standard, then no need to check slr // But first check if target correction different from algo - if (algo == CA_TH_NONE || algo == CA_TH_AG_PMS5003T_2024) { + if (algo == COR_ALGO_TEMP_HUM_NONE || algo == COR_ALGO_TEMP_HUM_AG_PMS5003T_2024) { if (target.algorithm != algo) { // Deep copy corrections from root to jconfig, so it will be saved later jconfig[jprop_corrections][correctionName]["correctionAlgorithm"] = algorithm; @@ -1376,7 +1376,7 @@ void Configuration::toConfig(const char *buf) { // Temperature correction /// Set default first before parsing local config - tempCorrection.algorithm = CA_TH_NONE; + tempCorrection.algorithm = COR_ALGO_TEMP_HUM_NONE; tempCorrection.intercept = 0; tempCorrection.scalingFactor = 0; /// Load correction from saved config @@ -1384,7 +1384,7 @@ void Configuration::toConfig(const char *buf) { // Relative humidity correction /// Set default first before parsing local config - rhumCorrection.algorithm = CA_TH_NONE; + rhumCorrection.algorithm = COR_ALGO_TEMP_HUM_NONE; rhumCorrection.intercept = 0; rhumCorrection.scalingFactor = 0; /// Load correction from saved config diff --git a/src/AgValue.cpp b/src/AgValue.cpp index c6be2e8..c7b2272 100644 --- a/src/AgValue.cpp +++ b/src/AgValue.cpp @@ -554,9 +554,9 @@ float Measurements::getCorrectedTempHum(MeasurementType type, int ch, bool force Configuration::TempHumCorrection tmp = config.getTempCorrection(); // Apply 'standard' correction if its defined or correction forced - if (tmp.algorithm == TempHumCorrectionAlgorithm::CA_TH_AG_PMS5003T_2024) { + if (tmp.algorithm == TempHumCorrectionAlgorithm::COR_ALGO_TEMP_HUM_AG_PMS5003T_2024) { return ag->pms5003t_1.compensateTemp(rawValue); - } else if (tmp.algorithm == TempHumCorrectionAlgorithm::CA_TH_NONE && forceCorrection) { + } else if (tmp.algorithm == TempHumCorrectionAlgorithm::COR_ALGO_TEMP_HUM_NONE && forceCorrection) { return ag->pms5003t_1.compensateTemp(rawValue); } @@ -570,9 +570,9 @@ float Measurements::getCorrectedTempHum(MeasurementType type, int ch, bool force Configuration::TempHumCorrection tmp = config.getHumCorrection(); // Apply 'standard' correction if its defined or correction forced - if (tmp.algorithm == TempHumCorrectionAlgorithm::CA_TH_AG_PMS5003T_2024) { + if (tmp.algorithm == TempHumCorrectionAlgorithm::COR_ALGO_TEMP_HUM_AG_PMS5003T_2024) { return ag->pms5003t_1.compensateHum(rawValue); - } else if (tmp.algorithm == TempHumCorrectionAlgorithm::CA_TH_NONE && forceCorrection) { + } else if (tmp.algorithm == TempHumCorrectionAlgorithm::COR_ALGO_TEMP_HUM_NONE && forceCorrection) { return ag->pms5003t_1.compensateHum(rawValue); } @@ -588,8 +588,8 @@ float Measurements::getCorrectedTempHum(MeasurementType type, int ch, bool force } // Use raw if correction not defined - if (correction.algorithm == TempHumCorrectionAlgorithm::CA_TH_NONE || - correction.algorithm == TempHumCorrectionAlgorithm::CA_TH_UNKNOWN) { + if (correction.algorithm == TempHumCorrectionAlgorithm::COR_ALGO_TEMP_HUM_NONE || + correction.algorithm == TempHumCorrectionAlgorithm::COR_ALGO_TEMP_HUM_UNKNOWN) { return rawValue; } diff --git a/src/App/AppDef.h b/src/App/AppDef.h index 9a03a71..20b8b01 100644 --- a/src/App/AppDef.h +++ b/src/App/AppDef.h @@ -108,10 +108,10 @@ enum PMCorrectionAlgorithm { // Don't change the order of the enum enum TempHumCorrectionAlgorithm { - CA_TH_UNKNOWN, // Unknown algorithm - CA_TH_NONE, // No PM correction - CA_TH_AG_PMS5003T_2024, - CA_TH_SLR_CUSTOM + COR_ALGO_TEMP_HUM_UNKNOWN, // Unknown algorithm + COR_ALGO_TEMP_HUM_NONE, // No PM correction + COR_ALGO_TEMP_HUM_AG_PMS5003T_2024, + COR_ALGO_TEMP_HUM_SLR_CUSTOM }; enum AgFirmwareMode {