6 releases
0.3.0 | May 20, 2021 |
---|---|
0.2.0 | Dec 22, 2019 |
0.1.3 | Dec 4, 2019 |
0.1.2 | Oct 21, 2019 |
#2030 in Embedded development
27 downloads per month
33KB
636 lines
gyuvl53l0x
no_std driver for VL53L0X (Time-of-Flight I2C laser-ranging module)
Basic usage
Include this library as a dependency in your Cargo.toml
:
[dependencies.gyuvl53l0x]
version = "<version>"
Use embedded-hal implementation to get I2C handle and then create vl53l0x handle.
Single read:
extern crate gyuvl53l0x;
match gyuvl53l0x::VL53L0X::default(i2c) {
Ok(mut u) => {
// set a new device address
u.set_device_address(0x39).unwrap();
// set the measurement timing budget in microseconds
u.set_measurement_timing_budget(20_000).unwrap();
loop {
match u.read_range_single_millimeters_blocking() {
Ok(val) => {
println!("{:#?}", val).unwrap();
}
_ => {
println!("Not ready").unwrap();
}
}
}
}
Err(gyuvl53l0x::VL53L0X::Error::BusError(error)) => {
println!("{:#?}", error).unwrap();
panic!();
}
_ => {
panic!();
}
};
Continuos read:
extern crate gyuvl53l0x;
match gyuvl53l0x::VL53L0X::default(i2c) {
Ok(mut u) => {
u.start_continuous(20_000).unwrap();
loop {
match u.read_range_continuous_millimeters_blocking() {
Ok(val) => {
println!("{:#?}", val).unwrap();
}
_ => {
println!("Not ready").unwrap();
}
}
}
}
Err(gyuvl53l0x::VL53L0X::Error::BusError(error)) => {
println!("{:#?}", error).unwrap();
panic!();
}
_ => {
panic!();
}
};
License
Dependencies
~350KB