[][src]Struct opt300x::Opt300x

pub struct Opt300x<I2C, IC, MODE> { /* fields omitted */ }

OPT300x device driver

Methods

impl<I2C> Opt300x<I2C, Opt3001, OneShot>[src]

pub fn new_opt3001(i2c: I2C, address: SlaveAddr) -> Self[src]

Create new instance of the device

impl<I2C> Opt300x<I2C, Opt3002, OneShot>[src]

pub fn new_opt3002(i2c: I2C, address: SlaveAddr) -> Self[src]

Create new instance of the device

impl<I2C> Opt300x<I2C, Opt3004, OneShot>[src]

pub fn new_opt3004(i2c: I2C, address: SlaveAddr) -> Self[src]

Create new instance of the device

impl<I2C> Opt300x<I2C, Opt3006, OneShot>[src]

pub fn new_opt3006(i2c: I2C, address: SlaveAddr) -> Self[src]

Create new instance of the device

impl<I2C> Opt300x<I2C, Opt3007, OneShot>[src]

pub fn new_opt3007(i2c: I2C) -> Self[src]

Create new instance of the OPT3007 device, which has a fixed I2C address.

impl<I2C, IC, MODE> Opt300x<I2C, IC, MODE>[src]

pub fn destroy(self) -> I2C[src]

Destroy driver instance, return I²C bus instance.

impl<I2C, E, IC> Opt300x<I2C, IC, OneShot> where
    I2C: Write<Error = E>, 
[src]

pub fn into_continuous(
    self
) -> Result<Opt300x<I2C, IC, Continuous>, ModeChangeError<E, Self>>
[src]

Change into continuous measurement mode

Note that the conversion ready flag is cleared automatically after calling this method.

impl<I2C, E, IC> Opt300x<I2C, IC, Continuous> where
    I2C: Write<Error = E>, 
[src]

pub fn into_one_shot(
    self
) -> Result<Opt300x<I2C, IC, OneShot>, ModeChangeError<E, Self>>
[src]

Change into one-shot mode

This will actually shut down the device until a measurement is requested.

impl<I2C, E, IC> Opt300x<I2C, IC, Continuous> where
    I2C: WriteRead<Error = E>, 
[src]

pub fn read_lux(&mut self) -> Result<f32, Error<E>>[src]

Read the result of the most recent light to digital conversion in lux

pub fn read_raw(&mut self) -> Result<(u8, u16), Error<E>>[src]

Read the result of the most recent light to digital conversion in raw format: (exponent, mantissa)

impl<I2C, E, IC> Opt300x<I2C, IC, OneShot> where
    I2C: WriteRead<Error = E> + Write<Error = E>, 
[src]

pub fn read_lux(&mut self) -> Result<Measurement<f32>, Error<E>>[src]

Read the result of the most recent light to digital conversion in lux

pub fn read_raw(&mut self) -> Result<Measurement<(u8, u16)>, Error<E>>[src]

Read the result of the most recent light to digital conversion in raw format: (exponent, mantissa)

impl<I2C, E, IC, MODE> Opt300x<I2C, IC, MODE> where
    I2C: WriteRead<Error = E>, 
[src]

pub fn read_status(&mut self) -> Result<Status, Error<E>>[src]

Read the status of the conversion.

Note that the conversion ready flag is cleared automatically after calling this method.

impl<I2C, E, IC, MODE> Opt300x<I2C, IC, MODE> where
    I2C: Write<Error = E>, 
[src]

pub fn set_fault_count(&mut self, count: FaultCount) -> Result<(), Error<E>>[src]

Set the fault count

Note that the conversion ready flag is cleared automatically after calling this method.

pub fn set_lux_range(&mut self, range: LuxRange) -> Result<(), Error<E>>[src]

Set the lux range.

Error::InvalidInputData will be returned for manual values outside the valid range.

Note that the conversion ready flag is cleared automatically after calling this method.

pub fn set_integration_time(
    &mut self,
    time: IntegrationTime
) -> Result<(), Error<E>>
[src]

Set the integration (conversion) time.

Note that the conversion ready flag is cleared automatically after calling this method.

pub fn set_interrupt_pin_polarity(
    &mut self,
    polarity: InterruptPinPolarity
) -> Result<(), Error<E>>
[src]

Set the interrupt pin polarity

Note that the conversion ready flag is cleared automatically after calling this method.

pub fn enable_exponent_masking(&mut self) -> Result<(), Error<E>>[src]

Enable exponent masking.

Note that the conversion ready flag is cleared automatically after calling this method.

pub fn disable_exponent_masking(&mut self) -> Result<(), Error<E>>[src]

Disable exponent masking (default).

Note that the conversion ready flag is cleared automatically after calling this method.

pub fn set_comparison_mode(
    &mut self,
    mode: ComparisonMode
) -> Result<(), Error<E>>
[src]

Set result comparison mode for interrupt reporting

Note that the conversion ready flag is cleared automatically after calling this method.

pub fn set_low_limit_raw(
    &mut self,
    exponent: u8,
    mantissa: u16
) -> Result<(), Error<E>>
[src]

Set the lux low limit in raw format (exponent, mantissa).

Returns Error::InvalidInputData for an exponent value greater than 11 or a mantissa value greater than 4095.

Note that this disables the end-of-conversion mode.

pub fn set_high_limit_raw(
    &mut self,
    exponent: u8,
    mantissa: u16
) -> Result<(), Error<E>>
[src]

Set the lux high limit in raw format (exponent, mantissa).

Returns Error::InvalidInputData for an exponent value greater than 11 or a mantissa value greater than 4095.

pub fn enable_end_of_conversion_mode(&mut self) -> Result<(), Error<E>>[src]

Enable end-of-conversion mode

Note that this changes the two highest bits of the lux low limit exponent. Please see the device datasheet for further details.

pub fn disable_end_of_conversion_mode(&mut self) -> Result<(), Error<E>>[src]

Disable end-of-conversion mode

Note that this restores the two highest bits of the lux low limit exponent to the last value set before enabling the end-of-conversion mode (0b00 by default).

impl<I2C, E, IC, MODE> Opt300x<I2C, IC, MODE> where
    I2C: WriteRead<Error = E>, 
[src]

pub fn get_manufacturer_id(&mut self) -> Result<u16, Error<E>>[src]

Read the manifacturer ID

impl<I2C, E, IC, MODE> Opt300x<I2C, IC, MODE> where
    I2C: WriteRead<Error = E>,
    IC: WithDeviceId, 
[src]

pub fn get_device_id(&mut self) -> Result<u16, Error<E>>[src]

Read the device ID

impl<I2C, IC, MODE> Opt300x<I2C, IC, MODE>[src]

pub fn reset_internal_driver_state(&mut self)[src]

Reset the internal state of this driver to the default values.

Note: This does not alter the state or configuration of the device.

This resets the cached configuration register value in this driver to the power-up (reset) configuration of the device.

This needs to be called after performing a reset on the device, for example through an I2C general-call Reset command, which was not done through this driver to ensure that the configurations in the device and in the driver match.

Trait Implementations

impl<I2C: Debug, IC: Debug, MODE: Debug> Debug for Opt300x<I2C, IC, MODE>[src]

Auto Trait Implementations

impl<I2C, IC, MODE> Unpin for Opt300x<I2C, IC, MODE> where
    I2C: Unpin,
    IC: Unpin,
    MODE: Unpin

impl<I2C, IC, MODE> Send for Opt300x<I2C, IC, MODE> where
    I2C: Send,
    IC: Send,
    MODE: Send

impl<I2C, IC, MODE> Sync for Opt300x<I2C, IC, MODE> where
    I2C: Sync,
    IC: Sync,
    MODE: Sync

impl<I2C, IC, MODE> UnwindSafe for Opt300x<I2C, IC, MODE> where
    I2C: UnwindSafe,
    IC: UnwindSafe,
    MODE: UnwindSafe

impl<I2C, IC, MODE> RefUnwindSafe for Opt300x<I2C, IC, MODE> where
    I2C: RefUnwindSafe,
    IC: RefUnwindSafe,
    MODE: RefUnwindSafe

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]