| Crates.io | opt40xx |
| lib.rs | opt40xx |
| version | 0.0.0 |
| created_at | 2025-12-01 13:19:43.759108+00 |
| updated_at | 2025-12-01 13:19:43.759108+00 |
| description | Driver for the OPT40xx ambient light sensors. |
| homepage | |
| repository | https://github.com/phycrax/opt40xx-rs |
| max_upload_size | |
| id | 1959765 |
| size | 50,966 |
Barebones driver for OPT40xx ambient light sensor family based on embedded-hal traits.
This sensor family uses almost the same register map for all its members.
Each member differ by:
It's possible to fully support each member individually by introducing member marker generics. This driver does not track sensor state, it exposes an interface to set whole registers instead, to keep things simple.
Implemented:
read_raw().read_status().set_config_a() and set_config_b().read_device_id().use opt40xx::*;
let mut i2c = // i2c bus that implements e-hal trait.
let mut sensor = Sensor::new(i2c, Address::Gnd);
sensor.set_config_a(ConfigA {
operating_mode: OperatingMode::Continuous,
conv_time: ConversionTime::Ms25,
..Default::default()
})
.unwrap();
loop {
let measurement = sensor.read_raw(Channel::Ch0, BurstRead::Enabled).unwrap();
info!("measurement: {:?}, count: {:?}", measurement.0, measurement.1);
}
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.