From f531e617d69d232019155edb16086631d96039fe Mon Sep 17 00:00:00 2001 From: Jan Gosmann Date: Thu, 6 May 2021 19:52:46 +0200 Subject: [PATCH] Expose gas_valid and heat_stab The BME680 datasheet recommends to check these values to ensure that a gas reading is valid. To do so, they must be exposed by the library. --- src/lib.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 872760a..358abd9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -334,6 +334,19 @@ impl FieldData { pub fn gas_resistance_ohm(&self) -> u32 { self.gas_resistance } + + /// Whether a real (and not a dummy) gas reading was performed. + pub fn gas_valid(&self) -> bool { + self.status & BME680_GASM_VALID_MSK != 0 + } + + /// Whether the heater target temperature for the gas reading was reached. + /// + /// If this values is `false`, the heating duration was likely too short or + /// the target temperature too high. + pub fn heat_stable(&self) -> bool { + self.status & BME680_HEAT_STAB_MSK != 0 + } } /// Shows if new data is available