[−][src]Struct rppal::gpio::OutputPin
GPIO pin configured as output.
OutputPin
s are constructed by converting a Pin
using Pin::into_output
.
The pin's mode is automatically set to Output
.
An OutputPin
can be used to change a pin's output state.
The embedded-hal
digital::OutputPin
and PwmPin
trait implementations for OutputPin
can be enabled by specifying the optional hal
feature in the dependency
declaration for the rppal
crate.
The unproven
embedded-hal
digital::InputPin
, digital::StatefulOutputPin
,
digital::ToggleableOutputPin
and Pwm
trait implementations for OutputPin
can be enabled
by specifying the optional hal-unproven
feature in the dependency declaration for
the rppal
crate.
Methods
impl OutputPin
[src]
pub fn pin(&self) -> u8
[src]
Returns the GPIO pin number.
Pins are addressed by their BCM numbers, rather than their physical location.
pub fn is_set_low(&self) -> bool
[src]
Returns true
if the pin's output state is set to Low
.
pub fn is_set_high(&self) -> bool
[src]
Returns true
if the pin's output state is set to High
.
pub fn write(&mut self, level: Level)
[src]
Sets the pin's output state.
pub fn set_low(&mut self)
[src]
Sets the pin's output state to Low
.
pub fn set_high(&mut self)
[src]
Sets the pin's output state to High
.
pub fn toggle(&mut self)
[src]
pub fn set_pwm(&mut self, period: Duration, pulse_width: Duration) -> Result<()>
[src]
Configures a software-based PWM signal.
period
indicates the time it takes to complete one cycle.
pulse_width
indicates the amount of time the PWM signal is active during a
single period.
Software-based PWM is inherently inaccurate on a multi-threaded OS due to
scheduling/preemption. If an accurate or faster PWM signal is required, use the
hardware Pwm
peripheral instead. More information can be found here.
If set_pwm
is called when a PWM thread is already active, the existing thread
will be reconfigured at the end of the current cycle.
pub fn set_pwm_frequency(
&mut self,
frequency: f64,
duty_cycle: f64
) -> Result<()>
[src]
&mut self,
frequency: f64,
duty_cycle: f64
) -> Result<()>
Configures a software-based PWM signal.
set_pwm_frequency
is a convenience method that converts frequency
to a period and
duty_cycle
to a pulse width, and then calls set_pwm
.
frequency
is specified in hertz (Hz).
duty_cycle
is specified as a floating point value between 0.0
(0%) and 1.0
(100%).
pub fn clear_pwm(&mut self) -> Result<()>
[src]
Stops a previously configured software-based PWM signal.
The thread responsible for emulating the PWM signal is stopped at the end of the current cycle.
pub fn reset_on_drop(&self) -> bool
[src]
Returns the value of reset_on_drop
.
pub fn set_reset_on_drop(&mut self, reset_on_drop: bool)
[src]
When enabled, resets the pin's mode to its original state and disables the
built-in pull-up/pull-down resistors when the pin goes out of scope.
By default, this is set to true
.
Note
Drop methods aren't called when a process is abnormally terminated, for
instance when a user presses Ctrl + C, and the SIGINT
signal
isn't caught. You can catch those using crates such as simple_signal
.
Trait Implementations
impl Debug for OutputPin
[src]
impl Drop for OutputPin
[src]
fn drop(&mut self)
[src]
Resets the pin's mode and disables the built-in pull-up/pull-down
resistors if reset_on_drop
is set to true
(default).
impl Eq for OutputPin
[src]
impl<'a> PartialEq<&'a OutputPin> for OutputPin
[src]
fn eq(&self, other: &&'a OutputPin) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialEq<OutputPin> for OutputPin
[src]
impl<'a> PartialEq<OutputPin> for &'a OutputPin
[src]
Auto Trait Implementations
impl !RefUnwindSafe for OutputPin
impl Send for OutputPin
impl Sync for OutputPin
impl Unpin for OutputPin
impl !UnwindSafe for OutputPin
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>,