Struct TouchPad

Source
pub struct TouchPad<P: TouchPin, Tm: TouchMode, Dm: DriverMode> { /* private fields */ }
Available on crate feature unstable only.
Expand description

A pin that is configured as a TouchPad.

Implementations§

Source§

impl<P: TouchPin, Tm: TouchMode> TouchPad<P, Tm, Async>

Source

pub async fn wait_for_touch(&mut self, threshold: u16)

Wait for the pad to be touched.

Source§

impl<P: TouchPin> TouchPad<P, OneShot, Blocking>

Source

pub fn start_measurement(&mut self)

(Re-)Start a touch measurement on the pin. You can get the result by calling read once it is finished.

Source§

impl<P: TouchPin, Tm: TouchMode, Dm: DriverMode> TouchPad<P, Tm, Dm>

Source

pub fn new(pin: P, _touch: &Touch<'_, Tm, Dm>) -> Self

Construct a new instance of TouchPad.

§Parameters:
  • pin: The pin that gets configured as touch pad
  • touch: The Touch struct indicating that touch is configured.
Source

pub fn try_read(&mut self) -> Option<u16>

Read the current touch pad capacitance counter.

Usually a lower value means higher capacitance, thus indicating touch event.

Returns None if the value is not yet ready. (Note: Measurement must be started manually with start_measurement if the touch peripheral is in OneShot mode).

Source§

impl<P: TouchPin, Tm: TouchMode> TouchPad<P, Tm, Blocking>

Source

pub fn read(&mut self) -> u16

Blocking read of the current touch pad capacitance counter.

Usually a lower value means higher capacitance, thus indicating touch event.

§Note for OneShot mode:

This function might block forever, if start_measurement was not called before. As measurements are not cleared, the touch values might also be outdated, if it has been some time since the last call to that function.

Source

pub fn enable_interrupt(&mut self, threshold: u16)

Enables the touch_pad interrupt.

The raised interrupt is actually RTC_CORE. A handler can be installed with Rtc::set_interrupt_handler().

§Parameters:
  • threshold: The threshold above/below which the pin is considered touched. Above/below depends on the configuration of touch in new (defaults to below).
§Example
Source

pub fn disable_interrupt(&mut self)

Disables the touch pad’s interrupt.

If no other touch pad interrupts are active, the touch interrupt is disabled completely.

Source

pub fn clear_interrupt(&mut self)

Clears a pending touch interrupt.

§Note on interrupt clearing behaviour:

There is only a single interrupt for the touch pad. is_interrupt_set can be used to check which pins are touchted. However, this function clears the interrupt status for all pins. So only call it when all pins are handled.

Source

pub fn is_interrupt_set(&mut self) -> bool

Checks if the pad is touched, based on the configured threshold value.

Auto Trait Implementations§

§

impl<P, Tm, Dm> Freeze for TouchPad<P, Tm, Dm>
where P: Freeze,

§

impl<P, Tm, Dm> RefUnwindSafe for TouchPad<P, Tm, Dm>
where P: RefUnwindSafe, Tm: RefUnwindSafe, Dm: RefUnwindSafe,

§

impl<P, Tm, Dm> Send for TouchPad<P, Tm, Dm>
where P: Send, Tm: Send, Dm: Send,

§

impl<P, Tm, Dm> Sync for TouchPad<P, Tm, Dm>
where P: Sync, Tm: Sync, Dm: Sync,

§

impl<P, Tm, Dm> Unpin for TouchPad<P, Tm, Dm>
where P: Unpin, Tm: Unpin, Dm: Unpin,

§

impl<P, Tm, Dm> UnwindSafe for TouchPad<P, Tm, Dm>
where P: UnwindSafe, Tm: UnwindSafe, Dm: UnwindSafe,

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, U> TryFrom<U> for T
where 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>

Performs the conversion.
§

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.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.