{"id":16064706,"url":"https://github.com/eldruin/tcs3472-rs","last_synced_at":"2025-07-09T17:09:09.418Z","repository":{"id":57669362,"uuid":"153926736","full_name":"eldruin/tcs3472-rs","owner":"eldruin","description":"Platform-agnostic Rust driver for the TCS3472 RGB color light to digital converter with IR filter","archived":false,"fork":false,"pushed_at":"2025-01-02T11:28:22.000Z","size":69,"stargazers_count":4,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-08T21:27:44.626Z","etag":null,"topics":["color","driver","embedded","embedded-hal","embedded-hal-driver","i2c","no-std","rgb","rust","sensor"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eldruin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-20T16:44:10.000Z","updated_at":"2025-01-02T11:28:25.000Z","dependencies_parsed_at":"2024-10-27T17:21:38.768Z","dependency_job_id":"c4b1d540-536d-4b8f-8d15-d55af413c0ec","html_url":"https://github.com/eldruin/tcs3472-rs","commit_stats":{"total_commits":57,"total_committers":1,"mean_commits":57.0,"dds":0.0,"last_synced_commit":"183a3a5f6c624c649780f66f043455a3dde62c04"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/eldruin/tcs3472-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eldruin%2Ftcs3472-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eldruin%2Ftcs3472-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eldruin%2Ftcs3472-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eldruin%2Ftcs3472-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eldruin","download_url":"https://codeload.github.com/eldruin/tcs3472-rs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eldruin%2Ftcs3472-rs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264466881,"owners_count":23612811,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["color","driver","embedded","embedded-hal","embedded-hal-driver","i2c","no-std","rgb","rust","sensor"],"created_at":"2024-10-09T05:09:12.057Z","updated_at":"2025-07-09T17:09:09.345Z","avatar_url":"https://github.com/eldruin.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rust TCS3472 RGB Color Light to Digital Converter with IR Filter Driver\n\n[![crates.io](https://img.shields.io/crates/v/tcs3472.svg)](https://crates.io/crates/tcs3472)\n[![Docs](https://docs.rs/tcs3472/badge.svg)](https://docs.rs/tcs3472)\n![Minimum Supported Rust Version](https://img.shields.io/badge/rustc-1.81+-blue.svg)\n[![Build Status](https://github.com/eldruin/tcs3472-rs/workflows/Build/badge.svg)](https://github.com/eldruin/tcs3472-rs/actions?query=workflow%3ABuild)\n[![Coverage Status](https://coveralls.io/repos/github/eldruin/tcs3472-rs/badge.svg?branch=master)](https://coveralls.io/github/eldruin/tcs3472-rs?branch=master)\n\nThis is a platform-agnostic Rust driver for the TCS3472 RGB color light to\ndigital converter with IR filter, based on the [`embedded-hal`] traits.\n\n[`embedded-hal`]: https://github.com/rust-embedded/embedded-hal\n\nThis driver allows you to:\n- Enable/disable the device.\n- Enable/disable the RGB converter.\n- Set RGB converter gain.\n- Enable/disable the RGB converter interrupt generation.\n- Set the RGB converter interrupt clear channel low/high thresholds.\n- Set the RGB converter interrupt persistence.\n- Set the number of integration cycles.\n- Enable/disable the wait feature.\n- Set the number of wait time cycles.\n- Enable/disable the *wait long* setting.\n- Read status of RGB converter.\n- Read the clear (unfiltered) channel measurement.\n- Read the red channel measurement.\n- Read the green channel measurement.\n- Read the blue channel measurement.\n- Read the measurement of all channels at once.\n- Read the device ID.\n\n## The device\nThe TCS3472 device provides a digital return of red, green, blue (RGB), and\nclear light sensing values. An IR blocking filter, integrated on-chip and\nlocalized to the color sensing photodiodes, minimizes the IR spectral\ncomponent of the incoming light and allows color measurements to be made\naccurately. The high sensitivity, wide dynamic range, and IR blocking\nfilter make the TCS3472 an ideal color sensor solution for use under\nvarying lighting conditions and through attenuating materials.\n\nThe TCS3472 color sensor has a wide range of applications including RGB LED\nbacklight control, solid-state lighting, health/fitness products,\nindustrial process controls and medical diagnostic equipment. In addition,\nthe IR blocking filter enables the TCS3472 to perform ambient light sensing\n(ALS). Ambient light sensing is widely used in display-based products such\nas cell phones, notebooks, and TVs to sense the lighting environment and\nenable automatic display brightness for optimal viewing and power savings.\nThe TCS3472, itself, can enter a lower-power wait state between light\nsensing measurements to further reduce the average power consumption.\n\nDatasheet:\n- [TCS3472](https://ams.com/documents/20143/36005/TCS3472_DS000390_2-00.pdf)\n\nThis driver is compatible with the devices TCS34725 and TCS34727.\n\n## Usage\n\nTo use this driver, import this crate and an `embedded_hal` implementation,\nthen instantiate the device.\n\nPlease find additional examples using hardware in this repository: [driver-examples]\n\n[driver-examples]: https://github.com/eldruin/driver-examples\n\n```rust\nuse linux_embedded_hal::I2cdev;\nuse tcs3472::Tcs3472;\n\nfn main() {\n    let dev = I2cdev::new(\"/dev/i2c-1\").unwrap();\n    let mut sensor = Tcs3472::new(dev);\n    sensor.enable().unwrap();\n    sensor.enable_rgbc().unwrap();\n    while !sensor.is_rgbc_status_valid().unwrap() {\n        // wait for measurement to be available\n    }\n    let m = sensor.read_all_channels().unwrap();\n    println!(\n        \"Measurements: clear = {}, red = {}, green = {}, blue = {}\",\n        m.clear, m.red, m.green, m.blue\n    );\n}\n```\n\nThis driver also supports the `embedded-hal-async` traits if the `async` feature is enabled in the `Cargo.toml` file:\n\n```toml\ntcs3472 = { version = \"0.3.0\", features = [\"async\"] }\n```\n\nExample how it looks like when using the [Embassy](https://embassy.dev/) framework:\n\n```rust\n#[embassy_executor::main]\nasync fn main(_spawner: Spawner) {\n    let p = embassy_stm32::init(Default::default());\n    // embassy i2c setup details omitted\n    let mut i2c = I2c::new(..);\n    let mut sensor = Tcs3472::new(i2c);\n    sensor.enable().await.unwrap();\n    sensor.enable_rgbc().await.unwrap();\n    while !sensor.is_rgbc_status_valid().await.unwrap() {\n        // wait for measurement to be available\n    };\n    let m = sensor.read_all_channels().await.unwrap();\n    defmt::info!(\n        \"Measurements: clear = {}, red = {}, green = {}, blue = {}\",\n        m.clear, m.red, m.green, m.blue\n    );\n}\n```\n\n## Minimum Supported Rust Version (MSRV)\n\nThis crate is guaranteed to compile on stable Rust 1.81.0 and up. It *might*\ncompile with older versions but that may change in any new patch release.\n\n## Support\n\nFor questions, issues, feature requests, and other changes, please file an\n[issue in the github project](https://github.com/eldruin/tcs3472-rs/issues).\n\n## License\n\nLicensed under either of:\n\n * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or\n   http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or\n   http://opensource.org/licenses/MIT)\n\nat your option.\n\n### Contributing\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall\nbe dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feldruin%2Ftcs3472-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feldruin%2Ftcs3472-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feldruin%2Ftcs3472-rs/lists"}