Skip to main content

mics_6814/
error.rs

1/// Errors that can occur when using the MiCS-6814 driver.
2#[derive(Debug, Clone, Copy, PartialEq)]
3#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
4pub enum Error {
5    /// The Rs/R0 ratio is out of the valid range for the requested gas.
6    OutOfRange,
7    /// The ADC voltage is invalid (negative, or exceeds Vcc).
8    InvalidVoltage,
9    /// The load resistance is zero or negative.
10    InvalidLoadResistance,
11}
12
13impl core::fmt::Display for Error {
14    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
15        match self {
16            Error::OutOfRange => write!(f, "Rs/R0 ratio out of sensor range"),
17            Error::InvalidVoltage => write!(f, "ADC voltage invalid"),
18            Error::InvalidLoadResistance => write!(f, "load resistance must be positive"),
19        }
20    }
21}