gyuvl53l0x

no_std driver for VL53L0X (Time-of-Flight I2C laser-ranging module)

Build Status crates.io Docs

Basic usage

Include this library as a dependency in your Cargo.toml:

rust [dependencies.gyuvl53l0x] version = "<version>"

Use embedded-hal implementation to get I2C handle and then create vl53l0x handle.

Single read:

```rust extern crate gyuvl53l0x;

match gyuvl53l0x::VL53L0X::default(i2c) { Ok(mut u) => { // set a new device address u.setdeviceaddress(0x39).unwrap(); // set the measurement timing budget in microseconds u.setmeasurementtimingbudget(20000).unwrap(); loop { match u.readrangesinglemillimetersblocking() { Ok(val) => { println!("{:#?}", val).unwrap(); } _ => { println!("Not ready").unwrap(); } } } } Err(gyuvl53l0x::VL53L0X::Error::BusError(error)) => { println!("{:#?}", error).unwrap(); panic!(); } _ => { panic!(); } }; ```

Continuos read:

```rust extern crate gyuvl53l0x;

match gyuvl53l0x::VL53L0X::default(i2c) { Ok(mut u) => { u.startcontinuous(20000).unwrap(); loop { match u.readrangecontinuousmillimetersblocking() { Ok(val) => { println!("{:#?}", val).unwrap(); } _ => { println!("Not ready").unwrap(); } } } } Err(gyuvl53l0x::VL53L0X::Error::BusError(error)) => { println!("{:#?}", error).unwrap(); panic!(); } _ => { panic!(); } }; ```

License

MIT license