Struct Tcs3472

Source
pub struct Tcs3472<I2C> { /* private fields */ }
Expand description

TCS3472 device driver.

Implementations§

Source§

impl<I2C, E> Tcs3472<I2C>
where I2C: I2c<Error = E>,

Source

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

Enable the device (Power ON).

The device goes to idle state.

Source

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

Disable the device (sleep).

Source

pub fn enable_rgbc(&mut self) -> Result<(), Error<E>>

Enable the RGB converter.

Source

pub fn disable_rgbc(&mut self) -> Result<(), Error<E>>

Disable the RGB converter.

Source

pub fn enable_rgbc_interrupts(&mut self) -> Result<(), Error<E>>

Enable the RGB converter interrupt generation.

Source

pub fn disable_rgbc_interrupts(&mut self) -> Result<(), Error<E>>

Disable the RGB converter interrupt generation.

Source

pub fn enable_wait(&mut self) -> Result<(), Error<E>>

Enable the wait feature (wait timer).

Source

pub fn disable_wait(&mut self) -> Result<(), Error<E>>

Disable the wait feature (wait timer).

Source

pub fn set_wait_cycles(&mut self, cycles: u16) -> Result<(), Error<E>>

Set the number of wait time cycles (1-256).

The actual wait time depends on the “wait long” setting.

  • If wait long is disabled, then the wait time corresponds to: number_of_cycles * 2.4ms.
  • If wait long is enabled, then the wait time is increased by a factor of 12 and therefore corresponds to aproximately: number_of_cycles * 0.029s.

See enable_wait_long() and disable_wait_long().

Source

pub fn enable_wait_long(&mut self) -> Result<(), Error<E>>

Enable the wait long setting.

The wait time configured with set_wait_cycles() is increased by a factor of 12. See set_wait_cycles().

Source

pub fn disable_wait_long(&mut self) -> Result<(), Error<E>>

Disable the wait long setting.

The wait time configured with set_wait_cycles() is used without multiplication factor. See set_wait_cycles().

Source

pub fn set_rgbc_gain(&mut self, gain: RgbCGain) -> Result<(), Error<E>>

Set the RGB converter gain.

Source

pub fn set_integration_cycles(&mut self, cycles: u16) -> Result<(), Error<E>>

Set the number of integration cycles (1-256).

The actual integration time corresponds to: number_of_cycles * 2.4ms.

Source

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

Set the RGB converter interrupt clear channel low threshold.

Source

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

Set the RGB converter interrupt clear channel high threshold.

Source

pub fn set_rgbc_interrupt_persistence( &mut self, persistence: RgbCInterruptPersistence, ) -> Result<(), Error<I2C::Error>>

Set the RGB converter interrupt persistence.

This controls the RGB converter interrupt generation rate.

Source§

impl<I2C, E> Tcs3472<I2C>
where I2C: I2c<Error = E>,

Source

pub fn is_rgbc_status_valid(&mut self) -> Result<bool, Error<E>>

Check whether the RGB converter status is valid.

Indicates that the RGBC channels have completed an integration cycle.

Source

pub fn read_clear_channel(&mut self) -> Result<u16, Error<E>>

Read the clear (unfiltered) channel measurement data.

Source

pub fn read_red_channel(&mut self) -> Result<u16, Error<E>>

Read the red channel measurement data.

Source

pub fn read_green_channel(&mut self) -> Result<u16, Error<E>>

Read the green channel measurement data.

Source

pub fn read_blue_channel(&mut self) -> Result<u16, Error<E>>

Read the blue channel measurement data.

Source

pub fn read_all_channels(&mut self) -> Result<AllChannelMeasurement, Error<E>>

Read the measurement data of all channels at once.

Source

pub fn read_device_id(&mut self) -> Result<u8, Error<E>>

Read the device ID.

The value returned corresponds to the part number identification:

  • 0x44 => TCS34725
  • 0x4D => TCS34727
Source§

impl<I2C> Tcs3472<I2C>

Source

pub fn new(i2c: I2C) -> Self

Create new instance of the TCS3472 device.

Source

pub fn destroy(self) -> I2C

Destroy driver instance, return I²C bus instance.

Trait Implementations§

Source§

impl<I2C: Debug> Debug for Tcs3472<I2C>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<I2C> Freeze for Tcs3472<I2C>
where I2C: Freeze,

§

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

§

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

§

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

§

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

§

impl<I2C> UnwindSafe for Tcs3472<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>,

Source§

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>,

Source§

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.