forked from airgradienthq/arduino
correction function return raw if algorithm is none
This commit is contained in:
@ -485,6 +485,7 @@ void Measurements::validateChannel(int ch) {
|
|||||||
|
|
||||||
float Measurements::getCorrectedPM25(AirGradient &ag, Configuration &config, bool useAvg, int ch) {
|
float Measurements::getCorrectedPM25(AirGradient &ag, Configuration &config, bool useAvg, int ch) {
|
||||||
float pm25;
|
float pm25;
|
||||||
|
float corrected;
|
||||||
float humidity;
|
float humidity;
|
||||||
float pm003Count;
|
float pm003Count;
|
||||||
int channel = ch - 1; // Array index
|
int channel = ch - 1; // Array index
|
||||||
@ -500,19 +501,27 @@ float Measurements::getCorrectedPM25(AirGradient &ag, Configuration &config, boo
|
|||||||
}
|
}
|
||||||
|
|
||||||
Configuration::PMCorrection pmCorrection = config.getPMCorrection();
|
Configuration::PMCorrection pmCorrection = config.getPMCorrection();
|
||||||
if (pmCorrection.algorithm == PMCorrectionAlgorithm::EPA_2021) {
|
switch (pmCorrection.algorithm) {
|
||||||
// EPA correction directly applied
|
case PMCorrectionAlgorithm::Unknown:
|
||||||
pm25 = ag.pms5003.compensate(pm25, humidity);
|
case PMCorrectionAlgorithm::None:
|
||||||
} else {
|
// If correction is Unknown, then default is None
|
||||||
// SLR correction, this is assumes before calling this function, correction algorithm is not None
|
corrected = pm25;
|
||||||
pm25 = ag.pms5003.slrCorrection(pm25, pm003Count, pmCorrection.scalingFactor, pmCorrection.intercept);
|
break;
|
||||||
|
case PMCorrectionAlgorithm::EPA_2021:
|
||||||
|
corrected = ag.pms5003.compensate(pm25, humidity);
|
||||||
|
break;
|
||||||
|
default: {
|
||||||
|
// All SLR correction using the same flow
|
||||||
|
corrected = ag.pms5003.slrCorrection(pm25, pm003Count, pmCorrection.scalingFactor,
|
||||||
|
pmCorrection.intercept);
|
||||||
if (pmCorrection.useEPA) {
|
if (pmCorrection.useEPA) {
|
||||||
// Add EPA compensation on top of SLR
|
// Add EPA compensation on top of SLR
|
||||||
pm25 = ag.pms5003.compensate(pm25, humidity);
|
corrected = ag.pms5003.compensate(pm25, humidity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return pm25;
|
return corrected;
|
||||||
}
|
}
|
||||||
|
|
||||||
String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi, AirGradient &ag,
|
String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi, AirGradient &ag,
|
||||||
|
Reference in New Issue
Block a user