hmc5883-async

Crates.iohmc5883-async
lib.rshmc5883-async
version0.1.3
sourcesrc
created_at2022-07-21 08:44:12.104114
updated_at2022-07-21 08:44:12.104114
descriptionHMC5883 magnetometer async driver for embedded hal
homepage
repositoryhttps://github.com/Dajamante/hmc5983-async
max_upload_size
id629538
size14,019
Aïssata Maiga (Dajamante)

documentation

README

HMC5883 async driver

A rust embedded-hal driver for the Honeywell HMC5883. Forked from the original work of Todd Stellanova and made async.

HMC5883 only support a single interface (I2C).

Example

You can connect to the HMC5883 through I2C:

    use hmc5883_async::*;
    let mut hmc = HMC5883::new(i2c);

    hmc.init(&mut Delay).await.expect("init failed");

    loop {
        if let Ok(temp) = hmc.get_temperature().await {
            info!("Temperature: {:?}", temp);
        }
        match hmc.get_mag_vector().await {
            Ok(mag) => info!("Magnitude vector: {:?}", mag),
            Err(E) => info!("Printing Error {}", E),
        }

        Timer::after(Duration::from_secs(3)).await;
    }

To run the example:

$ cd examples
$ cargo rb compass
Commit count: 42

cargo fmt