rename isValidPMS to isValidPm

This commit is contained in:
Phat Nguyen
2024-08-30 19:07:31 +07:00
parent c45901706f
commit 753f22923c
8 changed files with 55 additions and 55 deletions

View File

@ -311,7 +311,7 @@ void OledDisplay::showDashboard(const char *status) {
}
DISP()->setFont(u8g2_font_t0_22b_tf);
if (config.isPmStandardInUSAQI()) {
if (utils::isValidPMS(pm25)) {
if (utils::isValidPm(pm25)) {
sprintf(strBuf, "%d", ag->pms5003.convertPm25ToUsAqi(pm25));
} else {
sprintf(strBuf, "%s", "-");
@ -320,7 +320,7 @@ void OledDisplay::showDashboard(const char *status) {
DISP()->setFont(u8g2_font_t0_12_tf);
DISP()->drawUTF8(55, 61, "AQI");
} else {
if (utils::isValidPMS(pm25)) {
if (utils::isValidPm(pm25)) {
sprintf(strBuf, "%d", pm25);
} else {
sprintf(strBuf, "%s", "-");
@ -370,7 +370,7 @@ void OledDisplay::showDashboard(const char *status) {
pm25 = (int)ag->pms5003.compensate(pm25, value.Humidity);
}
ag->display.setCursor(0, 12);
if (utils::isValidPMS(pm25)) {
if (utils::isValidPm(pm25)) {
snprintf(strBuf, sizeof(strBuf), "PM2.5:%d", pm25);
} else {
snprintf(strBuf, sizeof(strBuf), "PM2.5:-");

View File

@ -54,16 +54,16 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
if (ag->isOne() || (ag->isPro4_2()) || ag->isPro3_3() || ag->isBasic()) {
if (config->hasSensorPMS1) {
if (utils::isValidPMS(this->pm01_1)) {
if (utils::isValidPm(this->pm01_1)) {
root["pm01"] = this->pm01_1;
}
if (utils::isValidPMS(this->pm25_1)) {
if (utils::isValidPm(this->pm25_1)) {
root["pm02"] = this->pm25_1;
}
if (utils::isValidPMS(this->pm10_1)) {
if (utils::isValidPm(this->pm10_1)) {
root["pm10"] = this->pm10_1;
}
if (utils::isValidPMS03Count(this->pm03PCount_1)) {
if (utils::isValidPm03Count(this->pm03PCount_1)) {
root["pm003Count"] = this->pm03PCount_1;
}
if (!localServer) {
@ -97,16 +97,16 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
} else {
if (config->hasSensorPMS1 && config->hasSensorPMS2) {
if (utils::isValidPMS(this->pm01_1) && utils::isValidPMS(this->pm01_2)) {
if (utils::isValidPm(this->pm01_1) && utils::isValidPm(this->pm01_2)) {
root["pm01"] = ag->round2((this->pm01_1 + this->pm01_2) / 2.0f);
}
if (utils::isValidPMS(this->pm25_1) && utils::isValidPMS(this->pm25_2)) {
if (utils::isValidPm(this->pm25_1) && utils::isValidPm(this->pm25_2)) {
root["pm02"] = ag->round2((this->pm25_1 + this->pm25_2) / 2.0f);
}
if (utils::isValidPMS(this->pm10_1) && utils::isValidPMS(this->pm10_2)) {
if (utils::isValidPm(this->pm10_1) && utils::isValidPm(this->pm10_2)) {
root["pm10"] = ag->round2((this->pm10_1 + this->pm10_2) / 2.0f);
}
if (utils::isValidPMS(this->pm03PCount_1) && utils::isValidPMS(this->pm03PCount_2)) {
if (utils::isValidPm(this->pm03PCount_1) && utils::isValidPm(this->pm03PCount_2)) {
root["pm003Count"] = ag->round2((this->pm03PCount_1 + this->pm03PCount_2) / 2.0f);
}
@ -139,16 +139,16 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
if (fwMode == FW_MODE_O_1PS || fwMode == FW_MODE_O_1PST) {
float val;
if (config->hasSensorPMS1) {
if (utils::isValidPMS(this->pm01_1)) {
if (utils::isValidPm(this->pm01_1)) {
root["pm01"] = this->pm01_1;
}
if (utils::isValidPMS(this->pm25_1)) {
if (utils::isValidPm(this->pm25_1)) {
root["pm02"] = this->pm25_1;
}
if (utils::isValidPMS(this->pm10_1)) {
if (utils::isValidPm(this->pm10_1)) {
root["pm10"] = this->pm10_1;
}
if (utils::isValidPMS03Count(this->pm03PCount_1)) {
if (utils::isValidPm03Count(this->pm03PCount_1)) {
root["pm003Count"] = this->pm03PCount_1;
}
if (utils::isValidTemperature(this->temp_1)) {
@ -178,16 +178,16 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
}
}
if (config->hasSensorPMS2) {
if(utils::isValidPMS(this->pm01_2)) {
if(utils::isValidPm(this->pm01_2)) {
root["pm01"] = this->pm01_2;
}
if(utils::isValidPMS(this->pm25_2)) {
if(utils::isValidPm(this->pm25_2)) {
root["pm02"] = this->pm25_2;
}
if(utils::isValidPMS(this->pm10_2)) {
if(utils::isValidPm(this->pm10_2)) {
root["pm10"] = this->pm10_2;
}
if(utils::isValidPMS03Count(this->pm03PCount_2)) {
if(utils::isValidPm03Count(this->pm03PCount_2)) {
root["pm003Count"] = this->pm03PCount_2;
}
@ -222,16 +222,16 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
if (fwMode == FW_MODE_O_1P) {
float val;
if (config->hasSensorPMS1) {
if (utils::isValidPMS(this->pm01_1)) {
if (utils::isValidPm(this->pm01_1)) {
root["pm01"] = this->pm01_1;
}
if (utils::isValidPMS(this->pm25_1)) {
if (utils::isValidPm(this->pm25_1)) {
root["pm02"] = this->pm25_1;
}
if (utils::isValidPMS(this->pm10_1)) {
if (utils::isValidPm(this->pm10_1)) {
root["pm10"] = this->pm10_1;
}
if (utils::isValidPMS03Count(this->pm03PCount_1)) {
if (utils::isValidPm03Count(this->pm03PCount_1)) {
root["pm003Count"] = this->pm03PCount_1;
}
if (utils::isValidTemperature(this->temp_1)) {
@ -259,16 +259,16 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
pms5003TFirmwareVersion(ag->pms5003t_1.getFirmwareVersion());
}
} else if (config->hasSensorPMS2) {
if(utils::isValidPMS(this->pm01_2)) {
if(utils::isValidPm(this->pm01_2)) {
root["pm01"] = this->pm01_2;
}
if(utils::isValidPMS(this->pm25_2)) {
if(utils::isValidPm(this->pm25_2)) {
root["pm02"] = this->pm25_2;
}
if(utils::isValidPMS(this->pm10_2)) {
if(utils::isValidPm(this->pm10_2)) {
root["pm10"] = this->pm10_2;
}
if(utils::isValidPMS03Count(this->pm03PCount_2)) {
if(utils::isValidPm03Count(this->pm03PCount_2)) {
root["pm003Count"] = this->pm03PCount_2;
}
if (utils::isValidTemperature(this->temp_2)) {
@ -300,16 +300,16 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
} else {
float val;
if (config->hasSensorPMS1) {
if(utils::isValidPMS(this->pm01_1)) {
if(utils::isValidPm(this->pm01_1)) {
root["channels"]["1"]["pm01"] = this->pm01_1;
}
if(utils::isValidPMS(this->pm25_1)) {
if(utils::isValidPm(this->pm25_1)) {
root["channels"]["1"]["pm02"] = this->pm25_1;
}
if(utils::isValidPMS(this->pm10_1)) {
if(utils::isValidPm(this->pm10_1)) {
root["channels"]["1"]["pm10"] = this->pm10_1;
}
if (utils::isValidPMS03Count(this->pm03PCount_1)) {
if (utils::isValidPm03Count(this->pm03PCount_1)) {
root["channels"]["1"]["pm003Count"] = this->pm03PCount_1;
}
if(utils::isValidTemperature(this->temp_1)) {
@ -342,16 +342,16 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
}
if (config->hasSensorPMS2) {
float val;
if (utils::isValidPMS(this->pm01_2)) {
if (utils::isValidPm(this->pm01_2)) {
root["channels"]["2"]["pm01"] = this->pm01_2;
}
if (utils::isValidPMS(this->pm25_2)) {
if (utils::isValidPm(this->pm25_2)) {
root["channels"]["2"]["pm02"] = this->pm25_2;
}
if (utils::isValidPMS(this->pm10_2)) {
if (utils::isValidPm(this->pm10_2)) {
root["channels"]["2"]["pm10"] = this->pm10_2;
}
if (utils::isValidPMS03Count(this->pm03PCount_2)) {
if (utils::isValidPm03Count(this->pm03PCount_2)) {
root["channels"]["2"]["pm003Count"] = this->pm03PCount_2;
}
if (utils::isValidTemperature(this->temp_2)) {

View File

@ -48,14 +48,14 @@ bool utils::isValidCO2(int16_t value) {
return false;
}
bool utils::isValidPMS(int value) {
bool utils::isValidPm(int value) {
if ((value >= VALID_PMS_MIN) && (value <= VALID_PMS_MAX)) {
return true;
}
return false;
}
bool utils::isValidPMS03Count(int value) {
bool utils::isValidPm03Count(int value) {
if (value >= VALID_PMS03COUNT_MIN) {
return true;
}

View File

@ -14,8 +14,8 @@ public:
static bool isValidTemperature(float value);
static bool isValidHumidity(float value);
static bool isValidCO2(int16_t value);
static bool isValidPMS(int value);
static bool isValidPMS03Count(int value);
static bool isValidPm(int value);
static bool isValidPm03Count(int value);
static bool isValidNOx(int value);
static bool isValidVOC(int value);
static float getInvalidTemperature(void);