Crates.io | tcs3400 |
lib.rs | tcs3400 |
version | 0.1.0 |
source | src |
created_at | 2022-11-16 21:32:26.739974 |
updated_at | 2022-11-16 21:32:26.739974 |
description | Platform-agnostic Rust driver for the TCS3400 RGB color light to digital converter with IR filter. |
homepage | https://github.com/andresv/tcs3400-rs |
repository | https://github.com/andresv/tcs3400-rs |
max_upload_size | |
id | 716722 |
size | 42,902 |
This is a platform agnostic Rust driver for the TCS3400 RGB color light to
digital converter with IR filter, based on the embedded-hal
traits.
This driver allows you to:
The TCS3400 device provides a digital return of red, green, blue (RGB), and clear light sensing values. An IR blocking filter, integrated on-chip and localized to the color sensing photodiodes, minimizes the IR spectral component of the incoming light and allows color measurements to be made accurately. The high sensitivity, wide dynamic range, and IR blocking filter make the TCS3400 an ideal color sensor solution for use under varying lighting conditions and through attenuating materials.
The TCS3400 color sensor has a wide range of applications including RGB LED backlight control, solid-state lighting, health/fitness products, industrial process controls and medical diagnostic equipment. In addition, the IR blocking filter enables the TCS3400 to perform ambient light sensing (ALS). Ambient light sensing is widely used in display-based products such as cell phones, notebooks, and TVs to sense the lighting environment and enable automatic display brightness for optimal viewing and power savings. The TCS3400, itself, can enter a lower-power wait state between light sensing measurements to further reduce the average power consumption.
Datasheet:
This driver is compatible with the devices TCS34005 and TCS34007.
To use this driver, import this crate and an embedded_hal
implementation,
then instantiate the device.
use linux_embedded_hal::I2cdev;
use tcs3400::Tcs3400;
fn main() {
let dev = I2cdev::new("/dev/i2c-1").unwrap();
let mut sensor = Tcs3400::new(dev);
sensor.enable().unwrap();
sensor.enable_rgbc().unwrap();
while !sensor.is_rgbc_status_valid().unwrap() {
// wait for measurement to be available
}
let m = sensor.read_all_channels().unwrap();
println!(
"Measurements: clear = {}, red = {}, green = {}, blue = {}",
m.clear, m.red, m.green, m.blue
);
}
This crate is guaranteed to compile on stable Rust 1.31.0 and up. It might compile with older versions but that may change in any new patch release.
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.