pros_sys/rotation.rs
1use core::ffi::c_uint;
2
3pub const ROTATION_MINIMUM_DATA_RATE: c_uint = 5;
4
5extern "C" {
6 /**
7 Reset Rotation Sensor
8
9 Reset the current absolute position to be the same as the
10 Rotation Sensor angle.
11
12 This function uses the following values of errno when an error state is
13 reached:
14 ENXIO - The given value is not within the range of V5 ports (1-21).
15 ENODEV - The port cannot be configured as an Rotation Sensor
16
17 \param port
18 The V5 Rotation Sensor port number from 1-21
19 \return 1 if the operation was successful or PROS_ERR if the operation
20 failed, setting errno.
21 */
22 pub fn rotation_reset(port: u8) -> i32;
23 /**
24 Set the Rotation Sensor's refresh interval in milliseconds.
25
26 The rate may be specified in increments of 5ms, and will be rounded down to
27 the nearest increment. The minimum allowable refresh rate is 5ms. The default
28 rate is 10ms.
29
30 This function uses the following values of errno when an error state is
31 reached:
32 ENXIO - The given value is not within the range of V5 ports (1-21).
33 ENODEV - The port cannot be configured as an Rotation Sensor
34
35 \param port
36 The V5 Rotation Sensor port number from 1-21
37 \param rate The data refresh interval in milliseconds
38 \return 1 if the operation was successful or PROS_ERR if the operation
39 failed, setting errno.
40 */
41 pub fn rotation_set_data_rate(port: u8, rate: u32) -> i32;
42 /**
43 Set the Rotation Sensor position reading to a desired rotation value
44
45 This function uses the following values of errno when an error state is
46 reached:
47 ENXIO - The given value is not within the range of V5 ports (1-21).
48 ENODEV - The port cannot be configured as an Rotation Sensor
49
50 \param port
51 The V5 Rotation Sensor port number from 1-21
52 \param position
53 The position in terms of ticks
54 \return 1 if the operation was successful or PROS_ERR if the operation
55 failed, setting errno.
56 */
57 pub fn rotation_set_position(port: u8, position: u32) -> i32;
58 /**
59 Reset the Rotation Sensor position to 0
60
61 This function uses the following values of errno when an error state is
62 reached:
63 ENXIO - The given value is not within the range of V5 ports (1-21).
64 ENODEV - The port cannot be configured as an Rotation Sensor
65
66 \param port
67 The V5 Rotation Sensor port number from 1-2
68 \return 1 if the operation was successful or PROS_ERR if the operation
69 failed, setting errno.
70 */
71 pub fn rotation_reset_position(port: u8) -> i32;
72 /**
73 Get the Rotation Sensor's current position in centidegrees
74
75 This function uses the following values of errno when an error state is
76 reached:
77 ENXIO - The given value is not within the range of V5 ports (1-21).
78 ENODEV - The port cannot be configured as an Rotation Sensor
79
80 \param port
81 The V5 Rotation Sensor port number from 1-21
82 \return The position value or PROS_ERR_F if the operation failed, setting
83 errno.
84 */
85 pub fn rotation_get_position(port: u8) -> i32;
86 /**
87 Get the Rotation Sensor's current velocity in centidegrees per second
88
89 This function uses the following values of errno when an error state is
90 reached:
91 ENXIO - The given value is not within the range of V5 ports (1-21).
92 ENODEV - The port cannot be configured as an Rotation Sensor
93
94 \param port
95 The V5 Rotation Sensor port number from 1-21
96 \return The velocity value or PROS_ERR_F if the operation failed, setting
97 errno.
98 */
99 pub fn rotation_get_velocity(port: u8) -> i32;
100 /**
101 Get the Rotation Sensor's current angle in centidegrees (0-36000)
102
103 This function uses the following values of errno when an error state is
104 reached:
105 ENXIO - The given value is not within the range of V5 ports (1-21).
106 ENODEV - The port cannot be configured as an Rotation Sensor
107
108 \param port
109 The V5 Rotation Sensor port number from 1-21
110 \return The angle value (0-36000) or PROS_ERR_F if the operation failed, setting
111 errno.
112 */
113 pub fn rotation_get_angle(port: u8) -> i32;
114 /**
115 Set the Rotation Sensor's direction reversed flag
116
117 This function uses the following values of errno when an error state is
118 reached:
119 ENXIO - The given value is not within the range of V5 ports (1-21).
120 ENODEV - The port cannot be configured as an Rotation Sensor
121
122 \param port
123 The V5 Rotation Sensor port number from 1-21
124 \param value
125 Determines if the direction of the Rotation Sensor is reversed or not.
126
127 \return 1 if operation succeeded or PROS_ERR if the operation failed, setting
128 errno.
129 */
130 pub fn rotation_set_reversed(port: u8, value: bool) -> i32;
131 /**
132 Reverse the Rotation Sensor's direction
133
134 This function uses the following values of errno when an error state is
135 reached:
136 ENXIO - The given value is not within the range of V5 ports (1-21).
137 ENODEV - The port cannot be configured as an Rotation Sensor
138
139 \param port
140 The V5 Rotation Sensor port number from 1-21
141
142 \return 1 if the operation was successful or PROS_ERR if the operation
143 failed, setting errno.
144 */
145 pub fn rotation_reverse(port: u8) -> i32;
146 /**
147 Initialize the Rotation Sensor with a reverse flag
148
149 This function uses the following values of errno when an error state is
150 reached:
151 ENXIO - The given value is not within the range of V5 ports (1-21).
152 ENODEV - The port cannot be configured as an Rotation Sensor
153
154 \param port
155 The V5 Rotation Sensor port number from 1-21
156 \param reverse_flag
157 Determines if the Rotation Sensor is reversed or not.
158
159 \return 1 if the operation was successful or PROS_ERR if the operation
160 failed, setting errno.
161 */
162 pub fn rotation_init_reverse(port: u8, reverse_flag: bool) -> i32;
163 /**
164 Get the Rotation Sensor's reversed flag
165
166 This function uses the following values of errno when an error state is
167 reached:
168 ENXIO - The given value is not within the range of V5 ports (1-21).
169 ENODEV - The port cannot be configured as an Rotation Sensor
170
171 \param port
172 The V5 Rotation Sensor port number from 1-21
173
174 \return Boolean value of if the Rotation Sensor's direction is reversed or not
175 or PROS_ERR if the operation failed, setting errno.
176 */
177 pub fn rotation_get_reversed(port: u8) -> i32;
178}