Crates.io | apds9253 |
lib.rs | apds9253 |
version | 1.0.0 |
source | src |
created_at | 2024-02-16 15:40:10.842466 |
updated_at | 2024-02-16 15:40:10.842466 |
description | Driver for APDS9253 light sensor |
homepage | |
repository | https://git.openlogisticsfoundation.org/silicon-economy/libraries/serum/apds9253 |
max_upload_size | |
id | 1142545 |
size | 43,280 |
This crate implements the driver for the APDS9253 RGB, ambient and IR light sensor from Broadcom. The sensor can be initialized in RGB mode, where all color channels and the infrared channel is available or in ALS mode, where only the ambient light and the infrared light channel is available.
The APDS has to be configured in RGB or ALS mode.
ALS mode:
## use embedded_hal_mock::*;
## let expectations = [];
## let mut i2c = i2c::Mock::new(&expectations);
##
use apds9253::*;
let mut sensor = Apds9253::new_als(i2c);
sensor.init().unwrap();
let ambient = sensor.read_ambient_light();
let infrared = sensor.read_infrared();
log::info!("Ambient: {ambient:?}, Infrared: {infrared:?}");
```rust
RGB mode:
```rust, no_run
#
use apds9253::*;
let mut sensor = Apds9253::new_rgb(i2c);
sensor.init().unwrap();
let red = sensor.read_red_channel();
let green = sensor.read_green_channel();
let blue = sensor.read_blue_channel();
let infrared = sensor.read_infrared();
log::info!("Red: {red:?}, Green: {green:?}, Blue: {blue:?}, Infrared: {infrared:?}");
Open Logistics Foundation License
Version 1.3, January 2023
See the LICENSE file in the top-level directory.
Fraunhofer IML Embedded Rust Group - embedded-rust@iml.fraunhofer.de