Ignore parameter values out of range #190

This commit is contained in:
Phat Nguyen
2024-07-11 06:25:31 +07:00
parent e58ce1cbea
commit df6cca3714
6 changed files with 95 additions and 13 deletions

View File

@ -1,5 +1,6 @@
#include "PMS5003.h"
#include "Arduino.h"
#include "../Main/utils.h"
#if defined(ESP8266)
#include <SoftwareSerial.h>
@ -87,28 +88,30 @@ bool PMS5003::begin(void) {
*
* @return int PM1.0 index
*/
int PMS5003::getPm01Ae(void) { return pms.getPM0_1(); }
int PMS5003::getPm01Ae(void) { return utils::correctPMS(pms.getPM0_1()); }
/**
* @brief Read PM2.5 must call this function after @ref readData success
*
* @return int PM2.5 index
*/
int PMS5003::getPm25Ae(void) { return pms.getPM2_5(); }
int PMS5003::getPm25Ae(void) { return utils::correctPMS(pms.getPM2_5()); }
/**
* @brief Read PM10.0 must call this function after @ref readData success
*
* @return int PM10.0 index
*/
int PMS5003::getPm10Ae(void) { return pms.getPM10(); }
int PMS5003::getPm10Ae(void) { return utils::correctPMS(pms.getPM10()); }
/**
* @brief Read PM0.3 must call this function after @ref readData success
*
* @return int PM0.3 index
*/
int PMS5003::getPm03ParticleCount(void) { return pms.getCount0_3(); }
int PMS5003::getPm03ParticleCount(void) {
return utils::correctPMS(pms.getCount0_3());
}
/**
* @brief Convert PM2.5 to US AQI

View File

@ -1,5 +1,6 @@
#include "PMS5003T.h"
#include "Arduino.h"
#include "../Main/utils.h"
#if defined(ESP8266)
#include <SoftwareSerial.h>
@ -112,28 +113,30 @@ bool PMS5003T::begin(void) {
*
* @return int PM1.0 index
*/
int PMS5003T::getPm01Ae(void) { return pms.getPM0_1(); }
int PMS5003T::getPm01Ae(void) { return utils::correctPMS(pms.getPM0_1()); }
/**
* @brief Read PM2.5 must call this function after @ref readData success
*
* @return int PM2.5 index
*/
int PMS5003T::getPm25Ae(void) { return pms.getPM2_5(); }
int PMS5003T::getPm25Ae(void) { return utils::correctPMS(pms.getPM2_5()); }
/**
* @brief Read PM10.0 must call this function after @ref readData success
*
* @return int PM10.0 index
*/
int PMS5003T::getPm10Ae(void) { return pms.getPM10(); }
int PMS5003T::getPm10Ae(void) { return utils::correctPMS(pms.getPM10()); }
/**
* @brief Read PM 0.3 Count must call this function after @ref readData success
*
* @return int PM 0.3 Count index
*/
int PMS5003T::getPm03ParticleCount(void) { return pms.getCount0_3(); }
int PMS5003T::getPm03ParticleCount(void) {
return utils::correctPMS(pms.getCount0_3());
}
/**
* @brief Convert PM2.5 to US AQI
@ -149,7 +152,7 @@ int PMS5003T::convertPm25ToUsAqi(int pm25) { return pms.pm25ToAQI(pm25); }
* @return float Degree Celcius
*/
float PMS5003T::getTemperature(void) {
return pms.getTemp()/10.0f;
return utils::correctTemperature(pms.getTemp() / 10.0f);
}
/**
@ -158,7 +161,7 @@ float PMS5003T::getTemperature(void) {
* @return float Percent (%)
*/
float PMS5003T::getRelativeHumidity(void) {
return pms.getHum()/10.0f;
return utils::correctHumidity(pms.getHum() / 10.0f);
}
/**