[][src]Struct tsic::Tsic

pub struct Tsic<I: InputPin, O: OutputPin> { /* fields omitted */ }

The Tsic struct is the main entry point when trying to get a temperature reading from a TSIC 306 sensor.


impl<I: InputPin> Tsic<I, DummyOutputPin>[src]

pub fn without_vdd_control(sensor_type: SensorType, signal_pin: I) -> Self[src]

Constructs a new Tsic without explicit control over the voltage (VDD) pin.

Use this construction method if you either want to manage the power of your sensor externally or have it on a permanent voltage connection. Usually in this case only the signal pin of the sensor is attached to a GPIO pin of your board.

IMPORTANT: While this sounds like the simpler method, I recommend using the with_vdd_control constructor and also attach the VDD pin of the sensor to your board. This will reduce the risk of accidentially performing a reading during the actual temperature transmission. If you still want to use it this way, you probably want to consider retrying on transient failures when executing the read operation.

impl<I: InputPin, O: OutputPin> Tsic<I, O>[src]

pub fn with_vdd_control(
    sensor_type: SensorType,
    signal_pin: I,
    vdd_pin: O
) -> Self

Constructs a new Tsic with explicit control over the voltage (VDD) pin.

Use this method if you want the library to control the voltage (VDD) pin of the sensor as well.

This is the recommended approach because it saves power and it makes sure that the readings are very consistent (we do not run the risk of trying to perform a reading while one is already in-progress, leading to error values).

Usually you need to assign another GPIO pin as an output pin which can drive around 3V in high state (see the datasheet for more info), and then the library will control the power up, initial delay, reading and power down for you transparently. Of course, you can also use the without_vdd_control constructor if you want more manual control or if you have the sensor on permanent power.

pub fn read<D: DelayUs<u8>>(
    &mut self,
    delay: &mut D
) -> Result<Temperature, TsicError>

Attempts to read from the sensor, might fail (see errors for details if so).

Note that the passed in Delay from the HAL needs to be aquired outside of this struct and passed in as mutable, because to aquire correct data from the sensor the code needs to pause for a certain amount of microseconds.

In case there is an error during the read phase and if the Tsic has been constructed to manage the VDD pin as well, it will try to shut it down in a best-effort manner as well.

Auto Trait Implementations

impl<I, O> Send for Tsic<I, O> where
    I: Send,
    O: Send

impl<I, O> Sync for Tsic<I, O> where
    I: Sync,
    O: Sync

impl<I, O> Unpin for Tsic<I, O> where
    I: Unpin,
    O: Unpin

Blanket Implementations

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

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

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

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

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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.