Struct veml7700::Veml7700

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

VEML7700 device driver.

Implementations§

source§

impl<I2C> Veml7700<I2C>
where I2C: I2c<SevenBitAddress>, I2C::Error: Into<Error<I2C::Error>>,

source

pub fn new(i2c: I2C) -> Self

Create new instance of the VEML6040 device.

source

pub fn destroy(self) -> I2C

Destroy driver instance, return I²C bus instance.

source§

impl<I2C> Veml7700<I2C>
where I2C: I2c<SevenBitAddress>, I2C::Error: Into<Error<I2C::Error>>,

source

pub fn enable(&mut self) -> Result<(), Error<I2C::Error>>

Enable the device.

Note that when activating the sensor a wait time of 4 ms should be observed before the first measurement is picked up to allow for a correct start of the signal processor and oscillator.

source

pub fn disable(&mut self) -> Result<(), Error<I2C::Error>>

Disable the device (shutdown).

source

pub fn set_integration_time( &mut self, it: IntegrationTime ) -> Result<(), Error<I2C::Error>>

Set the integration time.

source

pub fn set_gain(&mut self, gain: Gain) -> Result<(), Error<I2C::Error>>

Set the gain.

source

pub fn set_fault_count( &mut self, fc: FaultCount ) -> Result<(), Error<I2C::Error>>

Set the number of times a threshold crossing must happen consecutively to trigger an interrupt.

source

pub fn enable_interrupts(&mut self) -> Result<(), Error<I2C::Error>>

Enable interrupt generation.

source

pub fn disable_interrupts(&mut self) -> Result<(), Error<I2C::Error>>

Disable interrupt generation.

source

pub fn set_high_threshold_raw( &mut self, threshold: u16 ) -> Result<(), Error<I2C::Error>>

Set the ALS high threshold in raw format

source

pub fn set_low_threshold_raw( &mut self, threshold: u16 ) -> Result<(), Error<I2C::Error>>

Set the ALS low threshold in raw format

source

pub fn set_high_threshold_lux( &mut self, lux: f32 ) -> Result<(), Error<I2C::Error>>

Set the ALS high threshold in lux.

For values higher than 1000 lx and 1/4 or 1/8 gain, the inverse of the compensation formula is applied (this involves quite some math).

source

pub fn set_low_threshold_lux( &mut self, lux: f32 ) -> Result<(), Error<I2C::Error>>

Set the ALS low threshold in lux.

For values higher than 1000 lx and 1/4 or 1/8 gain, the inverse of the compensation formula is applied (this involves quite some math).

source

pub fn calculate_raw_threshold_value(&self, lux: f32) -> u16

Calculate raw value for threshold applying compensation if necessary.

This takes into consideration the configured integration time and gain and compensates the lux value if necessary.

For values higher than 1000 lx and 1/4 or 1/8 gain, the inverse of the compensation formula is applied. This involves quite some math so it may be interesting to calculate the threshold values ahead of time.

source

pub fn enable_power_saving( &mut self, psm: PowerSavingMode ) -> Result<(), Error<I2C::Error>>

Enable the power-saving mode

source

pub fn disable_power_saving(&mut self) -> Result<(), Error<I2C::Error>>

Disable the power-saving mode

source§

impl<I2C> Veml7700<I2C>
where I2C: I2c<SevenBitAddress>, I2C::Error: Into<Error<I2C::Error>>,

source

pub fn read_interrupt_status( &mut self ) -> Result<InterruptStatus, Error<I2C::Error>>

Read whether an interrupt has occurred.

Note that the interrupt status is updated at the same rate as the measurements. Once triggered, flags will stay true until a measurement is taken which does not exceed the threshold.

source

pub fn read_raw(&mut self) -> Result<u16, Error<I2C::Error>>

Read ALS high resolution output data in raw format

source

pub fn read_lux(&mut self) -> Result<f32, Error<I2C::Error>>

Read ALS high resolution output data converted to lux

For values higher than 1000 lx and 1/4 or 1/8 gain, the following compensation formula is applied: lux = 6.0135e-13*(lux^4) - 9.3924e-9*(lux^3) + 8.1488e-5*(lux^2) + 1.0023*lux

source

pub fn convert_raw_als_to_lux(&self, raw_als: u16) -> f32

Calculate lux value for a raw ALS measurement.

This takes into consideration the configured integration time and gain and compensates the lux value if necessary.

For values higher than 1000 lx and 1/4 or 1/8 gain, the following compensation formula is applied: lux = 6.0135e-13*(lux^4) - 9.3924e-9*(lux^3) + 8.1488e-5*(lux^2) + 1.0023*lux

source

pub fn read_white(&mut self) -> Result<u16, Error<I2C::Error>>

Read white channel measurement

Trait Implementations§

source§

impl<I2C: Debug> Debug for Veml7700<I2C>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<I2C> RefUnwindSafe for Veml7700<I2C>
where I2C: RefUnwindSafe,

§

impl<I2C> Send for Veml7700<I2C>
where I2C: Send,

§

impl<I2C> Sync for Veml7700<I2C>
where I2C: Sync,

§

impl<I2C> Unpin for Veml7700<I2C>
where I2C: Unpin,

§

impl<I2C> UnwindSafe for Veml7700<I2C>
where I2C: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.