Skip to content

Commit 6fe02f5

Browse files
committed
function name update
1 parent a39088b commit 6fe02f5

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

examples/servo/main.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,20 @@ int main(void) {
1717
uint16_t angle = 0;
1818
uint16_t index = 0; // the first index available.
1919

20-
if (libtock_read_servo_angle(index, &angle) == RETURNCODE_ENODEVICE) {
20+
if (libtock_servo_read_angle(index, &angle) == RETURNCODE_ENODEVICE) {
2121
printf("\n The index number is bigger than the available servomotors\n");
2222
return -1;
2323
}
2424

2525
// Changes the angle of the servomotor from 0 to 180 degrees (waiting 0.1 ms between every change).
2626
for (int i = 0; i <= 180; i++) {
2727
// `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);
2929
if (result == RETURNCODE_SUCCESS) {
3030
libtocksync_alarm_delay_ms(100);
3131
// 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) {
3333
printf("\nThe current angle is: %d", angle);
34-
} else {
35-
printf("\n This servo cannot return its angle.\n");
3634
}
3735
} else if (result == RETURNCODE_EINVAL) {
3836
printf("\nThe angle you provided exceeds 360 degrees\n");
@@ -42,4 +40,7 @@ int main(void) {
4240
return -1;
4341
}
4442
}
43+
if (libtock_servo_read_angle(index, &angle) != RETURNCODE_SUCCESS) {
44+
printf("\n This servo cannot return its angle.\n");
45+
}
4546
}

libtock/interface/syscalls/servo_syscalls.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ returncode_t libtock_servo_count(uint16_t* servo_count) {
1616

1717
}
1818

19-
returncode_t libtock_set_servo_angle(uint16_t index, uint16_t angle) {
19+
returncode_t libtock_servo_set_angle(uint16_t index, uint16_t angle) {
2020
syscall_return_t cval = command(DRIVER_NUM_SERVO, 2, index, angle);
2121
return tock_command_return_novalue_to_returncode(cval);
2222
}
2323

24-
returncode_t libtock_read_servo_angle(uint16_t index, uint16_t* angle) {
24+
returncode_t libtock_servo_read_angle(uint16_t index, uint16_t* angle) {
2525
uint32_t value = 0;
2626
syscall_return_t r = command(DRIVER_NUM_SERVO, 3, index, 0);
2727
// Converts the value returned by the servo, stored in `r`

libtock/interface/syscalls/servo_syscalls.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ bool libtock_servo_exists(void);
1313
// Returns the number of available servomotors.
1414
returncode_t libtock_servo_count(uint16_t* servo_count);
1515
// Change the angle.
16-
returncode_t libtock_set_servo_angle(uint16_t index, uint16_t angle);
16+
returncode_t libtock_servo_set_angle(uint16_t index, uint16_t angle);
1717
// Requests the current angle from the servo.
18-
returncode_t libtock_read_servo_angle(uint16_t index, uint16_t* angle);
18+
returncode_t libtock_servo_read_angle(uint16_t index, uint16_t* angle);
1919

2020
#ifdef __cplusplus
2121
}

0 commit comments

Comments
 (0)