pub struct TouchPad<P: TouchPin, Tm: TouchMode, Dm: DriverMode> { /* private fields */ }
unstable
only.Expand description
A pin that is configured as a TouchPad.
Implementations§
Source§impl<P: TouchPin, Tm: TouchMode> TouchPad<P, Tm, Async>
impl<P: TouchPin, Tm: TouchMode> TouchPad<P, Tm, Async>
Sourcepub async fn wait_for_touch(&mut self, threshold: u16)
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>
impl<P: TouchPin> TouchPad<P, OneShot, Blocking>
Sourcepub fn start_measurement(&mut self)
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>
impl<P: TouchPin, Tm: TouchMode, Dm: DriverMode> TouchPad<P, Tm, Dm>
Sourcepub fn try_read(&mut self) -> Option<u16>
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>
impl<P: TouchPin, Tm: TouchMode> TouchPad<P, Tm, Blocking>
Sourcepub fn read(&mut self) -> u16
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.
Sourcepub fn enable_interrupt(&mut self, threshold: u16)
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 oftouch
innew
(defaults to below).
§Example
Sourcepub fn disable_interrupt(&mut self)
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.
Sourcepub fn clear_interrupt(&mut self)
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.
Sourcepub fn is_interrupt_set(&mut self) -> bool
pub fn is_interrupt_set(&mut self) -> bool
Checks if the pad is touched, based on the configured threshold value.