Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes issue #42 #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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