Struct apds9960::Apds9960

source ·
pub struct Apds9960<I2C> { /* private fields */ }
Expand description

APDS9960 device driver.

Implementations

Common configuration.

Turn power on.

Deactivate everything and put the device to sleep.

Enable the wait feature.

Enables delay between proximity and / or color and ambient light cycles. The duration of the wait can be configured with set_wait_time() and enable_wait_long().

Disable the wait feature.

Enable long wait.

The wait time will be multiplied by 12 so that each cycle takes 0.03s. See also: set_wait_time().

Wait must be enabled with enable_wait().

Disable long wait.

Set the waiting time between proximity and / or color and ambient light cycles.

The value parameter must be a 2’s complement of the number of cycles.

Per default this is set to 0xFF (1 cycle) and each cycle has a fixed duration of 2.78ms except if long wait is enabled, then this time is multiplied by 12.

This must be set before enabling proximity and / or color and ambient light detection.

Waiting must be enabled with enable_wait(). Long wait can be enabled with enable_wait_long().

Force an interrupt.

Clear all non-gesture interrupts.

Gesture engine configuration.

Enable gesture detection

Disable gesture detection

Enable gesture mode.

This can be automatically enabled (depending on proximity thresholds) and disabled (see GMODE on datasheet).

Disable gesture mode.

This can be automatically enabled (depending on proximity thresholds) and disabled (see GMODE on datasheet).

Enable gesture interrupt generation

Disable gesture interrupt generation

Set the threshold of amount of available data in the gesture FIFO registers.

source

pub fn set_gesture_proximity_entry_threshold(
    &mut self,
    threshold: u8
) -> Result<(), Error<E>>

Set the gesture proximity entry threshold.

Set the gesture proximity exit threshold.

Set the gesture up offset.

Set the gesture down offset.

Set the gesture left offset.

Set the gesture right offset.

Set the gesture up, down, left and right offsets.

Gesture data reading.

Read the amount of available data in the gesture FIFO registers.

Read whether there is valid gesture data available.

Read whether the gesture data has overflown.

Read gesture data.

Will read the gesture data up to the minimum of: gesture data level, array size. Make sure to provide an array with at least the number of elements returned by the read_gesture_data_level() method multiplied by 4.

The data contents will be organized as follows: [up_dataset0, down_dataset0, left_dataset0, right_dataset0, up_dataset1, down_dataset1, left_dataset1, right_dataset1, ...]

Returns nb::Error::WouldBlock as long as not enough data is available.

Color and ambient light.

Enable color and ambient light detection.

Disable color and ambient light detection.

Set the color and ambient light integration time.

The value parameter must be a 2’s complement of the number of cycles.

Per default this is set to 0xFF (1 cycle) and each cycle has a fixed duration of 2.78ms.

Enable ambient light interrupt generation.

Disable ambient light interrupt generation.

Enable clear channel ambient light saturation interrupt generation.

Disable clear channel ambient light saturation interrupt generation.

Set the clear channel ambient light interrupt low threshold.

An interrupt will be generated if light interrupts are enabled and the clear data is less than this value.

Set the clear channel ambient light interrupt high threshold.

An interrupt will be generated if light interrupts are enabled and the clear data is greater than this value.

Clear ambient light interrupt.

Read the color / ambient light sensor data.

Returns nb::Error::WouldBlock as long as the data is not ready. This clears the data ready flag.

Read the color / ambient light sensor clear channel data.

Returns nb::Error::WouldBlock as long as the data is not ready. This clears the data ready flag.

Read the color / ambient light sensor red channel data.

Returns nb::Error::WouldBlock as long as the data is not ready. This clears the data ready flag.

Read the color / ambient light sensor green channel data.

Returns nb::Error::WouldBlock as long as the data is not ready. This clears the data ready flag.

Read the color / ambient light sensor blue channel data.

Returns nb::Error::WouldBlock as long as the data is not ready. This clears the data ready flag.

Read whether the color and ambient light sensor data is valid.

This is checked internally in the read_light_*() methods as well.

Proximity.

Enable proximity detection

Disable proximity detection

Enable proximity interrupt generation

Disable proximity interrupt generation

Enable proximity saturation interrupt generation

Disable proximity saturation interrupt generation

Set the proximity interrupt low threshold.

Set the proximity interrupt high threshold.

Set the proximity up/right photodiode offset.

Set the proximity down/left photodiode offset.

Set the proximity up/right and down/left photodiode offset.

Clear proximity interrupt.

Read the proximity sensor data.

Returns nb::Error::WouldBlock as long as the data is not ready.

Read whether the proximity sensor data is valid.

This is checked internally in read_proximity() as well.

Read the device ID.

This is per default 0xAB.

Create new instance of the APDS9960 device.

Destroy driver instance, return I²C bus instance.

Trait Implementations

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.