mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-06-30 02:00:58 +02:00
Ignore parameter values out of range #190
This commit is contained in:
49
src/Main/utils.cpp
Normal file
49
src/Main/utils.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
#include "utils.h"
|
||||
|
||||
utils::utils(/* args */)
|
||||
{
|
||||
}
|
||||
|
||||
utils::~utils()
|
||||
{
|
||||
}
|
||||
|
||||
float utils::correctTemperature(float value) {
|
||||
if (value < -40) {
|
||||
return -40;
|
||||
}
|
||||
if (value > 100) {
|
||||
return 125;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
float utils::correctHumidity(float value) {
|
||||
if (value < 0) {
|
||||
return 0;
|
||||
}
|
||||
if (value > 100) {
|
||||
return 100;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
int16_t utils::correctCO2(int16_t value) {
|
||||
if (value < 0) {
|
||||
return 0;
|
||||
}
|
||||
if (value > 10000) {
|
||||
return 10000;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
int utils::correctPMS(int value) {
|
||||
if (value < 10) {
|
||||
return 10;
|
||||
}
|
||||
if (value > 1000) {
|
||||
return 1000;
|
||||
}
|
||||
return value;
|
||||
}
|
Reference in New Issue
Block a user