marcelbuesing / bme680

Pure Rust BME680 implementation
MIT License
28 stars 26 forks source link

Owning the delayer appears problematic #34

Closed huntc closed 3 years ago

huntc commented 3 years ago

Thanks for providing this library.

I'm trying to use the library in the context of an embedded-hal. When initing your library I must provide a delayer:

    let mut delayer = Delay::new(board.SYST);

    let mut dev = Bme680::init(i2c, delayer, I2CAddress::Primary).unwrap();

The problem with the above is that, because your library now owns the delayer, I'm no longer able to use it elsewhere.

Do you have any thoughts on what I might do in this situation?

caemor commented 3 years ago

Best solution would be a PR which adds delay as a function parameter everywhere it is needed similar to what is already happening in soft_reset https://github.com/marcelbuesing/bme680/blob/e10fa1a35ade1771f276357dc7949654b92dfd99/src/lib.rs#L403-L407 and remove delay from the bme680 struct.

caemor commented 3 years ago

I think the following functions would need to be updated:

marcelbuesing commented 3 years ago

Thanks @caemor I think that sounds like a good idea.

huntc commented 3 years ago

Best solution would be a PR which adds delay as a function parameter everywhere it is needed similar to what is already happening in soft_reset

https://github.com/marcelbuesing/bme680/blob/e10fa1a35ade1771f276357dc7949654b92dfd99/src/lib.rs#L403-L407

and remove delay from the bme680 struct.

Sounds like a plan. I think it could be passed as a &mut also, right? I can take a look in several hours from now.

caemor commented 3 years ago

Exactly

huntc commented 3 years ago

The PR is in: https://github.com/marcelbuesing/bme680/pull/35

huntc commented 3 years ago

Thanks again for this library. Is it possible to get a review of my PR?