pub struct Veml7700<I2C> { /* private fields */ }
Expand description
VEML7700 device driver.
Implementations§
source§impl<I2C> Veml7700<I2C>
impl<I2C> Veml7700<I2C>
sourcepub fn enable(&mut self) -> Result<(), Error<I2C::Error>>
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.
sourcepub fn set_integration_time(
&mut self,
it: IntegrationTime
) -> Result<(), Error<I2C::Error>>
pub fn set_integration_time( &mut self, it: IntegrationTime ) -> Result<(), Error<I2C::Error>>
Set the integration time.
sourcepub fn set_fault_count(
&mut self,
fc: FaultCount
) -> Result<(), Error<I2C::Error>>
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.
sourcepub fn enable_interrupts(&mut self) -> Result<(), Error<I2C::Error>>
pub fn enable_interrupts(&mut self) -> Result<(), Error<I2C::Error>>
Enable interrupt generation.
sourcepub fn disable_interrupts(&mut self) -> Result<(), Error<I2C::Error>>
pub fn disable_interrupts(&mut self) -> Result<(), Error<I2C::Error>>
Disable interrupt generation.
sourcepub fn set_high_threshold_raw(
&mut self,
threshold: u16
) -> Result<(), Error<I2C::Error>>
pub fn set_high_threshold_raw( &mut self, threshold: u16 ) -> Result<(), Error<I2C::Error>>
Set the ALS high threshold in raw format
sourcepub fn set_low_threshold_raw(
&mut self,
threshold: u16
) -> Result<(), Error<I2C::Error>>
pub fn set_low_threshold_raw( &mut self, threshold: u16 ) -> Result<(), Error<I2C::Error>>
Set the ALS low threshold in raw format
sourcepub fn set_high_threshold_lux(
&mut self,
lux: f32
) -> Result<(), Error<I2C::Error>>
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).
sourcepub fn set_low_threshold_lux(
&mut self,
lux: f32
) -> Result<(), Error<I2C::Error>>
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).
sourcepub fn calculate_raw_threshold_value(&self, lux: f32) -> u16
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.
sourcepub fn enable_power_saving(
&mut self,
psm: PowerSavingMode
) -> Result<(), Error<I2C::Error>>
pub fn enable_power_saving( &mut self, psm: PowerSavingMode ) -> Result<(), Error<I2C::Error>>
Enable the power-saving mode
source§impl<I2C> Veml7700<I2C>
impl<I2C> Veml7700<I2C>
sourcepub fn read_interrupt_status(
&mut self
) -> Result<InterruptStatus, Error<I2C::Error>>
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.
sourcepub fn read_raw(&mut self) -> Result<u16, Error<I2C::Error>>
pub fn read_raw(&mut self) -> Result<u16, Error<I2C::Error>>
Read ALS high resolution output data in raw format
sourcepub fn read_lux(&mut self) -> Result<f32, Error<I2C::Error>>
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
sourcepub fn convert_raw_als_to_lux(&self, raw_als: u16) -> f32
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