Platform-agnostic Rust driver for the APDS9960 digital proximity, ambient light, RGB and gesture sensor.
APACHE-2.0 License
This is a platform agnostic Rust driver for the APDS9960 digital proximity, ambient light, RGB
and gesture sensor using the embedded-hal
traits.
This driver allows you to:
enable()
.enable_wait()
.enable_wait_long()
.set_wait_time()
.force_interrupt()
.clear_interrupts()
.read_device_id()
.enable_proximity()
.enable_proximity_interrupts()
.enable_proximity_saturation_interrupts()
.read_proximity()
.is_proximity_data_valid()
.set_proximity_low_threshold()
.set_proximity_offsets()
.clear_proximity_interrupt()
.enable_light()
.enable_light_interrupts()
.enable_light_saturation_interrupts()
.is_light_data_valid()
.read_light()
.set_light_integration_time()
.set_light_low_threshold()
.clear_light_interrupt()
.enable_gesture()
.enable_gesture_mode()
.enable_gesture_interrupts()
.is_gesture_data_valid()
.read_gesture_data_level()
.set_gesture_data_level_threshold()
.has_gesture_data_overflown()
.read_gesture_data()
.set_gesture_proximity_entry_threshold()
.set_gesture_offsets()
.The APDS-9960 device features advanced gesture detection, proximity detection, digital ambient light sense (ALS) and color sense (RGBC).
The communication is done through an I2C bidirectional bus.
Datasheet:
Please find additional examples using hardware in this repository: driver-examples
extern crate embedded_hal;
extern crate linux_embedded_hal;
#[macro_use]
extern crate nb;
extern crate apds9960;
use apds9960::Apds9960;
use linux_embedded_hal::I2cdev;
fn main() {
let dev = I2cdev::new("/dev/i2c-1").unwrap();
let mut sensor = Apds9960::new(dev);
sensor.enable().unwrap();
sensor.enable_proximity().unwrap();
loop {
let p = block!(sensor.read_proximity()).unwrap();
println!("Proximity: {}", p);
}
}
For questions, issues, feature requests, and other changes, please file an issue in the github project.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.