airgradienthq / arduino

Other
207 stars 110 forks source link

Ignore parameter values out of range #197

Closed pnt325 closed 2 months ago

pnt325 commented 2 months ago

Correct sensor value has out of range #190

pnt325 commented 2 months ago

A few things: Only negative PM values (below 0) need to be ignored. 0..10 are valid readings and should be allowed.

Also, if a value is outside the range, the value should be completely ignored.

So for example Temperature -100 should NOT return -40 but be ignored. This would apply to all checks.

For this way we don't need to correct value in range, just need to verify it's valid or not before use(show on display or sync to cloud).

The correction method will be remove and replace check valid valid method.

bool utils::validTemperature(float value) {
  if (value >= VALID_TEMPERATURE_MIN && value <= VALID_TEMPERATURE_MAX) {
    return true;
  }
  return false;
}

@airgradienthq How do you think?

airgradienthq commented 2 months ago

@pnt325 yes I think that's how it should work.