Rename prefix temp hum correction enum member

This commit is contained in:
samuelbles07
2025-02-05 11:05:36 +07:00
parent 4b09b98524
commit 15869be234
3 changed files with 20 additions and 20 deletions

View File

@ -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<int>(CA_TH_SLR_CUSTOM);
TempHumCorrectionAlgorithm result = CA_TH_UNKNOWN;
const int enumSize = static_cast<int>(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

View File

@ -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;
}

View File

@ -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 {