https://github.com/joshmcguigan/tsl256x
Platform agnostic driver for TSL256x series light intensity sensors built using the embedded-hal
https://github.com/joshmcguigan/tsl256x
embedded embedded-hal embedded-hal-driver no-std rust
Last synced: about 1 year ago
JSON representation
Platform agnostic driver for TSL256x series light intensity sensors built using the embedded-hal
- Host: GitHub
- URL: https://github.com/joshmcguigan/tsl256x
- Owner: JoshMcguigan
- License: apache-2.0
- Created: 2018-07-07T22:36:51.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-14T16:26:50.000Z (almost 8 years ago)
- Last Synced: 2025-04-30T14:27:50.076Z (about 1 year ago)
- Topics: embedded, embedded-hal, embedded-hal-driver, no-std, rust
- Language: Rust
- Homepage:
- Size: 13.7 KB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE.txt
Awesome Lists containing this project
README
# tsl256x Light-To-Digital Converter [](https://crates.io/crates/tsl256x) [](https://docs.rs/tsl256x)
> Platform agnostic driver for TSL256x series of light intensity sensors built using the embedded-hal
## What works
- Getting raw sensor readings for both visible+IR spectrum and IR-only spectrum
- Using one of the three built in slave addresses, or any custom address
- Powering the chip on/off to conserve energy
- Setting sensor gain and integration time
## TODO
- [ ] Add method to perform lux calculation (requires nostd implementation of exponentiation for f32)
- [ ] Add method to setup interrupts
- [ ] Support the TSL2560 (SPI version)
## Example
```rust
extern crate tsl256x;
use tsl256x::{Tsl2561, SlaveAddr};
let sensor = Tsl2561::new(&mut i2c, SlaveAddr::default().addr()).unwrap();
sensor.power_on(&mut i2c);
// Note sensor readings are zero until one integration period (default 400ms) after power on
iprintln!(&mut cp.ITM.stim[0], "IR+Visible: {}, IR Only: {}",
sensor.visible_and_ir_raw(&mut i2c).unwrap(),
sensor.ir_raw(&mut i2c).unwrap());
```
## License
Licensed under either of
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.
### Contribution
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.