Skip to content

Commit

Permalink
fixes issue marcelbuesing#42
Browse files Browse the repository at this point in the history
  • Loading branch information
fenax committed Feb 2, 2022
1 parent a4b407d commit 76cfaa8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ const BME680_GAS_INDEX_MSK: u8 = 0x0f;
const BME680_GAS_RANGE_MSK: u8 = 0x0f;
const BME680_GASM_VALID_MSK: u8 = 0x20;
const BME680_HEAT_STAB_MSK: u8 = 0x10;
const BME680_MEASURING_MSK: u8 = 0x20;

/// Buffer length macro declaration
const BME680_TMP_BUFFER_LENGTH: usize = 40;
Expand Down Expand Up @@ -506,6 +507,10 @@ where

for (reg_addr, reg_data) in reg {
let tmp_buff: [u8; 2] = [*reg_addr, *reg_data];
while self.is_measuring()? {

}

debug!(
"Setting register reg: {:?} tmp_buf: {:?}",
reg_addr, tmp_buff
Expand Down Expand Up @@ -936,6 +941,17 @@ where
Ok(gas_sett)
}

fn is_measuring(&mut self)->Result<bool, <I2C as Read>::Error, <I2C as Write>::Error>{
let val :u8 = 0;
I2CUtil::read_bytes(
&mut self.i2c,
self.dev_id.addr(),
BME680_FIELD0_ADDR,
&mut [val],
)?;
Ok(val & BME680_MEASURING_MSK != 0)
}

/// Retrieve the current sensor informations
pub fn get_sensor_data(
&mut self,
Expand Down

0 comments on commit 76cfaa8

Please sign in to comment.