VersBinarii / bme280-rs

A platform agnostic Rust driver for the Bosch BM[PE]-280
Other
59 stars 73 forks source link

Borrow delay mutably #12

Closed David-OConnor closed 2 years ago

David-OConnor commented 3 years ago

Don't own delay; otherwise this crate causes compatibility issues, since delay is a popular thing to do.

arrowcircle commented 3 years ago

Could you please show an example of new usage?

dtantsur commented 3 years ago

@uber-foo any opinion on this PR?

sciguy16 commented 3 years ago

@arrowcircle here's an example of the new usage on an STM32F103:

let cp = cortex_m::Peripherals::take().unwrap();
let mut delay = Delay::new(cp.SYST, clocks);
let i2c = stm32f1xx_hal::i2c::BlockingI2c::i2c1( ... );
let mut bme280 = BME280::new_primary(i2c);
bme280.init(&mut delay).unwrap();
let measurements = bme280.measure(&mut delay).unwrap();

I've tested it on an STM32 and it's working well.

arrowcircle commented 3 years ago

@arrowcircle here's an example of the new usage on an STM32F103:

let cp = cortex_m::Peripherals::take().unwrap();
let mut delay = Delay::new(cp.SYST, clocks);
let i2c = stm32f1xx_hal::i2c::BlockingI2c::i2c1( ... );
let mut bme280 = BME280::new_primary(i2c);
bme280.init(&mut delay).unwrap();
let measurements = bme280.measure(&mut delay).unwrap();

I've tested it on an STM32 and it's working well.

@sciguy16 Hey! Thanks for the answer. Does it work with the rtic?

sciguy16 commented 3 years ago

I haven't tried it with rtic, but as long as it's got something that provides a DelayMs then it should work the same as before.