VersBinarii / bme280-rs

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

Update to embedded-hal 1.0.0-alpha.8 and add optional support for embedded-hal-async #23

Closed quentinmit closed 1 year ago

quentinmit commented 1 year ago

Note that the example won't compile until https://github.com/stm32-rs/stm32f4xx-hal/pull/510 is merged, since they use stm32f4xx-hal and it's currently on 1.0.0-alpha.7 (not that it seemingly compiles out of the box, anyway). Not sure what to do before that's merged (block merging this, I guess?).

VersBinarii commented 1 year ago

Thank you for this. I think i will wait for the next release of the stm32f4xx-hal before merging this. Could you please provide an example for the async code usage?

quentinmit commented 1 year ago

Thank you for this. I think i will wait for the next release of the stm32f4xx-hal before merging this. Could you please provide an example for the async code usage?

Hm, stm32f4xx-hal doesn't implement the embedded-hal-async traits yet. What HAL should I write an example against? The most popular async HAL for stm32 would be embassy-stm32, but that's still fairly unstable (and would require a pinned crate patch). Or would you prefer an example that doesn't actually compile? (Other than adding some .await calls, the async code would be identical, anyway.)

VersBinarii commented 1 year ago

Yes, exactly, async with embedded is quite new. TBH the only embedded async executor i'm aware of is embassy but i know nothing more about it beyond that. So i guess i was asking in this convoluted way if you could whip out some quick example of how to use the async stuff with whatever is currently out there. I was just wondering what you would use the async version of this crate for yourself 😀. But dont worry about it if its too much hassle 😉

quentinmit commented 1 year ago

Yes, exactly, async with embedded is quite new. TBH the only embedded async executor i'm aware of is embassy but i know nothing more about it beyond that. So i guess i was asking in this convoluted way if you could whip out some quick example of how to use the async stuff with whatever is currently out there. I was just wondering what you would use the async version of this crate for yourself 😀. But dont worry about it if its too much hassle 😉

If that's all you're looking for you're welcome to look at the code I already wrote using it :)

https://github.com/quentinmit/discobike/blob/main/discobiker/src/actors/barometer.rs

I've been rewriting the code for my bike in Rust... yes, I know it's ridiculous to have 5kloc and counting for some LEDs... :)

VersBinarii commented 1 year ago

Thanks for the link. I have been meaning to try out embassy for some time. Cheers 👍🏻

yes, I know it's ridiculous to have 5kloc and counting for some LEDs... :)

A sure, you gotta do what you gotta do 😉 . I used to pimp my wheels with he "phantom texts" running on the 8bit PIC chips. Tons of fun 😄