[−][src]Struct gp2y1014au::sensor::Gp2y1014au
Implementations
impl<PinLed, OneShotReader, Adc, Word, PinData> Gp2y1014au<PinLed, OneShotReader, Adc, Word, PinData> where
PinLed: OutputPin,
OneShotReader: OneShot<Adc, Word, PinData>,
PinData: Channel<Adc>,
[src]
PinLed: OutputPin,
OneShotReader: OneShot<Adc, Word, PinData>,
PinData: Channel<Adc>,
pub fn new(
pin_led: PinLed,
pin_data: PinData,
one_shot_reader: OneShotReader
) -> Self
[src]
pin_led: PinLed,
pin_data: PinData,
one_shot_reader: OneShotReader
) -> Self
Creates a new instance of the Gp2y1014au dust sensor
Arguments
pin_led
- The pin connected to the led for the sensor.pin_data
- The pin connected to data/out on the sensor.one_shot_reader
- A structure that implements "embedded_hal::adc::OneShot"
Example
ⓘThis example is not tested
use stm32f4xx_hal:: adc::{ Adc, config::AdcConfig }; // ... let pc1_led = gpioc.pc1.into_push_pull_output(); let pc0_out = gpioc.pc0.into_analog(); let mut adc = Adc::adc1(board_peripherals.ADC1, true, AdcConfig::default()); let mut reader = Gp2y1014au::new(pc1_led, pc0_out, adc);
pub fn read(
&mut self
) -> Result<Word, Error<PinLed::Error, OneShotReader::Error>>
[src]
&mut self
) -> Result<Word, Error<PinLed::Error, OneShotReader::Error>>
Reads the pin state. Returns back Word
which varies based on your HAL implementation.
The error types returned back from this will either be Error::LedError
or Error::ReadError
.
Error::ReadError
- Implies the OneShot::read function failed for some reason.nb::Error::WouldBlock
is already handled in the code as a loop.Error::LedError
- Implies the pin for the LED was either failed to be set low or high respectively. This error indicates you should probably discard the result and call the method again.
pub fn split(self) -> (PinLed, PinData, OneShotReader)
[src]
Returns back the pins and reader used to construct the sensor. This function consumes self.
Auto Trait Implementations
impl<PinLed, OneShotReader, Adc, Word, PinData> Send for Gp2y1014au<PinLed, OneShotReader, Adc, Word, PinData> where
Adc: Send,
OneShotReader: Send,
PinData: Send,
PinLed: Send,
Word: Send,
Adc: Send,
OneShotReader: Send,
PinData: Send,
PinLed: Send,
Word: Send,
impl<PinLed, OneShotReader, Adc, Word, PinData> Sync for Gp2y1014au<PinLed, OneShotReader, Adc, Word, PinData> where
Adc: Sync,
OneShotReader: Sync,
PinData: Sync,
PinLed: Sync,
Word: Sync,
Adc: Sync,
OneShotReader: Sync,
PinData: Sync,
PinLed: Sync,
Word: Sync,
impl<PinLed, OneShotReader, Adc, Word, PinData> Unpin for Gp2y1014au<PinLed, OneShotReader, Adc, Word, PinData> where
Adc: Unpin,
OneShotReader: Unpin,
PinData: Unpin,
PinLed: Unpin,
Word: Unpin,
Adc: Unpin,
OneShotReader: Unpin,
PinData: Unpin,
PinLed: Unpin,
Word: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,