forked from airgradienthq/arduino
New function to set max update before averaging
Rename enum member
This commit is contained in:
@ -5,7 +5,43 @@
|
|||||||
|
|
||||||
#define json_prop_pmFirmware "firmware"
|
#define json_prop_pmFirmware "firmware"
|
||||||
|
|
||||||
void Measurements::init() {}
|
void Measurements::maxUpdate(AgValueType type, int max) {
|
||||||
|
switch (type) {
|
||||||
|
case AgValueType::Temperature:
|
||||||
|
_temperature.update.max = max;
|
||||||
|
break;
|
||||||
|
case AgValueType::Humidity:
|
||||||
|
_humidity.update.max = max;
|
||||||
|
break;
|
||||||
|
case AgValueType::CO2:
|
||||||
|
_co2.update.max = max;
|
||||||
|
break;
|
||||||
|
case AgValueType::TVOC:
|
||||||
|
_tvoc.update.max = max;
|
||||||
|
break;
|
||||||
|
case AgValueType::TVOCRaw:
|
||||||
|
_tvoc_raw.update.max = max;
|
||||||
|
break;
|
||||||
|
case AgValueType::NOx:
|
||||||
|
_nox.update.max = max;
|
||||||
|
break;
|
||||||
|
case AgValueType::NOxRaw:
|
||||||
|
_nox_raw.update.max = max;
|
||||||
|
break;
|
||||||
|
case AgValueType::PM25:
|
||||||
|
_pm_25.update.max = max;
|
||||||
|
break;
|
||||||
|
case AgValueType::PM01:
|
||||||
|
_pm_01.update.max = max;
|
||||||
|
break;
|
||||||
|
case AgValueType::PM10:
|
||||||
|
_pm_10.update.max = max;
|
||||||
|
break;
|
||||||
|
case AgValueType::PM03_PC:
|
||||||
|
_pm_03_pc.update.max = max;
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
bool Measurements::updateValue(AgValueType type, int val) {
|
bool Measurements::updateValue(AgValueType type, int val) {
|
||||||
// Define data point source
|
// Define data point source
|
||||||
@ -44,7 +80,7 @@ bool Measurements::updateValue(AgValueType type, int val) {
|
|||||||
temporary = &_pm_10;
|
temporary = &_pm_10;
|
||||||
invalidValue = utils::getInvalidPmValue();
|
invalidValue = utils::getInvalidPmValue();
|
||||||
break;
|
break;
|
||||||
case AgValueType::PM03:
|
case AgValueType::PM03_PC:
|
||||||
temporary = &_pm_03_pc;
|
temporary = &_pm_03_pc;
|
||||||
invalidValue = utils::getInvalidPmValue();
|
invalidValue = utils::getInvalidPmValue();
|
||||||
break;
|
break;
|
||||||
@ -568,7 +604,7 @@ String Measurements::agValueTypeStr(AgValueType type) {
|
|||||||
case AgValueType::PM10:
|
case AgValueType::PM10:
|
||||||
str = "PM10";
|
str = "PM10";
|
||||||
break;
|
break;
|
||||||
case AgValueType::PM03:
|
case AgValueType::PM03_PC:
|
||||||
str = "PM03";
|
str = "PM03";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -11,7 +11,7 @@ private:
|
|||||||
struct Update {
|
struct Update {
|
||||||
int counter; // How many update attempts done
|
int counter; // How many update attempts done
|
||||||
int success; // How many update value that actually give valid value
|
int success; // How many update value that actually give valid value
|
||||||
int max; // Maximum update before calculating average
|
int max; // Maximum update counter before calculating average
|
||||||
};
|
};
|
||||||
|
|
||||||
// Reading type for sensor value that outputs float
|
// Reading type for sensor value that outputs float
|
||||||
@ -68,15 +68,21 @@ public:
|
|||||||
PM25,
|
PM25,
|
||||||
PM01,
|
PM01,
|
||||||
PM10,
|
PM10,
|
||||||
PM03,
|
PM03_PC,
|
||||||
};
|
};
|
||||||
|
|
||||||
void init();
|
/**
|
||||||
|
* @brief Set each AgValueType maximum update for a value type before calculate the average
|
||||||
|
*
|
||||||
|
* @param type the target value type to set
|
||||||
|
* @param max the maximum counter
|
||||||
|
*/
|
||||||
|
void maxUpdate(AgValueType type, int max);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief update target type value with new value.
|
* @brief update target type value with new value.
|
||||||
* Each AgValueType has last raw value and last average that are calculated based on max number of
|
* Each AgValueType has last raw value and last average that are calculated based on max number of
|
||||||
* set This function is for AgValueType that use INT as the data type
|
* update. This function is for AgValueType that use INT as the data type
|
||||||
*
|
*
|
||||||
* @param type (AgValueType) value type that will be updated
|
* @param type (AgValueType) value type that will be updated
|
||||||
* @param val (int) the new value
|
* @param val (int) the new value
|
||||||
@ -88,7 +94,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief update target type value with new value.
|
* @brief update target type value with new value.
|
||||||
* Each AgValueType has last raw value and last average that are calculated based on max number of
|
* Each AgValueType has last raw value and last average that are calculated based on max number of
|
||||||
* set This function is for AgValueType that use FLOAT as the data type
|
* update. This function is for AgValueType that use FLOAT as the data type
|
||||||
*
|
*
|
||||||
* @param type (AgValueType) value type that will be updated
|
* @param type (AgValueType) value type that will be updated
|
||||||
* @param val (float) the new value
|
* @param val (float) the new value
|
||||||
|
Reference in New Issue
Block a user