Change pm25Compensated to compensated

This commit is contained in:
Phat Nguyen
2024-08-16 06:39:52 +07:00
parent 6cd587b008
commit f3a9c722b2
8 changed files with 20 additions and 20 deletions

View File

@ -306,7 +306,7 @@ void OledDisplay::showDashboard(const char *status) {
/** Draw PM2.5 value */ /** Draw PM2.5 value */
int pm25 = value.pm25_1; int pm25 = value.pm25_1;
if (config.hasSensorSHT) { if (config.hasSensorSHT) {
pm25 = ag->pms5003.pm25Compensated(pm25, value.Humidity); pm25 = ag->pms5003.compensated(pm25, value.Humidity);
} }
DISP()->setFont(u8g2_font_t0_22b_tf); DISP()->setFont(u8g2_font_t0_22b_tf);
if (config.isPmStandardInUSAQI()) { if (config.isPmStandardInUSAQI()) {
@ -366,7 +366,7 @@ void OledDisplay::showDashboard(const char *status) {
/** Set PM */ /** Set PM */
int pm25 = value.pm25_1; int pm25 = value.pm25_1;
if(config.hasSensorSHT) { if(config.hasSensorSHT) {
pm25 = (int)ag->pms5003.pm25Compensated(pm25, value.Humidity); pm25 = (int)ag->pms5003.compensated(pm25, value.Humidity);
} }
ag->display.setCursor(0, 12); ag->display.setCursor(0, 12);
if (utils::isValidPMS(value.pm25_1)) { if (utils::isValidPMS(value.pm25_1)) {

View File

@ -51,7 +51,7 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
} }
if (config->hasSensorSHT && config->hasSensorPMS1) { if (config->hasSensorSHT && config->hasSensorPMS1) {
int pm25 = ag->pms5003.pm25Compensated(this->pm25_1, this->Humidity); int pm25 = ag->pms5003.compensated(this->pm25_1, this->Humidity);
if (pm25 >= 0) { if (pm25 >= 0) {
root["pm02Compensated"] = pm25; root["pm02Compensated"] = pm25;
} }
@ -92,8 +92,8 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
} }
} }
int pm25 = (ag->pms5003t_1.pm25Compensated(this->pm25_1, this->temp_1) + int pm25 = (ag->pms5003t_1.compensated(this->pm25_1, this->temp_1) +
ag->pms5003t_2.pm25Compensated(this->pm25_2, this->temp_2)) / ag->pms5003t_2.compensated(this->pm25_2, this->temp_2)) /
2; 2;
root["pm02Compensated"] = pm25; root["pm02Compensated"] = pm25;
} }
@ -133,7 +133,7 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
} }
} }
} }
root["pm02Compensated"] = ag->pms5003t_1.pm25Compensated(this->pm25_1, this->temp_1); root["pm02Compensated"] = ag->pms5003t_1.compensated(this->pm25_1, this->temp_1);
} }
if (config->hasSensorPMS2) { if (config->hasSensorPMS2) {
if(utils::isValidPMS(this->pm01_2)) { if(utils::isValidPMS(this->pm01_2)) {
@ -170,7 +170,7 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
} }
} }
} }
root["pm02Compensated"] = ag->pms5003t_2.pm25Compensated(this->pm25_2, this->temp_2); root["pm02Compensated"] = ag->pms5003t_2.compensated(this->pm25_2, this->temp_2);
} }
} else { } else {
if (fwMode == FW_MODE_O_1P) { if (fwMode == FW_MODE_O_1P) {
@ -207,7 +207,7 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
} }
} }
} }
root["pm02Compensated"] = ag->pms5003t_1.pm25Compensated(this->pm25_1, this->temp_1); root["pm02Compensated"] = ag->pms5003t_1.compensated(this->pm25_1, this->temp_1);
} else if (config->hasSensorPMS2) { } else if (config->hasSensorPMS2) {
if(utils::isValidPMS(this->pm01_2)) { if(utils::isValidPMS(this->pm01_2)) {
root["pm01"] = this->pm01_2; root["pm01"] = this->pm01_2;
@ -241,7 +241,7 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
} }
} }
} }
root["pm02Compensated"] = ag->pms5003t_1.pm25Compensated(this->pm25_1, this->temp_1); root["pm02Compensated"] = ag->pms5003t_1.compensated(this->pm25_1, this->temp_1);
} }
} else { } else {
float val; float val;
@ -278,7 +278,7 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
} }
} }
} }
root["channels"]["1"]["pm02Compensated"] = ag->pms5003t_1.pm25Compensated(this->pm25_1, this->temp_1); root["channels"]["1"]["pm02Compensated"] = ag->pms5003t_1.compensated(this->pm25_1, this->temp_1);
} }
if (config->hasSensorPMS2) { if (config->hasSensorPMS2) {
float val; float val;
@ -314,7 +314,7 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
} }
} }
} }
root["channels"]["2"]["pm02Compensated"] = ag->pms5003t_2.pm25Compensated(this->pm25_2, this->temp_2); root["channels"]["2"]["pm02Compensated"] = ag->pms5003t_2.compensated(this->pm25_2, this->temp_2);
} }
} }
} }

View File

@ -275,9 +275,9 @@ int PMSBase::pm25ToAQI(int pm02) {
* *
* @param pm25 Raw PM2.5 value * @param pm25 Raw PM2.5 value
* @param humidity Humidity value (%) * @param humidity Humidity value (%)
* @return float * @return int
*/ */
int PMSBase::pm25Compensated(int pm25, float humidity) { int PMSBase::compensated(int pm25, float humidity) {
float value; float value;
if (humidity < 0) { if (humidity < 0) {
humidity = 0; humidity = 0;

View File

@ -28,7 +28,7 @@ public:
uint16_t getHum(void); uint16_t getHum(void);
int pm25ToAQI(int pm02); int pm25ToAQI(int pm02);
int pm25Compensated(int pm25, float humidity); int compensated(int pm25, float humidity);
private: private:
Stream *stream; Stream *stream;

View File

@ -128,8 +128,8 @@ int PMS5003::convertPm25ToUsAqi(int pm25) { return pms.pm25ToAQI(pm25); }
* @param humidity Humidity value * @param humidity Humidity value
* @return float * @return float
*/ */
int PMS5003::pm25Compensated(int pm25, float humidity) { int PMS5003::compensated(int pm25, float humidity) {
return pms.pm25Compensated(pm25, humidity); return pms.compensated(pm25, humidity);
} }
/** /**

View File

@ -24,7 +24,7 @@ public:
int getPm10Ae(void); int getPm10Ae(void);
int getPm03ParticleCount(void); int getPm03ParticleCount(void);
int convertPm25ToUsAqi(int pm25); int convertPm25ToUsAqi(int pm25);
int pm25Compensated(int pm25, float humidity); int compensated(int pm25, float humidity);
private: private:
bool _isBegin = false; bool _isBegin = false;

View File

@ -171,8 +171,8 @@ float PMS5003T::getRelativeHumidity(void) {
* @param humidity Humidity value * @param humidity Humidity value
* @return float * @return float
*/ */
float PMS5003T::pm25Compensated(int pm25, float humidity) { float PMS5003T::compensated(int pm25, float humidity) {
return pms.pm25Compensated(pm25, humidity); return pms.compensated(pm25, humidity);
} }
/** /**

View File

@ -29,7 +29,7 @@ public:
int convertPm25ToUsAqi(int pm25); int convertPm25ToUsAqi(int pm25);
float getTemperature(void); float getTemperature(void);
float getRelativeHumidity(void); float getRelativeHumidity(void);
float pm25Compensated(int pm25, float humidity); float compensated(int pm25, float humidity);
private: private:
bool _isBegin = false; bool _isBegin = false;