pub struct PwmOutput { /* private fields */ }Expand description
Represents an analog actuator of unspecified type: an Output Device that write analog values from a PWM compatible pin.
https://docs.arduino.cc/language-reference/en/functions/analog-io/analogWrite/
Implementations§
Source§impl PwmOutput
impl PwmOutput
Sourcepub fn new<T: Into<PinIdOrName>>(
board: &dyn Hardware,
pin: T,
default: u16,
) -> Result<Self, Error>
pub fn new<T: Into<PinIdOrName>>( board: &dyn Hardware, pin: T, default: u16, ) -> Result<Self, Error>
Sourcepub fn set_percentage(&mut self, percentage: u8) -> Result<&Self, Error>
pub fn set_percentage(&mut self, percentage: u8) -> Result<&Self, Error>
Sets the PWM value to a percentage of its max value. NOTE: everything above 100 is considered 100%.
Sourcepub fn get_percentage(&self) -> u8
pub fn get_percentage(&self) -> u8
Gets the current percentage of the PWM value compared to max possible.
Trait Implementations§
Source§impl Output for PwmOutput
impl Output for PwmOutput
Source§fn set_state(&mut self, state: State) -> Result<State, Error>
fn set_state(&mut self, state: State) -> Result<State, Error>
Internal only: you should rather use Self::set_value() function.
Source§fn get_default(&self) -> State
fn get_default(&self) -> State
Returns the actuator default (or neutral) state.
Source§fn animate<S: Into<State>>(
&mut self,
state: S,
duration: u64,
transition: Easing,
)
fn animate<S: Into<State>>( &mut self, state: S, duration: u64, transition: Easing, )
Animates the output of the device. In other word: the state of the device will be animated from
current step to targeted step through an interpolation of in-between states.
The function will last for the required duration and the interpolation will follow an easing
transition function. Read more
Source§fn is_busy(&self) -> bool
fn is_busy(&self) -> bool
Indicates the busy status, ie if the device is running an animation.
impl Device for PwmOutput
Auto Trait Implementations§
impl Freeze for PwmOutput
impl !RefUnwindSafe for PwmOutput
impl Send for PwmOutput
impl Sync for PwmOutput
impl Unpin for PwmOutput
impl !UnwindSafe for PwmOutput
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more