pros_sys/ext_adi.rs
1//! Contains prototypes for interfacing with the 3-Wire Expander.
2
3use core::ffi::*;
4
5use crate::adi::*;
6
7/**
8Reference type for an initialized encoder.
9
10This merely contains the port number for the encoder, unlike its use as an
11object to store encoder data in PROS 2.
12*/
13pub type ext_adi_encoder_t = i32;
14
15/**
16Reference type for an initialized ultrasonic.
17
18This merely contains the port number for the ultrasonic, unlike its use as an
19object to store encoder data in PROS 2.
20*/
21pub type ext_adi_ultrasonic_t = i32;
22
23/**
24Reference type for an initialized gyroscope.
25
26This merely contains the port number for the gyroscope, unlike its use as an
27object to store gyro data in PROS 2.
28
29(Might Be useless with the wire expander.)
30*/
31pub type ext_adi_gyro_t = i32;
32
33/**
34Reference type for an initialized potentiometer.
35
36This merely contains the port number for the potentiometer, unlike its use as an
37object to store gyro data in PROS 2.
38*/
39pub type ext_adi_potentiometer_t = i32;
40
41/**
42Reference type for an initialized addressable led, which stores its smart and adi port.
43*/
44pub type ext_adi_led_t = i32;
45
46extern "C" {
47 /** Gets the configuration for the given ADI port.
48
49 This function uses the following values of errno when an error state is
50 reached:
51 ENXIO - Either the ADI port value or the smart port value is not within its
52 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
53
54 \param smart_port
55 The smart port number that the ADI Expander is in
56 \param adi_port
57 The ADI port number (from 1-8, 'a'-'h', 'A'-'H') for which to return
58 the configuration
59
60 \return The ADI configuration for the given port*/
61 pub fn ext_adi_port_get_config(smart_port: u8, adi_port: u8) -> adi_port_config_e_t;
62 /** Gets the value for the given ADI port.
63
64 This function uses the following values of errno when an error state is
65 reached:
66 ENXIO - Either the ADI port value or the smart port value is not within its
67 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
68
69 \param smart_port
70 The smart port number that the ADI Expander is in
71 \param adi_port
72 The ADI port number (from 1-8, 'a'-'h', 'A'-'H') for which to return
73 the configuration
74
75 \return The value stored for the given port*/
76 pub fn ext_adi_port_get_value(smart_port: u8, adi_port: u8) -> i32;
77 /** Configures an ADI port to act as a given sensor type.
78
79 This function uses the following values of errno when an error state is
80 reached:
81 ENXIO - Either the ADI port value or the smart port value is not within its
82 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
83
84 \param smart_port
85 The smart port number that the ADI Expander is in
86 \param adi_port
87 The ADI port number (from 1-8, 'a'-'h', 'A'-'H') to configure
88 \param type
89 The configuration type for the port
90
91 \return 1 if the operation was successful or PROS_ERR if the operation
92 failed, setting errno.*/
93 pub fn ext_adi_port_set_config(
94 smart_port: u8,
95 adi_port: u8,
96 port_type: adi_port_config_e_t,
97 ) -> i32;
98 /** Sets the value for the given ADI port.
99
100 This only works on ports configured as outputs, and the behavior will change
101 depending on the configuration of the port.
102
103 This function uses the following values of errno when an error state is
104 reached:
105 ENXIO - Either the ADI port value or the smart port value is not within its
106 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
107
108 \param smart_port
109 The smart port number that the ADI Expander is in
110 \param adi_port
111 The ADI port number (from 1-8, 'a'-'h', 'A'-'H') for which the value
112 will be set
113 \param value
114 The value to set the ADI port to
115
116 \return 1 if the operation was successful or PROS_ERR if the operation
117 failed, setting errno.*/
118 pub fn ext_adi_port_set_value(smart_port: u8, adi_port: u8, value: i32) -> i32;
119 /** Calibrates the analog sensor on the specified port and returns the new
120 calibration value.
121
122 This method assumes that the true sensor value is not actively changing at
123 this time and computes an average from approximately 500 samples, 1 ms apart,
124 for a 0.5 s period of calibration. The average value thus calculated is
125 returned and stored for later calls to the adi_analog_read_calibrated() and
126 adi_analog_read_calibrated_HR() functions. These functions will return
127 the difference between this value and the current sensor value when called.
128
129 Do not use this function when the sensor value might be unstable
130 (gyro rotation, accelerometer movement).
131
132 This function uses the following values of errno when an error state is
133 reached:
134 ENXIO - Either the ADI port value or the smart port value is not within its
135 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
136
137 \param smart_port
138 The smart port number that the ADI Expander is in
139 \param adi_port
140 The ADI port to calibrate (from 1-8, 'a'-'h', 'A'-'H')
141
142 \return The average sensor value computed by this function*/
143 pub fn ext_adi_analog_calibrate(smart_port: u8, adi_port: u8) -> i32;
144 /** Gets the 12-bit value of the specified port.
145
146 The value returned is undefined if the analog pin has been switched to a
147 different mode.
148
149 This function uses the following values of errno when an error state is
150 reached:
151 ENXIO - Either the ADI port value or the smart port value is not within its
152 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
153 EADDRINUSE - The port is not configured as an analog input
154
155 \param smart_port
156 The smart port number that the ADI Expander is in
157 \param adi_port
158 The ADI port (from 1-8, 'a'-'h', 'A'-'H') for which the value will be
159 returned
160
161 \return The analog sensor value, where a value of 0 reflects an input voltage
162 of nearly 0 V and a value of 4095 reflects an input voltage of nearly 5 V*/
163 pub fn ext_adi_analog_read(smart_port: u8, adi_port: u8) -> i32;
164 /** Gets the 12 bit calibrated value of an analog input port.
165
166 The adi_analog_calibrate() function must be run first. This function is
167 inappropriate for sensor values intended for integration, as round-off error
168 can accumulate causing drift over time. Use adi_analog_read_calibrated_HR()
169 instead.
170
171 This function uses the following values of errno when an error state is
172 reached:
173 ENXIO - Either the ADI port value or the smart port value is not within its
174 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
175 EADDRINUSE - The port is not configured as an analog input
176
177 \param smart_port
178 The smart port number that the ADI Expander is in
179 \param adi_port
180 The ADI port (from 1-8, 'a'-'h', 'A'-'H') for which the value will be
181 returned
182
183 \return The difference of the sensor value from its calibrated default from
184 -4095 to 4095*/
185 pub fn ext_adi_analog_read_calibrated(smart_port: u8, adi_port: u8) -> i32;
186 /** Gets the 16 bit calibrated value of an analog input port.
187
188 The adi_analog_calibrate() function must be run first. This is intended for
189 integrated sensor values such as gyros and accelerometers to reduce drift due
190 to round-off, and should not be used on a sensor such as a line tracker
191 or potentiometer.
192
193 The value returned actually has 16 bits of "precision", even though the ADC
194 only reads 12 bits, so that error induced by the average value being between
195 two values when integrated over time is trivial. Think of the value as the
196 true value times 16.
197
198 This function uses the following values of errno when an error state is
199 reached:
200 ENXIO - Either the ADI port value or the smart port value is not within its
201 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
202 EADDRINUSE - The port is not configured as an analog input
203
204 \param smart_port
205 The smart port number that the ADI Expander is in
206 \param adi_port
207 The ADI port (from 1-8, 'a'-'h', 'A'-'H') for which the value will be
208 returned
209
210 \return The difference of the sensor value from its calibrated default from
211 -16384 to 16384*/
212 pub fn ext_adi_analog_read_calibrated_HR(smart_port: u8, adi_port: u8) -> i32;
213 /** Gets the digital value (1 or 0) of a port configured as a digital input.
214
215 If the port is configured as some other mode, the digital value which
216 reflects the current state of the port is returned, which may or may not
217 differ from the currently set value. The return value is undefined for ports
218 configured as any mode other than a Digital Input.
219
220 This function uses the following values of errno when an error state is
221 reached:
222 ENXIO - Either the ADI port value or the smart port value is not within its
223 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
224 EADDRINUSE - The port is not configured as a digital input
225
226 \param smart_port
227 The smart port number that the ADI Expander is in
228 \param adi_port
229 The ADI port to read (from 1-8, 'a'-'h', 'A'-'H')
230
231 \return True if the pin is HIGH, or false if it is LOW*/
232 pub fn ext_adi_digital_read(smart_port: u8, adi_port: u8) -> i32;
233 /** Gets a rising-edge case for a digital button press.
234
235 This function is not thread-safe.
236 Multiple tasks polling a single button may return different results under the
237 same circumstances, so only one task should call this function for any given
238 button. E.g., Task A calls this function for buttons 1 and 2. Task B may call
239 this function for button 3, but should not for buttons 1 or 2. A typical
240 use-case for this function is to call inside opcontrol to detect new button
241 presses, and not in any other tasks.
242
243 This function uses the following values of errno when an error state is
244 reached:
245 ENXIO - Either the ADI port value or the smart port value is not within its
246 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
247 EADDRINUSE - The port is not configured as a digital input
248
249 \param smart_port
250 The smart port number that the ADI Expander is in
251 \param adi_port
252 The ADI port to read (from 1-8, 'a'-'h', 'A'-'H')
253
254 \return 1 if the button is pressed and had not been pressed
255 the last time this function was called, 0 otherwise.*/
256 pub fn ext_adi_digital_get_new_press(smart_port: u8, adi_port: u8) -> i32;
257 /** Sets the digital value (1 or 0) of a port configured as a digital output.
258
259 If the port is configured as some other mode, behavior is undefined.
260
261 This function uses the following values of errno when an error state is
262 reached:
263 ENXIO - Either the ADI port value or the smart port value is not within its
264 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
265 EADDRINUSE - The port is not configured as a digital output
266
267 \param smart_port
268 The smart port number that the ADI Expander is in
269 \param adi_port
270 The ADI port number (from 1-8, 'a'-'h', 'A'-'H') to configure
271 \param value
272 An expression evaluating to "true" or "false" to set the output to
273 HIGH or LOW respectively, or the constants HIGH or LOW themselves
274
275 \return 1 if the operation was successful or PROS_ERR if the operation
276 failed, setting errno.*/
277 pub fn ext_adi_digital_write(smart_port: u8, adi_port: u8, value: bool) -> i32;
278 /** Configures the port as an input or output with a variety of settings.
279
280 This function uses the following values of errno when an error state is
281 reached:
282 ENXIO - Either the ADI port value or the smart port value is not within its
283 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
284
285 \param smart_port
286 The smart port number that the ADI Expander is in
287 \param adi_port
288 The ADI port number (from 1-8, 'a'-'h', 'A'-'H') to configure
289 \param mode
290 One of INPUT, INPUT_ANALOG, INPUT_FLOATING, OUTPUT, or OUTPUT_OD
291
292 \return 1 if the operation was successful or PROS_ERR if the operation
293 failed, setting errno.*/
294 pub fn ext_adi_pin_mode(smart_port: u8, adi_port: u8, mode: u8) -> i32;
295 /** Sets the speed of the motor on the given port.
296
297 This function uses the following values of errno when an error state is
298 reached:
299 ENXIO - Either the ADI port value or the smart port value is not within its
300 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
301 EADDRINUSE - The port is not configured as an motor
302
303 \param smart_port
304 The smart port number that the ADI Expander is in
305 \param adi_port
306 The ADI port number (from 1-8, 'a'-'h', 'A'-'H') to configure
307 \param speed
308 The new signed speed; -127 is full reverse and 127 is full forward,
309 with 0 being off
310
311 \return 1 if the operation was successful or PROS_ERR if the operation
312 failed, setting errno.*/
313 pub fn ext_adi_motor_set(smart_port: u8, adi_port: u8, speed: i8) -> i32;
314 /** Gets the last set speed of the motor on the given port.
315
316 This function uses the following values of errno when an error state is
317 reached:
318 ENXIO - Either the ADI port value or the smart port value is not within its
319 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
320 EADDRINUSE - The port is not configured as an motor
321
322 \param smart_port
323 The smart port number that the ADI Expander is in
324 \param adi_port
325 The ADI port to get (from 1-8, 'a'-'h', 'A'-'H')
326
327 \return The last set speed of the motor on the given port*/
328 pub fn ext_adi_motor_get(smart_port: u8, adi_port: u8) -> i32;
329 /** Stops the motor on the given port.
330
331 This function uses the following values of errno when an error state is
332 reached:
333 ENXIO - Either the ADI port value or the smart port value is not within its
334 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
335 EADDRINUSE - The port is not configured as an motor
336
337 \param smart_port
338 The smart port number that the ADI Expander is in
339 \param adi_port
340 The ADI port to set (from 1-8, 'a'-'h', 'A'-'H')
341
342 \return 1 if the operation was successful or PROS_ERR if the operation
343 failed, setting errno.*/
344 pub fn ext_adi_motor_stop(smart_port: u8, adi_port: u8) -> i32;
345 /** Gets the number of ticks recorded by the encoder.
346
347 There are 360 ticks in one revolution.
348
349 This function uses the following values of errno when an error state is
350 reached:
351 ENXIO - Either the ADI port value or the smart port value is not within its
352 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
353 EADDRINUSE - The port is not configured as an encoder
354
355 \param enc
356 The adi_encoder_t object from adi_encoder_init() to read
357
358 \return The signed and cumulative number of counts since the last start or
359 reset*/
360 pub fn ext_adi_encoder_get(enc: ext_adi_encoder_t) -> i32;
361 /** Creates an encoder object and configures the specified ports accordingly.
362
363 This function uses the following values of errno when an error state is
364 reached:
365 ENXIO - Either the ADI port value or the smart port value is not within its
366 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
367 EADDRINUSE - The port is not configured as an encoder
368
369 \param smart_port
370 The smart port number that the ADI Expander is in
371 \param adi_port_top
372 The "top" wire from the encoder sensor with the removable cover side
373 up. This should be in port 1, 3, 5, or 7 ('A', 'C', 'E', or 'G').
374 \param adi_port_bottom
375 The "bottom" wire from the encoder sensor
376 \param reverse
377 If "true", the sensor will count in the opposite direction
378
379 \return An adi_encoder_t object to be stored and used for later calls to
380 encoder functions*/
381 pub fn ext_adi_encoder_init(
382 smart_port: u8,
383 adi_port_top: u8,
384 adi_port_bottom: u8,
385 reverse: bool,
386 ) -> ext_adi_encoder_t;
387 /** Sets the encoder value to zero.
388
389 It is safe to use this method while an encoder is enabled. It is not
390 necessary to call this method before stopping or starting an encoder.
391
392 This function uses the following values of errno when an error state is
393 reached:
394 ENXIO - Either the ADI port value or the smart port value is not within its
395 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
396 EADDRINUSE - The port is not configured as an encoder
397
398 \param enc
399 The adi_encoder_t object from adi_encoder_init() to reset
400
401 \return 1 if the operation was successful or PROS_ERR if the operation
402 failed, setting errno.*/
403 pub fn ext_adi_encoder_reset(enc: ext_adi_encoder_t) -> i32;
404 /** Disables the encoder and voids the configuration on its ports.
405
406 This function uses the following values of errno when an error state is
407 reached:
408 ENXIO - Either the ADI port value or the smart port value is not within its
409 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
410 EADDRINUSE - The port is not configured as an encoder
411
412 \param enc
413 The adi_encoder_t object from adi_encoder_init() to stop
414
415 \return 1 if the operation was successful or PROS_ERR if the operation
416 failed, setting errno.*/
417 pub fn ext_adi_encoder_shutdown(enc: ext_adi_encoder_t) -> i32;
418 /** Gets the current ultrasonic sensor value in centimeters.
419
420 If no object was found, zero is returned. If the ultrasonic sensor was never
421 started, the return value is undefined. Round and fluffy objects can cause
422 inaccurate values to be returned.
423
424 This function uses the following values of errno when an error state is
425 reached:
426 ENXIO - Either the ADI port value or the smart port value is not within its
427 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
428 EADDRINUSE - The port is not configured as an ultrasonic
429
430 \param ult
431 The adi_ultrasonic_t object from adi_ultrasonic_init() to read
432
433 \return The distance to the nearest object in m^-4 (10000 indicates 1 meter),
434 measured from the sensor's mounting points.*/
435 pub fn ext_adi_ultrasonic_get(ult: ext_adi_ultrasonic_t) -> i32;
436 /** Creates an ultrasonic object and configures the specified ports accordingly.
437
438 This function uses the following values of errno when an error state is
439 reached:
440 ENXIO - Either the ADI port value or the smart port value is not within its
441 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
442 EADDRINUSE - The port is not configured as an ultrasonic
443
444 \param smart_port
445 The smart port number that the ADI Expander is in
446 \param adi_port_ping
447 The port connected to the orange OUTPUT cable. This should be in port
448 1, 3, 5, or 7 ('A', 'C', 'E', 'G').
449 \param adi_port_echo
450 The port connected to the yellow INPUT cable. This should be in the
451 next highest port following port_ping.
452
453 \return An adi_ultrasonic_t object to be stored and used for later calls to
454 ultrasonic functions*/
455 pub fn ext_adi_ultrasonic_init(
456 smart_port: u8,
457 adi_port_ping: u8,
458 adi_port_echo: u8,
459 ) -> ext_adi_ultrasonic_t;
460 /** Disables the ultrasonic sensor and voids the configuration on its ports.
461
462 This function uses the following values of errno when an error state is
463 reached:
464 ENXIO - Either the ADI port value or the smart port value is not within its
465 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
466 EADDRINUSE - The port is not configured as an ultrasonic
467
468 \param ult
469 The adi_ultrasonic_t object from adi_ultrasonic_init() to stop
470
471 \return 1 if the operation was successful or PROS_ERR if the operation
472 failed, setting errno.*/
473 pub fn ext_adi_ultrasonic_shutdown(ult: ext_adi_ultrasonic_t) -> i32;
474 /** Gets the current gyro angle in tenths of a degree. Unless a multiplier is
475 applied to the gyro, the return value will be a whole number representing
476 the number of degrees of rotation times 10.
477
478 There are 360 degrees in a circle, thus the gyro will return 3600 for one
479 whole rotation.
480
481 This function uses the following values of errno when an error state is
482 reached:
483 ENXIO - Either the ADI port value or the smart port value is not within its
484 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
485 EADDRINUSE - The port is not configured as a gyro
486
487 \param gyro
488 The adi_gyro_t object for which the angle will be returned
489
490 \return The gyro angle in degrees.*/
491 pub fn ext_adi_gyro_get(gyro: ext_adi_gyro_t) -> c_double;
492 /** Initializes a gyroscope on the given port. If the given port has not
493 previously been configured as a gyro, then this function starts a 1300 ms
494 calibration period.
495
496 It is highly recommended that this function be called from initialize() when
497 the robot is stationary to ensure proper calibration.
498
499 This function uses the following values of errno when an error state is
500 reached:
501 ENXIO - Either the ADI port value or the smart port value is not within its
502 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
503 EADDRINUSE - The port is not configured as a gyro
504
505 \param smart_port
506 The smart port number that the ADI Expander is in
507 \param adi_port
508 The ADI port to initialize as a gyro (from 1-8, 'a'-'h', 'A'-'H')
509 \param multiplier
510 A scalar value that will be multiplied by the gyro heading value
511 supplied by the ADI
512
513 \return An adi_gyro_t object containing the given port, or PROS_ERR if the
514 initialization failed.*/
515 pub fn ext_adi_gyro_init(smart_port: u8, adi_port: u8, multiplier: c_double) -> ext_adi_gyro_t;
516 /** Resets the gyroscope value to zero.
517
518 This function uses the following values of errno when an error state is
519 reached:
520 ENXIO - Either the ADI port value or the smart port value is not within its
521 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
522 EADDRINUSE - The port is not configured as a gyro
523
524 \param gyro
525 The adi_gyro_t object for which the angle will be returned
526
527 \return 1 if the operation was successful or PROS_ERR if the operation
528 failed, setting errno.*/
529 pub fn ext_adi_gyro_reset(gyro: ext_adi_gyro_t) -> i32;
530 /** Disables the gyro and voids the configuration on its port.
531
532 This function uses the following values of errno when an error state is
533 reached:
534 ENXIO - Either the ADI port value or the smart port value is not within its
535 valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
536 EADDRINUSE - The port is not configured as a gyro
537
538 \param gyro
539 The adi_gyro_t object to be shut down
540
541 \return 1 if the operation was successful or PROS_ERR if the operation
542 failed, setting errno.*/
543 pub fn ext_adi_gyro_shutdown(gyro: ext_adi_gyro_t) -> i32;
544 /** Initializes a potentiometer on the given port.
545
546 This function uses the following values of errno when an error state is
547 reached:
548 ENXIO - The given value is not within the range of ADI Ports
549 EADDRINUSE - The port is not configured as a potentiometer
550
551 \param smart_port
552 The smart port with the adi expander (1-21)
553 \param adi_port
554 The ADI port to initialize as a gyro (from 1-8, 'a'-'h', 'A'-'H')
555 \param potentiometer_type
556 An adi_potentiometer_type_e_t enum value specifying the potentiometer version type
557
558 \return An adi_potentiometer_t object containing the given port, or PROS_ERR if the
559 initialization failed.*/
560 pub fn ext_adi_potentiometer_init(
561 smart_port: u8,
562 adi_port: u8,
563 potentiometer_type: adi_potentiometer_type_e_t,
564 ) -> ext_adi_potentiometer_t;
565 /** Gets the current potentiometer angle in tenths of a degree.
566
567 The original potentiometer rotates 250 degrees thus returning an angle between 0-250 degrees.
568 Potentiometer V2 rotates 333 degrees thus returning an angle between 0-333 degrees.
569
570 This function uses the following values of errno when an error state is
571 reached:
572 ENXIO - The given value is not within the range of ADI Ports
573 EADDRINUSE - The port is not configured as a potentiometer
574
575 \param potentiometer
576 The adi_potentiometer_t object for which the angle will be returned
577
578 \return The potentiometer angle in degrees.*/
579 pub fn ext_adi_potentiometer_get_angle(potentiometer: ext_adi_potentiometer_t) -> c_double;
580 /** Initializes a led on the given port.
581
582 This function uses the following values of errno when an error state is
583 reached:
584 ENXIO - The given value is not within the range of ADI Ports
585 EINVAL - A given value is not correct, or the buffer is null
586 EADDRINUSE - The port is not configured for ADI output
587
588 \param smart_port
589 The smart port with the adi expander (1-21)
590 \param adi_port
591 The ADI port to initialize as a led (from 1-8, 'a'-'h', 'A'-'H')
592
593 \return An ext_adi_led_t object containing the given port, or PROS_ERR if the
594 initialization failed.*/
595 pub fn ext_adi_led_init(smart_port: u8, adi_port: u8) -> ext_adi_led_t;
596 /** @brief Clear the entire led strip of color
597
598 This function uses the following values of errno when an error state is
599 reached:
600 ENXIO - The given value is not within the range of ADI Ports
601 EINVAL - A given value is not correct, or the buffer is null
602 EADDRINUSE - The port is not configured for ADI output
603
604 @param led port of type adi_led_t
605 @param buffer array of colors in format 0xRRGGBB, recommended that individual RGB value not to exceed 0x80 due to current draw
606 @param buffer_length length of buffer to clear
607 @return PROS_SUCCESS if successful, PROS_ERR if not*/
608 pub fn ext_adi_led_clear_all(led: ext_adi_led_t, buffer: *mut u32, buffer_length: u32) -> i32;
609 /** @brief Set the entire led strip using the colors contained in the buffer
610
611 This function uses the following values of errno when an error state is
612 reached:
613 ENXIO - The given value is not within the range of ADI Ports
614 EINVAL - A given value is not correct, or the buffer is null
615 EADDRINUSE - The port is not configured for ADI output
616
617 @param led port of type adi_led_t
618 @param buffer array of colors in format 0xRRGGBB, recommended that individual RGB value not to exceed 0x80 due to current draw
619 @param buffer_length length of buffer to clear
620 @return PROS_SUCCESS if successful, PROS_ERR if not*/
621 pub fn ext_adi_led_set(led: ext_adi_led_t, buffer: *mut u32, buffer_length: u32) -> i32;
622 /** @brief Set the entire led strip to one color
623
624 This function uses the following values of errno when an error state is
625 reached:
626 ENXIO - The given value is not within the range of ADI Ports
627 EINVAL - A given value is not correct, or the buffer is null
628 EADDRINUSE - The port is not configured for ADI output
629
630 @param led port of type adi_led_t
631 @param buffer array of colors in format 0xRRGGBB, recommended that individual RGB value not to exceed 0x80 due to current draw
632 @param buffer_length length of buffer to clear
633 @param color color to set all the led strip value to
634 @return PROS_SUCCESS if successful, PROS_ERR if not*/
635 pub fn ext_adi_led_set_all(
636 led: ext_adi_led_t,
637 buffer: *mut u32,
638 buffer_length: u32,
639 color: u32,
640 ) -> i32;
641 /** @brief Set one pixel on the led strip
642
643 This function uses the following values of errno when an error state is
644 reached:
645 ENXIO - The given value is not within the range of ADI Ports
646 EINVAL - A given value is not correct, or the buffer is null
647 EADDRINUSE - The port is not configured for ADI output
648
649 @param led port of type adi_led_t
650 @param buffer array of colors in format 0xRRGGBB, recommended that individual RGB value not to exceed 0x80 due to current draw
651 @param buffer_length length of the input buffer
652 @param color color to clear all the led strip to
653 @param pixel_position position of the pixel to clear (0 indexed)
654 @return PROS_SUCCESS if successful, PROS_ERR if not*/
655 pub fn ext_adi_led_set_pixel(
656 led: ext_adi_led_t,
657 buffer: *mut u32,
658 buffer_length: u32,
659 color: u32,
660 pixel_position: u32,
661 ) -> i32;
662 /** @brief Clear one pixel on the led strip
663
664 This function uses the following values of errno when an error state is
665 reached:
666 ENXIO - The given value is not within the range of ADI Ports
667 EINVAL - A given value is not correct, or the buffer is null
668 EADDRINUSE - The port is not configured for ADI output
669
670 @param led port of type adi_led_t
671 @param buffer array of colors in format 0xRRGGBB, recommended that individual RGB value not to exceed 0x80 due to current draw
672 @param buffer_length length of the input buffer
673 @param pixel_position position of the pixel to clear (0 indexed)
674 @return PROS_SUCCESS if successful, PROS_ERR if not*/
675 pub fn ext_adi_led_clear_pixel(
676 led: ext_adi_led_t,
677 buffer: *mut u32,
678 buffer_length: u32,
679 pixel_position: u32,
680 ) -> i32;
681}