21 if (!std::isfinite(voltage) || !std::isfinite(vcc) || voltage <= 0.0f || voltage > vcc)
31 if (!std::isfinite(min_value) || !std::isfinite(max_value) || !std::isfinite(mean) || mean <= 0.0f)
38 if (!std::isfinite(
x) ||
x < 0.0f || !std::isfinite(x_air) || x_air <= 0.0f)
46 if (!std::isfinite(ratio))
bool calibration_is_stable(float min_value, float max_value, float mean)
True when the clean-air samples spread at most MAX_CALIBRATION_SPREAD of their mean.
constexpr float MAX_CALIBRATION_SPREAD
Largest relative spread (max - min) / mean a clean-air calibration accepts.
float air_value_from_voltage(float voltage, float vcc)
x = VCC - V_ao: 0 at VCC (a saturated sensor, never clean air).
float ratio_from_air_value(float x, float x_air)
ratio = x / x_air (NaN when either value is unusable).
float ppm_from_vendor_curve(float ratio, const VendorCurve &curve)
ratio -> ppm as DFRobot_MICS getGasData(): 0 above the threshold or below the vendor range,...
Per-gas constants of the vendor model.
float max_ppm
upper end of the measuring range
float gain
ppm per unit ratio
float threshold
ratio at or below which the gas counts as detected
float min_ppm
the vendor reports 0 ppm below this