Crates.io | apds9960 |
lib.rs | apds9960 |
version | 0.1.0 |
source | src |
created_at | 2018-12-21 18:43:33.480308 |
updated_at | 2018-12-21 18:43:33.480308 |
description | Platform-agnostic Rust driver for the APDS9960 digital proximity, ambient light, RGB and gesture sensor. |
homepage | https://github.com/eldruin/apds9960-rs |
repository | https://github.com/eldruin/apds9960-rs |
max_upload_size | |
id | 103176 |
size | 67,768 |
This is a platform agnostic Rust driver for the APDS9960 digital proximity, ambient light, RGB
and gesture sensor, based on 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 in this repository: apds9960-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);
}
}
Licensed under either of
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.