pub trait Servo<'a> {
// Required methods
fn set_angle(&self, angle: u16) -> Result<(), ErrorCode>;
fn get_angle(&self) -> Result<usize, ErrorCode>;
}
Required Methods§
Sourcefn set_angle(&self, angle: u16) -> Result<(), ErrorCode>
fn set_angle(&self, angle: u16) -> Result<(), ErrorCode>
Changes the angle of the servo. Return values:
Ok(())
: The attempt at changing the angle was successful.FAIL
: Cannot change the angle.INVAL
: The value exceeds u16, indicating it’s incorrect since servomotors can only have a maximum of 360 degrees.NODEVICE
: The index exceeds the number of servomotors provided.
§Arguments
angle
- the variable that receives the angle (in degrees from 0 to 180) from the servo driver.