diff --git a/apis/interface/servo/src/lib.rs b/apis/interface/servo/src/lib.rs index 825c241b..abc65f4e 100644 --- a/apis/interface/servo/src/lib.rs +++ b/apis/interface/servo/src/lib.rs @@ -15,34 +15,40 @@ impl Servo { } } /// Returns the number of the servomotors available. - pub fn servo_count() -> Result { + pub fn count() -> Result { S::command(DRIVER_NUM, SERVO_COUNT, 0, 0).to_result() } /// Changes the angle of the servo. - /// Return values: /// + /// # Arguments + /// - `angle` - the variable that receives the angle + /// (in degrees from 0 to 180) from the servo driver. + /// - `index` - the variable that receives the index of the servomotor. + /// + /// # Return values: /// - `Ok(())`: The attempt at changing the angle was successful. + /// + /// # Errors: /// - `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. - /// - `index` - the variable that receives the index of the servomotor. pub fn set_angle(index: u32, angle: u32) -> Result<(), ErrorCode> { S::command(DRIVER_NUM, SET_ANGLE, index, angle).to_result() } /// Returns the angle of the servo. - /// Return values: /// + /// # Arguments + /// - `index` - the variable that receives the index of the servomotor. + /// + /// # Return values: /// - `angle`: The value, in angles from 0 to 360, of the servo. + /// + /// # Errors: /// - `NOSUPPORT`: The servo cannot return its angle. /// - `NODEVICE`: The index exceeds the number of servomotors provided. - /// # Arguments - /// - `index` - the variable that receives the index of the servomotor. pub fn get_angle(index: u32) -> Result { S::command(DRIVER_NUM, GET_ANGLE, index, 0).to_result() } diff --git a/apis/interface/servo/src/tests.rs b/apis/interface/servo/src/tests.rs index 33a778bc..79a256ed 100644 --- a/apis/interface/servo/src/tests.rs +++ b/apis/interface/servo/src/tests.rs @@ -16,11 +16,11 @@ fn exists() { assert_eq!(Servo::exists(), Ok(())); } #[test] -fn servo_count() { +fn count() { let kernel = fake::Kernel::new(); let driver = fake::Servo::<2>::new(); kernel.add_driver(&driver); - assert_eq!(Servo::servo_count(), Ok(2)); + assert_eq!(Servo::count(), Ok(2)); } #[test] fn set_angle() {