@@ -17,22 +17,20 @@ int main(void) {
17
17
uint16_t angle = 0 ;
18
18
uint16_t index = 0 ; // the first index available.
19
19
20
- if (libtock_read_servo_angle (index , & angle ) == RETURNCODE_ENODEVICE ) {
20
+ if (libtock_servo_read_angle (index , & angle ) == RETURNCODE_ENODEVICE ) {
21
21
printf ("\n The index number is bigger than the available servomotors\n" );
22
22
return -1 ;
23
23
}
24
24
25
25
// Changes the angle of the servomotor from 0 to 180 degrees (waiting 0.1 ms between every change).
26
26
for (int i = 0 ; i <= 180 ; i ++ ) {
27
27
// `result` stores the returned code received from the driver.
28
- result = libtock_set_servo_angle (index , i );
28
+ result = libtock_servo_set_angle (index , i );
29
29
if (result == RETURNCODE_SUCCESS ) {
30
30
libtocksync_alarm_delay_ms (100 );
31
31
// Verifies if the function successfully returned the current angle.
32
- if (libtock_read_servo_angle (index , & angle ) == RETURNCODE_SUCCESS ) {
32
+ if (libtock_servo_read_angle (index , & angle ) == RETURNCODE_SUCCESS ) {
33
33
printf ("\nThe current angle is: %d" , angle );
34
- } else {
35
- printf ("\n This servo cannot return its angle.\n" );
36
34
}
37
35
} else if (result == RETURNCODE_EINVAL ) {
38
36
printf ("\nThe angle you provided exceeds 360 degrees\n" );
@@ -42,4 +40,7 @@ int main(void) {
42
40
return -1 ;
43
41
}
44
42
}
43
+ if (libtock_servo_read_angle (index , & angle ) != RETURNCODE_SUCCESS ) {
44
+ printf ("\n This servo cannot return its angle.\n" );
45
+ }
45
46
}
0 commit comments