Struct syact::device::SoftwarePWM
source · pub struct SoftwarePWM<P: OutputPin + Send> { /* private fields */ }Expand description
A simple software-made PWM-signal
Implementations§
source§impl<P: OutputPin + Send + 'static> SoftwarePWM<P>
impl<P: OutputPin + Send + 'static> SoftwarePWM<P>
sourcepub fn new(pin: P) -> Self
pub fn new(pin: P) -> Self
Create a new software PWM-signal at the given pin. Make sure the pin is not already in use!
§Setup
Once the setup function is called, the thread and the pin will be crated
sourcepub fn with_period_time(self, time: Time) -> Self
pub fn with_period_time(self, time: Time) -> Self
Sets the period time of the signal inline
sourcepub fn pulse(pin: &mut P, t_ac: Time, t_in: Time) -> Result<(), P::Error>
pub fn pulse(pin: &mut P, t_ac: Time, t_in: Time) -> Result<(), P::Error>
Does a single pulse with the active time t_ac and inactive time t_in
sourcepub fn get_period(&self) -> [Time; 2]
pub fn get_period(&self) -> [Time; 2]
Get the signal times in period style (t_ac, t_per)
sourcepub fn set_period(&mut self, t_ac: Time, t_per: Time)
pub fn set_period(&mut self, t_ac: Time, t_per: Time)
Set the signal times in period style
t_acis the active timet_peris the full period time
§Panics
The function panics if the given active time t_ac is bigger than the period time t_per
sourcepub fn get_freq(&self) -> (Velocity, f32)
pub fn get_freq(&self) -> (Velocity, f32)
Get the signal times in frequency style (freq, factor)
freqis the freqency of the signal, meaning how many pulses there are per secondfactorrepresents how much of the pulse is active time (values0.0to1.0)
sourcepub fn set_freq(&mut self, freq: Frequency, factor: f32)
pub fn set_freq(&mut self, freq: Frequency, factor: f32)
Set the signal times in frequency style
freqis the freqency of the signal, meaning how many pulses there are per secondfactorrepresents how much of the pulse is active time (values0.0to1.0)
§Panics
The function panics if the given factor is out of range
Trait Implementations§
source§impl<P: OutputPin + Send + 'static> Dismantle for SoftwarePWM<P>
impl<P: OutputPin + Send + 'static> Dismantle for SoftwarePWM<P>
source§impl<P: OutputPin + Send + 'static> SetDutyCycle for SoftwarePWM<P>
impl<P: OutputPin + Send + 'static> SetDutyCycle for SoftwarePWM<P>
source§fn max_duty_cycle(&self) -> u16
fn max_duty_cycle(&self) -> u16
Get the maximum duty cycle value. Read more
source§fn set_duty_cycle(&mut self, duty: u16) -> Result<(), Self::Error>
fn set_duty_cycle(&mut self, duty: u16) -> Result<(), Self::Error>
Set the duty cycle to
duty / max_duty. Read moresource§fn set_duty_cycle_fully_off(&mut self) -> Result<(), Self::Error>
fn set_duty_cycle_fully_off(&mut self) -> Result<(), Self::Error>
Set the duty cycle to 0%, or always inactive.
source§fn set_duty_cycle_fully_on(&mut self) -> Result<(), Self::Error>
fn set_duty_cycle_fully_on(&mut self) -> Result<(), Self::Error>
Set the duty cycle to 100%, or always active.
Auto Trait Implementations§
impl<P> Freeze for SoftwarePWM<P>
impl<P> !RefUnwindSafe for SoftwarePWM<P>
impl<P> Send for SoftwarePWM<P>
impl<P> !Sync for SoftwarePWM<P>
impl<P> Unpin for SoftwarePWM<P>where
P: Unpin,
impl<P> !UnwindSafe for SoftwarePWM<P>
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