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