Skip to content

Commit 38aebeb

Browse files
committed
Reformat pm correction enum naming
1 parent b0f5263 commit 38aebeb

File tree

3 files changed

+30
-30
lines changed

3 files changed

+30
-30
lines changed

src/AgConfigure.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ const char *LED_BAR_MODE_NAMES[] = {
2222
};
2323

2424
const char *PM_CORRECTION_ALGORITHM_NAMES[] = {
25-
[Unknown] = "-", // This is only to pass "non-trivial designated initializers" error
26-
[None] = "none",
27-
[EPA_2021] = "epa_2021",
28-
[SLR_PMS5003_20220802] = "slr_PMS5003_20220802",
29-
[SLR_PMS5003_20220803] = "slr_PMS5003_20220803",
30-
[SLR_PMS5003_20220824] = "slr_PMS5003_20220824",
31-
[SLR_PMS5003_20231030] = "slr_PMS5003_20231030",
32-
[SLR_PMS5003_20231218] = "slr_PMS5003_20231218",
33-
[SLR_PMS5003_20240104] = "slr_PMS5003_20240104",
25+
[COR_ALGO_PM_UNKNOWN] = "-", // This is only to pass "non-trivial designated initializers" error
26+
[COR_ALGO_PM_NONE] = "none",
27+
[COR_ALGO_PM_EPA_2021] = "epa_2021",
28+
[COR_ALGO_PM_PMS5003_20220802] = "slr_PMS5003_20220802",
29+
[COR_ALGO_PM_PMS5003_20220803] = "slr_PMS5003_20220803",
30+
[COR_ALGO_PM_PMS5003_20220824] = "slr_PMS5003_20220824",
31+
[COR_ALGO_PM_PMS5003_20231030] = "slr_PMS5003_20231030",
32+
[COR_ALGO_PM_PMS5003_20231218] = "slr_PMS5003_20231218",
33+
[COR_ALGO_PM_PMS5003_20240104] = "slr_PMS5003_20240104",
3434
};
3535

3636
const char *TEMP_HUM_CORRECTION_ALGORITHM_NAMES[] = {
@@ -115,8 +115,8 @@ PMCorrectionAlgorithm Configuration::matchPmAlgorithm(String algorithm) {
115115
// If the input string matches an algorithm name, return the corresponding enum value
116116
// Else return Unknown
117117

118-
const size_t enumSize = SLR_PMS5003_20240104 + 1; // Get the actual size of the enum
119-
PMCorrectionAlgorithm result = PMCorrectionAlgorithm::Unknown;
118+
const size_t enumSize = COR_ALGO_PM_PMS5003_20240104 + 1; // Get the actual size of the enum
119+
PMCorrectionAlgorithm result = COR_ALGO_PM_UNKNOWN;;
120120

121121
// Loop through enum values
122122
for (size_t enumVal = 0; enumVal < enumSize; enumVal++) {
@@ -166,15 +166,15 @@ bool Configuration::updatePmCorrection(JSONVar &json) {
166166
// Check algorithm
167167
String algorithm = pm02["correctionAlgorithm"];
168168
PMCorrectionAlgorithm algo = matchPmAlgorithm(algorithm);
169-
if (algo == Unknown) {
169+
if (algo == COR_ALGO_PM_UNKNOWN) {
170170
logInfo("Unknown algorithm");
171171
return false;
172172
}
173173
logInfo("Correction algorithm: " + algorithm);
174174

175175
// If algo is None or EPA_2021, no need to check slr
176176
// But first check if pmCorrection different from algo
177-
if (algo == None || algo == EPA_2021) {
177+
if (algo == COR_ALGO_PM_NONE || algo == COR_ALGO_PM_EPA_2021) {
178178
if (pmCorrection.algorithm != algo) {
179179
// Deep copy corrections from root to jconfig, so it will be saved later
180180
jconfig[jprop_corrections]["pm02"]["correctionAlgorithm"] = algorithm;
@@ -397,8 +397,8 @@ void Configuration::defaultConfig(void) {
397397
jconfig[jprop_offlineMode] = jprop_offlineMode_default;
398398
jconfig[jprop_monitorDisplayCompensatedValues] = jprop_monitorDisplayCompensatedValues_default;
399399

400-
// PM2.5 correction
401-
pmCorrection.algorithm = None;
400+
// PM2.5 default correction
401+
pmCorrection.algorithm = COR_ALGO_PM_NONE;
402402
pmCorrection.changed = false;
403403
pmCorrection.intercept = 0;
404404
pmCorrection.scalingFactor = 1;
@@ -1380,7 +1380,7 @@ void Configuration::toConfig(const char *buf) {
13801380

13811381
// PM2.5 correction
13821382
/// Set default first before parsing local config
1383-
pmCorrection.algorithm = PMCorrectionAlgorithm::None;
1383+
pmCorrection.algorithm = COR_ALGO_PM_NONE;
13841384
pmCorrection.intercept = 0;
13851385
pmCorrection.scalingFactor = 0;
13861386
pmCorrection.useEPA = false;
@@ -1526,8 +1526,8 @@ bool Configuration::isPMCorrectionChanged(void) {
15261526
*/
15271527
bool Configuration::isPMCorrectionEnabled(void) {
15281528
PMCorrection pmCorrection = getPMCorrection();
1529-
if (pmCorrection.algorithm == PMCorrectionAlgorithm::None ||
1530-
pmCorrection.algorithm == PMCorrectionAlgorithm::Unknown) {
1529+
if (pmCorrection.algorithm == COR_ALGO_PM_NONE ||
1530+
pmCorrection.algorithm == COR_ALGO_PM_UNKNOWN) {
15311531
return false;
15321532
}
15331533

src/AgValue.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -658,12 +658,12 @@ float Measurements::getCorrectedPM25(bool useAvg, int ch) {
658658

659659
Configuration::PMCorrection pmCorrection = config.getPMCorrection();
660660
switch (pmCorrection.algorithm) {
661-
case PMCorrectionAlgorithm::Unknown:
662-
case PMCorrectionAlgorithm::None:
661+
case PMCorrectionAlgorithm::COR_ALGO_PM_UNKNOWN:
662+
case PMCorrectionAlgorithm::COR_ALGO_PM_NONE:
663663
// If correction is Unknown, then default is None
664664
corrected = pm25;
665665
break;
666-
case PMCorrectionAlgorithm::EPA_2021:
666+
case PMCorrectionAlgorithm::COR_ALGO_PM_EPA_2021:
667667
corrected = ag->pms5003.compensate(pm25, humidity);
668668
break;
669669
default: {

src/App/AppDef.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@ enum ConfigurationControl {
9595
};
9696

9797
enum PMCorrectionAlgorithm {
98-
Unknown, // Unknown algorithm
99-
None, // No PM correction
100-
EPA_2021,
101-
SLR_PMS5003_20220802,
102-
SLR_PMS5003_20220803,
103-
SLR_PMS5003_20220824,
104-
SLR_PMS5003_20231030,
105-
SLR_PMS5003_20231218,
106-
SLR_PMS5003_20240104,
98+
COR_ALGO_PM_UNKNOWN, // Unknown algorithm
99+
COR_ALGO_PM_NONE, // No PM correction
100+
COR_ALGO_PM_EPA_2021,
101+
COR_ALGO_PM_PMS5003_20220802,
102+
COR_ALGO_PM_PMS5003_20220803,
103+
COR_ALGO_PM_PMS5003_20220824,
104+
COR_ALGO_PM_PMS5003_20231030,
105+
COR_ALGO_PM_PMS5003_20231218,
106+
COR_ALGO_PM_PMS5003_20240104,
107107
};
108108

109109
// Don't change the order of the enum

0 commit comments

Comments
 (0)