pub struct ServoConfig {
pub max_angle: f32,
pub frequency: Rate,
pub pulse_width_ns: Range<u32>,
pub duty: Duty,
}Fields§
§max_angle: f32Max angle that servo can be turned, mostly 180, 360.
frequency: RateWhat frequency expect servo (ex. 50Hz for SG90).
pulse_width_ns: Range<u32>What pulse width in nanos servo supports (ex. 500000-2400000ns for SG90).
duty: DutyPWM resolution in bits. Higher bits means more precise control.
Implementations§
Source§impl ServoConfig
impl ServoConfig
Sourcepub fn default_servo(duty: Duty, max_angle: f32) -> Self
pub fn default_servo(duty: Duty, max_angle: f32) -> Self
Default servo configuration with 50Hz frequency and pulse width range of 500000-2500000 ns (0.5-2.5ms).
Sourcepub fn mg995(duty: Duty) -> Self
pub fn mg995(duty: Duty) -> Self
Config for MG995. High-torque servo motor with metal gears. Can be used for MG996, MG996R as well.
Sourcepub fn configure_timer<'a, S: TimerSpeed>(
&self,
ledc: &mut Ledc<'a>,
timer_num: Number,
clock_source: S::ClockSourceType,
) -> Result<Timer<'a, S>, Error>
pub fn configure_timer<'a, S: TimerSpeed>( &self, ledc: &mut Ledc<'a>, timer_num: Number, clock_source: S::ClockSourceType, ) -> Result<Timer<'a, S>, Error>
Helper function to configure a timer with this servo’s configuration.
Sourcepub fn calc_duty_range(&self, max_duty: f32) -> Range<f32>
pub fn calc_duty_range(&self, max_duty: f32) -> Range<f32>
Calculates duty range in absolute values for this servo configuration. Returns absolute duty values (0..max_duty), not percentages.
Trait Implementations§
Source§impl Clone for ServoConfig
impl Clone for ServoConfig
Source§fn clone(&self) -> ServoConfig
fn clone(&self) -> ServoConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ServoConfig
impl RefUnwindSafe for ServoConfig
impl Send for ServoConfig
impl Sync for ServoConfig
impl Unpin for ServoConfig
impl UnwindSafe for ServoConfig
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