mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-30 00:47:17 +02:00
Fix invalidate value check for getAverage
This commit is contained in:
@ -406,12 +406,12 @@ float Measurements::getAverage(MeasurementType type, int ch) {
|
|||||||
// Sanity check to validate channel, assert if invalid
|
// Sanity check to validate channel, assert if invalid
|
||||||
validateChannel(ch);
|
validateChannel(ch);
|
||||||
|
|
||||||
|
bool undefined = false;
|
||||||
|
|
||||||
// Follow array indexing just for get address of the value type
|
// Follow array indexing just for get address of the value type
|
||||||
ch = ch - 1;
|
ch = ch - 1;
|
||||||
|
|
||||||
// Define data point source. Data type doesn't matter because only to get the average value
|
// Define data point source. Data type doesn't matter because only to get the average value
|
||||||
FloatValue *temporary = nullptr;
|
|
||||||
Update update;
|
|
||||||
float measurementAverage;
|
float measurementAverage;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case CO2:
|
case CO2:
|
||||||
@ -434,12 +434,12 @@ float Measurements::getAverage(MeasurementType type, int ch) {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Invalidate, measurements type not handled
|
// Invalidate, measurements type not handled
|
||||||
measurementAverage = -1000;
|
undefined = true;
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Sanity check if measurement type is not defined
|
// Sanity check if measurement type is not defined
|
||||||
if (measurementAverage == -1000) {
|
if (undefined) {
|
||||||
Serial.printf("ERROR! %s is not defined on get average value function\n", measurementTypeStr(type).c_str());
|
Serial.printf("ERROR! %s is not defined on get average value function\n", measurementTypeStr(type).c_str());
|
||||||
delay(1000);
|
delay(1000);
|
||||||
assert(0);
|
assert(0);
|
||||||
|
Reference in New Issue
Block a user